[2.1.2-Scala] Exception running TEST-ONLY: Unable to download JavaScript

505 views
Skip to first unread message

Jose Alfonso Mora Lores

unread,
Aug 6, 2013, 8:45:29 AM8/6/13
to play-fr...@googlegroups.com
When i run TEST-ONLY or TEST i get the exception:

java.io.IOException: Unable to download JavaScript from 'http://localhost:19001/assets/javascripts/lib/../API.js' (status 500).
at com.gargoylesoftware.htmlunit.html.HtmlPage.loadJavaScriptFromUrl(HtmlPage.java:1016) [htmlunit.jar:2.9]

The tests do not break but it takes time to complete.

If i open the route http://localhost:19001/assets/javascripts/lib/../API.js i can see the script correctly

I'm surfing under a PROXY on Ubuntu 12.4

Maybe i need to configurate something but i don't know what.

THX

Jose Alfonso Mora Lores

unread,
Aug 7, 2013, 6:42:58 AM8/7/13
to play-fr...@googlegroups.com
This is the complete log:

[error] c.g.h.h.HtmlPage - Error loading JavaScript from [http://localhost:19001/assets/javascripts/lib/mustache.js].
java.io.IOException: Unable to download JavaScript from 'http://localhost:19001/assets/javascripts/lib/mustache.js' (status 500).
at com.gargoylesoftware.htmlunit.html.HtmlPage.loadJavaScriptFromUrl(HtmlPage.java:1016) [htmlunit.jar:2.9]
at com.gargoylesoftware.htmlunit.html.HtmlPage.loadExternalJavaScriptFile(HtmlPage.java:950) [htmlunit.jar:2.9]
at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:349) ~[htmlunit.jar:2.9]
at com.gargoylesoftware.htmlunit.html.HtmlScript$1.execute(HtmlScript.java:220) ~[htmlunit.jar:2.9]
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.doProcessPostponedActions(JavaScriptEngine.java:642) ~[htmlunit.jar:2.9]
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.access$400(JavaScriptEngine.java:79) ~[htmlunit.jar:2.9]
[error] c.g.h.h.HtmlPage - Error loading JavaScript from [http://localhost:19001/assets/javascripts/lib/../models//Presupuesto.js].
java.io.IOException: Unable to download JavaScript from 'http://localhost:19001/assets/javascripts/lib/../models//Presupuesto.js' (status 500).
at com.gargoylesoftware.htmlunit.html.HtmlPage.loadJavaScriptFromUrl(HtmlPage.java:1016) [htmlunit.jar:2.9]
at com.gargoylesoftware.htmlunit.html.HtmlPage.loadExternalJavaScriptFile(HtmlPage.java:950) [htmlunit.jar:2.9]
at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:349) ~[htmlunit.jar:2.9]
at com.gargoylesoftware.htmlunit.html.HtmlScript$1.execute(HtmlScript.java:220) ~[htmlunit.jar:2.9]
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.doProcessPostponedActions(JavaScriptEngine.java:642) ~[htmlunit.jar:2.9]
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.access$400(JavaScriptEngine.java:79) ~[htmlunit.jar:2.9]
[error] c.g.h.h.HtmlPage - Error loading JavaScript from [http://localhost:19001/assets/javascripts/lib/../views//PresupuestoView.js].
java.io.IOException: Unable to download JavaScript from 'http://localhost:19001/assets/javascripts/lib/../views//PresupuestoView.js' (status 500).
at com.gargoylesoftware.htmlunit.html.HtmlPage.loadJavaScriptFromUrl(HtmlPage.java:1016) [htmlunit.jar:2.9]
at com.gargoylesoftware.htmlunit.html.HtmlPage.loadExternalJavaScriptFile(HtmlPage.java:950) [htmlunit.jar:2.9]
at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:349) ~[htmlunit.jar:2.9]
at com.gargoylesoftware.htmlunit.html.HtmlScript$1.execute(HtmlScript.java:220) ~[htmlunit.jar:2.9]
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.doProcessPostponedActions(JavaScriptEngine.java:642) ~[htmlunit.jar:2.9]
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.access$400(JavaScriptEngine.java:79) ~[htmlunit.jar:2.9]
[error] c.g.h.h.HtmlPage - Error loading JavaScript from [http://localhost:19001/assets/javascripts/lib/../views//PresupuestoToOrdenView.js].
java.io.IOException: Unable to download JavaScript from 'http://localhost:19001/assets/javascripts/lib/../views//PresupuestoToOrdenView.js' (status 500).
at com.gargoylesoftware.htmlunit.html.HtmlPage.loadJavaScriptFromUrl(HtmlPage.java:1016) [htmlunit.jar:2.9]
at com.gargoylesoftware.htmlunit.html.HtmlPage.loadExternalJavaScriptFile(HtmlPage.java:950) [htmlunit.jar:2.9]
at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:349) ~[htmlunit.jar:2.9]
at com.gargoylesoftware.htmlunit.html.HtmlScript$1.execute(HtmlScript.java:220) ~[htmlunit.jar:2.9]
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.doProcessPostponedActions(JavaScriptEngine.java:642) ~[htmlunit.jar:2.9]
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.access$400(JavaScriptEngine.java:79) ~[htmlunit.jar:2.9]
[error] c.g.h.h.HtmlPage - Error loading JavaScript from [http://localhost:19001/assets/javascripts/lib/../API.js].
java.io.IOException: Unable to download JavaScript from 'http://localhost:19001/assets/javascripts/lib/../API.js' (status 500).
at com.gargoylesoftware.htmlunit.html.HtmlPage.loadJavaScriptFromUrl(HtmlPage.java:1016) [htmlunit.jar:2.9]
at com.gargoylesoftware.htmlunit.html.HtmlPage.loadExternalJavaScriptFile(HtmlPage.java:950) [htmlunit.jar:2.9]
at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:349) ~[htmlunit.jar:2.9]
at com.gargoylesoftware.htmlunit.html.HtmlScript$1.execute(HtmlScript.java:220) ~[htmlunit.jar:2.9]
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.doProcessPostponedActions(JavaScriptEngine.java:642) ~[htmlunit.jar:2.9]
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.access$400(JavaScriptEngine.java:79) ~[htmlunit.jar:2.9]



2013/8/6 Jose Alfonso Mora Lores <josealf...@gmail.com>

--
You received this message because you are subscribed to a topic in the Google Groups "play-framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/play-framework/yj4NT3BO0Os/unsubscribe.
To unsubscribe from this group and all its topics, send an email to play-framewor...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
José Alfonso Mora Lores

Johan Andren

unread,
Aug 8, 2013, 10:48:08 AM8/8/13
to play-fr...@googlegroups.com
It could be that you need WithServerWithApplication is not enough if you have code trying to access urls inside of the application that you want to test since it wont actually listen to http requests.

Can you really access the url when the tests are running, not only when you have the play app running normally?

Jose Alfonso Mora Lores

unread,
Aug 9, 2013, 3:06:28 AM8/9/13
to play-fr...@googlegroups.com
Yes, i can acces to this route running only test. If i run the play app i can acces to the route http://localhost:9000/...



2013/8/8 Johan Andren <johan....@mejsla.se>
It could be that you need WithServerWithApplication is not enough if you have code trying to access urls inside of the application that you want to test since it wont actually listen to http requests.

Can you really access the url when the tests are running, not only when you have the play app running normally?

--
You received this message because you are subscribed to a topic in the Google Groups "play-framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/play-framework/yj4NT3BO0Os/unsubscribe.
To unsubscribe from this group and all its topics, send an email to play-framewor...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Nilanjan Raychaudhuri

unread,
Aug 9, 2013, 8:33:43 AM8/9/13
to play-fr...@googlegroups.com
Could you share the test code so that I can take a look at?


Nilanjan, Developer & Consultant
Typesafe Inc.
Twitter: @nraychaudhuri
Message has been deleted

Jose Alfonso Mora Lores

unread,
Aug 9, 2013, 9:06:44 AM8/9/13
to play-fr...@googlegroups.com
package functional;

import static junit.framework.Assert.fail;
import static org.fest.assertions.Assertions.assertThat;
import static org.fluentlenium.core.filter.FilterConstructor.with;
import static org.fluentlenium.core.filter.FilterConstructor.withId;
import static org.fluentlenium.core.filter.FilterConstructor.withName;
import static org.fluentlenium.core.filter.FilterConstructor.withText;
import static play.mvc.Http.Status.BAD_REQUEST;
import static play.mvc.Http.Status.OK;
import static play.mvc.Http.Status.UNAUTHORIZED;
import static play.test.Helpers.*;

import java.io.File;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.annotation.Nullable;

import models.*;

import org.codehaus.jackson.JsonNode;
import org.fluentlenium.core.domain.FluentWebElement;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;

import play.libs.Json;
import play.libs.Yaml;
import play.mvc.Content;
import play.mvc.Result;
import play.test.FakeApplication;
import play.test.Helpers;
import play.test.TestBrowser;
import play.test.WithBrowser;

import com.avaje.ebean.Ebean;
import com.google.common.base.Function;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;

import controllers.routes;

public class OpenAlbaranTest extends WithBrowser {
    private String getValidAlbaranJson() {
        return "{\"serie\":\"S1\", \"codigo\":\"2013/01\", \"formaPago\":\"CONTADO\", \"fechaCreacion\":1368144000000, \"tipoFactura\":\"NORMAL\", \"rutaPDF\":null,"
                + "\"taller\" :{\"id\":100,\"nombre\":\"Talleres Dominguez\",\"direccion\":\"Avda de Arteixo, 44, 15142, Arteixo\",\"NIF\":\"B12345678\"},"
                + "\"cliente\":{\"id\":100,\"nombre\":\"Manuel\",\"apellidos\":\"Leira Neira\",\"telefono\":\"616353543\",\"direccion\":\"Santiago de Chile, 24 - Vigo\",\"nif\":\"32765876R\",\"porcentajeDescuento\":0}}";
    }

    @Before
    @SuppressWarnings("unchecked")
    public void setUp() {
        browser = new TestBrowser(new HtmlUnitDriver(), "3333");
        java.util.logging.Logger.getLogger("com.gargoylesoftware").setLevel(Level.OFF);
        java.util.logging.Logger.getLogger("org.xhtmlrenderer").setLevel(Level.OFF);
        app = fakeApplication(inMemoryDatabase());
        start(app);

        Map<String, List<Object>> all = (Map<String, List<Object>>) Yaml.load("test-data.yml");

        Ebean.save(all.get("talleres"));
        Ebean.save(all.get("usuarios"));
        Ebean.save(all.get("clientes"));
        Ebean.save(all.get("vehiculos"));
        Ebean.save(all.get("ors"));
        Ebean.save(all.get("averias"));
        Ebean.save(all.get("imputacion_pieza_ors"));
        Ebean.save(all.get("facturas"));
        Ebean.save(all.get("albaranes"));

        browser.goTo("/");
        browser.fill("#password").with("***");
        browser.fill("#login").with("***@***.es");
        browser.submit("#entrar");
    }

    @Test
    public void plantilla_de_abrir_albaran_recibe_albaran() {
        Albaran albaran = new Albaran();

        Content html = views.html.albaranes.abrir.render(albaran);
        assertThat(contentAsString(html)).contains("<body>");
    }
       
}


I think the problem is in browser = new TestBrowser(new HtmlUnitDriver(), "3333");

I tryed to change Build.scala at line "org.seleniumhq.selenium" % "selenium-firefox-driver" % "2.31.0" % "test" to "org.seleniumhq.selenium" % "selenium-java" % "2.32.0" % "test" but nothing happens


2013/8/9 Nilanjan Raychaudhuri <nraych...@gmail.com>
Reply all
Reply to author
Forward
0 new messages