Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    GWTTestCase and GWT 2.8 causes Load Script Error

    Recently I upgraded to GWT 2.8 from GWT 2.6.1. Now all of my GWTTestCases fail where they were all passing with GWT 2.6.1.

    I've written a simple test case fails. This test case calls new SmartGwtEntryPoint().onModuleLoad(),

    Code:
    [B]public[/B] [B]class[/B] BasicGWTTest [B]extends[/B] GWTTestCase {
     
        [B]public[/B] [B]void[/B] testBasic() [B]throws[/B] Exception {
            [B]new[/B] SmartGwtEntryPoint().onModuleLoad();
        }
     
        @Override
        [B]public[/B] String getModuleName() {
            [B]return[/B] "com.cedarcone.Orchestrate.OrchestrateJUnit";
        }
     
    }
    I run this test using the Eclipse Run as/GWT Junit Test

    Here is the resulting test log:

    Code:
    Mar 13, 2017 1:01:26 PM java.util.prefs.WindowsPreferences <init>
    WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
    log4j:WARN No appenders could be found for logger (org.eclipse.jetty.util.log).
    log4j:WARN Please initialize the log4j system properly.
    Compiling module com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit
       Ignored 420 units with compilation errors in first pass.
    Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
       Compiling 1 permutation
          Compiling permutation 0...
       Compile of permutations succeeded
       Compilation succeeded -- 18.057s
    Linking into P:\Git\CedarCone\Orchestrate\www-test\com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit
       Link succeeded
       Linking succeeded -- 19.029s
    Ignored 420 units with compilation errors in first pass.
    Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
    Starting http://localhost:59705/com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/junit.html on browser FF38
    200 - GET /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/junit.html (127.0.0.1)
    200 - GET /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit.nocache.js (127.0.0.1)
    200 - GET /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/2381ECD98107A199E2092EE7746E7EB5.cache.js (127.0.0.1)
    200 - GET /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/gwt/standard/standard.css (127.0.0.1)
    200 - POST /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/junithost (127.0.0.1) 219 bytes
    Here is the GWT module referred to in the test:

    Code:
    <?xml version=[I]"1.0"[/I] encoding=[I]"UTF-8"[/I]?>
    <module>
    <inherits name=[I]"com.google.gwt.logging.Logging"[/I]/>
    <inherits name=[I]"com.google.gwt.core.Core"[/I]/>
    <inherits name=[I]'com.cedarcone.Orchestrate.OrchestrateCommon'[/I] />
    <inherits name=[I]"com.smartgwtee.SmartGwtEENoScript"[/I] />
         <source path=[I]'test'[/I] />
         <entry-point class=[I]'com.cedarcone.Orchestrate.test.client.ExampleTest'[/I] />
    </module>
    Here is JUnit.html

    Code:
    <!doctype html>
    <!--
    Copyright 2008 Google Inc.
     
    Licensed under the Apache License, Version 2.0 (the "License"); you may not
    use this file except in compliance with the License. You may obtain a copy of
    the License at
     
    http://www.apache.org/licenses/LICENSE-2.0
     
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
    License for the specific language governing permissions and limitations under
    the License.
    -->
    <html>
    <head>
    <meta charset=[I]"utf-8"[/I]>
    <meta name=[I]'gwt:onLoadErrorFn'[/I] content=[I]'junitOnLoadErrorFn'[/I]>
    <meta name=[I]'gwt:onPropertyErrorFn'[/I] content=[I]'junitOnPropertyErrorFn'[/I]>
    </head>
    <body>
    <script>
    [B]function[/B] junitOnLoadErrorFn(moduleName, e) {
      junitLaunchError('Failed to load module ' + moduleName + ': ' + e);
    }
     
    [B]function[/B] junitOnPropertyErrorFn(propName, allowedValues, badValue) {
      [B]var[/B] msg = 'While attempting to load the module, property "' + propName;
      [B]if[/B] (badValue != [B]null[/B]) {
        msg += '" was set to the unexpected value "' + badValue + '"';
      } [B]else[/B] {
        msg += '" was not specified';
      }
      msg += 'Allowed values: ' + allowedValues;
      junitLaunchError(msg);
    }
     
    [B]function[/B] junitLaunchError(msg) {
      junitError("/launch", msg);
    }
     
    [B]function[/B] junitError(type, msg) {
      [B]var[/B] xmlHttpRequest = [B]new[/B] XMLHttpRequest();
      xmlHttpRequest.open('POST', 'junithost/error' + type, [B]true[/B]);
      xmlHttpRequest.setRequestHeader('Content-Type', 'text/x-gwt-rpc; charset=utf-8');
      xmlHttpRequest.send(msg);
      [B]if[/B] (window.console && window.console.log) {
        window.console.log(type + " error: " + msg);
      }
    }
     
    [B]function[/B] loadSelectionScript() {
      [B]var[/B] moduleName = location.pathname;
      [B]var[/B] pos = moduleName.lastIndexOf('/');
      moduleName = moduleName.substr(0, pos);
      pos = moduleName.lastIndexOf('/');
      moduleName = moduleName.substr(pos + 1);
      document.write('<script language="javascript" src="' + encodeURIComponent(moduleName) + '.nocache.js"><\/script>');
    }
    loadSelectionScript();
    </script>
    </body>
    </html>
    Here is the stack trace of the failure:

    Code:
    com.google.gwt.core.client.JavaScriptException: (TypeError) : Cannot read property "Dialog" from undefined
                    at com.smartgwt.client.util.I18nUtil.initMessages(I18nUtil.java:168)
                    at com.smartgwt.client.util.I18nUtil.init(I18nUtil.java:32)
                    at com.smartgwt.client.SmartGwtEntryPoint.$onModuleLoad(SmartGwtEntryPoint.java:431)
                    at com.cedarcone.Orchestrate.test.gwt.BasicGWTTest.testBasic(BasicGWTTest.java:20)
                    at Unknown.anonymous(GWTTestMetadataImpl.java:8)
                    at com.google.gwt.junit.client.impl.GWTTestAccessor.$invoke(GWTTestAccessor.java:35)
                    at com.google.gwt.junit.client.impl.GWTRunner.$executeTestMethod(GWTRunner.java:226)
                    at com.google.gwt.junit.client.GWTTestCase.$doRunTest(GWTTestCase.java:157)
                    at com.google.gwt.junit.client.GWTTestCase.$runBare(TestCase.java:59)
                    at com.google.gwt.junit.client.GWTTestCase.$__doRunTest(GWTTestCase.java:115)
                    at com.google.gwt.junit.client.impl.GWTRunner.$runTest(GWTRunner.java:302)
                    at com.google.gwt.junit.client.impl.GWTRunner.$doRunTest(GWTRunner.java:235)
                    at com.google.gwt.junit.client.impl.GWTRunner$TestBlockListener.$onSuccess(GWTRunner.java:106)
                    at com.google.gwt.junit.client.impl.GWTRunner$InitialResponseListener.$onSuccess(GWTRunner.java:61)
                    at com.google.gwt.junit.client.impl.GWTRunner$InitialResponseListener.onSuccess(GWTRunner.java:59)
                    at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.$onResponseReceived(RequestCallbackAdapter.java:232)
                    at com.google.gwt.http.client.Request.$fireOnResponseReceived(Request.java:250)
                    at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:412)
                    at Unknown.anonymous(XMLHttpRequest.java:329)
                    at com.google.gwt.core.client.impl.Impl.apply(Impl.java:239)
                    at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:298)
                    at Unknown.anonymous(Impl.java:77)
    Last edited by dbscott525; 13 Mar 2017, 12:19.

    #2
    The title of this would more accurately be "GWTTestCase and GWT 2.8 fails in new SmartGwtEntryPoint().onModuleLoad()"

    Comment


      #3
      You've specified the dependency <inherits name="com.smartgwtee.SmartGwtEENoScript" /> which means that your HTML is responsible for loading the SC JS Framework files, such as ISC_Core.js, before <module>.nocache.js, however we don't see where that's done in your HTML.

      Comment


        #4
        The GWTTestCase class that is used to write a test case automatically generates junit.html. So I don’t have access to the source of html where I would need to add loading of the SmartGWT scripts.

        Is there a way to have them loaded via an API or something?

        Comment


          #5
          When you said you were using the same setup with GWT 2.6.1 and it worked, was it exactly the same, including the
          Code:
          <inherits name="com.smartgwtee.SmartGwtEENoScript" />
          dependency?

          Comment


            #6
            When I inherit from “com.smartgwtee.SmartGwtEE”

            I get the following:

            Code:
            Mar 13, 2017 5:33:47 PM java.util.prefs.WindowsPreferences <init>
            WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
            log4j:WARN No appenders could be found for logger (org.eclipse.jetty.util.log).
            log4j:WARN Please initialize the log4j system properly.
            Compiling module com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit
               Ignored 420 units with compilation errors in first pass.
            Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
               Compiling 1 permutation
                  Compiling permutation 0...
               Compile of permutations succeeded
               Compilation succeeded -- 17.342s
            Linking into P:\Git\CedarCone\Orchestrate\www-test\com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit
               Invoking Linker Cross-Site-Iframe
                  Ignoring the following script tags in the gwt.xml file
            sc/initsc.js
            sc/modules/ISC_Core.js
            sc/modules/ISC_Foundation.js
            sc/modules/ISC_Containers.js
            sc/modules/ISC_Grids.js
            sc/modules/ISC_Forms.js
            sc/modules/ISC_RichTextEditor.js
            sc/modules/ISC_Calendar.js
            sc/modules/ISC_DataBinding.js
            sc/skins/Enterprise/load_skin.js
             
               Invoking Linker SmartGwtScriptInjector
                  Creating loadScriptTagFiles.js to manually load the following script tags:
            sc/initsc.js
            sc/modules/ISC_Core.js
            sc/modules/ISC_Foundation.js
            sc/modules/ISC_Containers.js
            sc/modules/ISC_Grids.js
            sc/modules/ISC_Forms.js
            sc/modules/ISC_RichTextEditor.js
            sc/modules/ISC_Calendar.js
            sc/modules/ISC_DataBinding.js
            sc/skins/Enterprise/load_skin.js
               Link succeeded
               Linking succeeded -- 17.382s
            Ignored 420 units with compilation errors in first pass.
            Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
            Starting http://localhost:49661/com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/junit.html on browser FF38
            200 - GET /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/junit.html (127.0.0.1)
            200 - GET /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit.nocache.js (127.0.0.1)
            200 - GET /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/518C773BD8AADE8E4C310DA19CB05BD7.cache.js (127.0.0.1)
            [WARN] 404 - GET /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/loadScriptTagFiles.js (127.0.0.1) 403 bytes
               Request headers
                  Host: localhost:49661
                  User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:38.0) Gecko/20100101 Firefox/38.0
                  Accept: */*
                  Accept-Language: en-US
                  Accept-Encoding: gzip, deflate
                  Referer: http://localhost:49661/com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/junit.html
                  Connection: keep-alive
               Response headers
                  Date: Tue, 14 Mar 2017 00:34:33 GMT
                  Content-Type: text/html; charset=ISO-8859-1
                  Cache-Control: must-revalidate,no-cache,no-store
                  Content-Length: 403
            logging for HtmlUnit thread
               [ERROR] Load Script Error: [U]java.io.IOException[/U]: Unable to download JavaScript from 'http://localhost:49661/com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/loadScriptTagFiles.js' (status 404).
            [U]java.io.IOException[/U]: Unable to download JavaScript from 'http://localhost:49661/com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/loadScriptTagFiles.js' (status 404).
                 at com.gargoylesoftware.htmlunit.html.HtmlPage.loadJavaScriptFromUrl([U]HtmlPage.java:1047[/U])
                 at com.gargoylesoftware.htmlunit.html.HtmlPage.loadExternalJavaScriptFile([U]HtmlPage.java:974[/U])
                 at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded([U]HtmlScript.java:399[/U])
                 at com.gargoylesoftware.htmlunit.html.HtmlScript$3.execute([U]HtmlScript.java:277[/U])
                 at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.doProcessPostponedActions([U]JavaScriptEngine.java:1002[/U])
                 at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.access$500([U]JavaScriptEngine.java:103[/U])
                 at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run([U]JavaScriptEngine.java:949[/U])
                 at net.sourceforge.htmlunit.corejs.javascript.Context.call([U]Context.java:628[/U])
                 at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call([U]ContextFactory.java:513[/U])
                 at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute([U]JavaScriptEngine.java:836[/U])
                 at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute([U]JavaScriptEngine.java:812[/U])
                 at com.gargoylesoftware.htmlunit.html.HtmlPage.loadExternalJavaScriptFile([U]HtmlPage.java:997[/U])
                 at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded([U]HtmlScript.java:399[/U])
                 at com.gargoylesoftware.htmlunit.html.HtmlScript$3.execute([U]HtmlScript.java:277[/U])
                 at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.doProcessPostponedActions([U]JavaScriptEngine.java:1002[/U])
                 at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.access$500([U]JavaScriptEngine.java:103[/U])
                 at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run([U]JavaScriptEngine.java:949[/U])
                 at net.sourceforge.htmlunit.corejs.javascript.Context.call([U]Context.java:628[/U])
                 at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call([U]ContextFactory.java:513[/U])
                 at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute([U]JavaScriptEngine.java:836[/U])
                 at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute([U]JavaScriptEngine.java:812[/U])
                 at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute([U]JavaScriptEngine.java:800[/U])
                 at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible([U]HtmlPage.java:910[/U])
                 at com.gargoylesoftware.htmlunit.html.HtmlScript.executeInlineScriptIfNeeded([U]HtmlScript.java:354[/U])
                 at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded([U]HtmlScript.java:415[/U])
                 at com.gargoylesoftware.htmlunit.html.HtmlScript$3.execute([U]HtmlScript.java:277[/U])
                 at com.gargoylesoftware.htmlunit.html.HtmlScript.onAllChildrenAddedToPage([U]HtmlScript.java:293[/U])
                 at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement([U]HTMLParser.java:799[/U])
                 at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
                 at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement([U]HTMLParser.java:756[/U])
                 at org.cyberneko.html.HTMLTagBalancer.callEndElement([U]HTMLTagBalancer.java:1170[/U])
                 at org.cyberneko.html.HTMLTagBalancer.endElement([U]HTMLTagBalancer.java:1072[/U])
                 at org.cyberneko.html.filters.DefaultFilter.endElement([U]DefaultFilter.java:206[/U])
                 at org.cyberneko.html.filters.NamespaceBinder.endElement([U]NamespaceBinder.java:330[/U])
                 at org.cyberneko.html.HTMLScanner$ContentScanner.scanEndElement([U]HTMLScanner.java:3126[/U])
                 at org.cyberneko.html.HTMLScanner$ContentScanner.scan([U]HTMLScanner.java:2093[/U])
                 at org.cyberneko.html.HTMLScanner.scanDocument([U]HTMLScanner.java:920[/U])
                 at org.cyberneko.html.HTMLConfiguration.parse([U]HTMLConfiguration.java:499[/U])
                 at org.cyberneko.html.HTMLConfiguration.parse([U]HTMLConfiguration.java:452[/U])
                 at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
                 at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse([U]HTMLParser.java:1039[/U])
                 at com.gargoylesoftware.htmlunit.html.HTMLParser.parse([U]HTMLParser.java:252[/U])
                 at com.gargoylesoftware.htmlunit.html.HTMLParser.parseHtml([U]HTMLParser.java:198[/U])
                 at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage([U]DefaultPageCreator.java:271[/U])
                 at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage([U]DefaultPageCreator.java:159[/U])
                 at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto([U]WebClient.java:478[/U])
                 at com.gargoylesoftware.htmlunit.WebClient.getPage([U]WebClient.java:352[/U])
                 at com.gargoylesoftware.htmlunit.WebClient.getPage([U]WebClient.java:417[/U])
                 at com.gargoylesoftware.htmlunit.WebClient.getPage([U]WebClient.java:402[/U])
                 at com.google.gwt.junit.RunStyleHtmlUnit$HtmlUnitThread.run([U]RunStyleHtmlUnit.java:141[/U])
            200 - GET /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/gwt/standard/standard.css (127.0.0.1)
            200 - POST /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/junithost (127.0.0.1) 219 bytes
            It looks as though the URL for loading loadScriptTagFiles is incorrectly specified because com.cedarcone.Orchestrate.OrchestrateJUnit.Junit is in the path twice.

            Because of this I switched to com.smartgwtee.SmartGwtEENoScript as advised. This resulted in the Cannot read property "Dialog" from undefined error

            Code:
            com.google.gwt.core.client.JavaScriptException: (TypeError) : Cannot read property "Dialog" from undefined
                            at com.smartgwt.client.util.I18nUtil.initMessages(I18nUtil.java:168)
                            at com.smartgwt.client.util.I18nUtil.init(I18nUtil.java:32)
                            at com.smartgwt.client.SmartGwtEntryPoint.$onModuleLoad(SmartGwtEntryPoint.java:431)
                            at com.cedarcone.Orchestrate.test.gwt.BasicGWTTest.testBasic(BasicGWTTest.java:38)
                            at Unknown.anonymous(GWTTestMetadataImpl.java:8)
                            at com.google.gwt.junit.client.impl.GWTTestAccessor.$invoke(GWTTestAccessor.java:35)
                            at com.google.gwt.junit.client.impl.GWTRunner.$executeTestMethod(GWTRunner.java:226)
                            at com.google.gwt.junit.client.GWTTestCase.$doRunTest(GWTTestCase.java:157)
                            at com.google.gwt.junit.client.GWTTestCase.$runBare(TestCase.java:59)
                            at com.google.gwt.junit.client.GWTTestCase.$__doRunTest(GWTTestCase.java:115)
                            at com.google.gwt.junit.client.impl.GWTRunner.$runTest(GWTRunner.java:302)
                            at com.google.gwt.junit.client.impl.GWTRunner.$doRunTest(GWTRunner.java:235)
                            at com.google.gwt.junit.client.impl.GWTRunner$TestBlockListener.$onSuccess(GWTRunner.java:106)
                            at com.google.gwt.junit.client.impl.GWTRunner$InitialResponseListener.$onSuccess(GWTRunner.java:61)
                            at com.google.gwt.junit.client.impl.GWTRunner$InitialResponseListener.onSuccess(GWTRunner.java:59)
                            at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.$onResponseReceived(RequestCallbackAdapter.java:232)
                            at com.google.gwt.http.client.Request.$fireOnResponseReceived(Request.java:250)
                            at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:412)
                            at Unknown.anonymous(XMLHttpRequest.java:329)
                            at com.google.gwt.core.client.impl.Impl.apply(Impl.java:239)
                            at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:298)
                            at Unknown.anonymous(Impl.java:77)
            Isomorphic’s response to this is that I needed to explicitly load the scripts in my HTML file. Because this is generated by the GWTTestCase framework I could not do that.

            Now I am loading the scripts via the GWT ScriptInjector API. Here is my test program that programmatically loads the Isomorphic scripts.

            Code:
            [B]public[/B] [B]class[/B] BasicGWTTest [B]extends[/B] GWTTestCase {
             
                [B]private[/B] [B]static[/B] [B]final[/B] [B]boolean[/B] [B][I]NO_SCRIPT[/I][/B]         = [B]true[/B];
             
                [B]public[/B] [B]void[/B] testBasic() [B]throws[/B] Exception {
                    [B]if[/B] ([B][I]NO_SCRIPT[/I][/B]) {
                        Iterator<String> iterator = Arrays.[I]asList[/I]("Core", "Foundation", "Containers", "Grids", "Forms", "RichTextEditor", "Calendar",
                                "DataBinding")
                                                          .iterator();
                        loadNextScript(iterator);
                    } [B]else[/B] {
                        [B]new[/B] SmartGwtEntryPoint().onModuleLoad();
                    }
                }
             
                [B]private[/B] [B]void[/B] loadNextScript(Iterator<String> iterator) {
             
                    [B]if[/B] (!iterator.hasNext()) {
                        log("BEFORE new SmartGwtEntryPoint().onModuleLoad();");
                        [B]new[/B] SmartGwtEntryPoint().onModuleLoad();
                        log("AFTER new SmartGwtEntryPoint().onModuleLoad();");
                        [B]return[/B];
                    }
             
                    ScriptInjector.[I]fromUrl[/I]("sc/modules/ISC_" + iterator.next() + ".js")
                                  .setCallback([B]new[/B] Callback<Void, Exception>() {
             
                                      @Override
                                      [B]public[/B] [B]void[/B] onFailure(Exception e) {
                                          log("Script load failed: " + e);
                                      }
             
                                      @Override
                                      [B]public[/B] [B]void[/B] onSuccess(Void arg0) {
                                          loadNextScript(iterator);
                                      }
                                  })
                                  .inject();
                }
             
                [B]private[/B] [B]void[/B] log(String msg) {
                    Logger.[I]getLogger[/I]("MyLogger")
                          .log(Level.[B][I]SEVERE[/I][/B], msg);
                }
             
                @Override
                [B]public[/B] String getModuleName() {
                    [B]return[/B] "com.cedarcone.Orchestrate.OrchestrateJUnit";
                }
             
            }
            Here are the log results:

            Code:
            Mar 13, 2017 6:29:13 PM java.util.prefs.WindowsPreferences <init>
            WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
            log4j:WARN No appenders could be found for logger (org.eclipse.jetty.util.log).
            log4j:WARN Please initialize the log4j system properly.
            Compiling module com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit
               Ignored 420 units with compilation errors in first pass.
            Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
               Compiling 1 permutation
                  Compiling permutation 0...
               Compile of permutations succeeded
               Compilation succeeded -- 19.384s
            Linking into P:\Git\CedarCone\Orchestrate\www-test\com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit
               Link succeeded
               Linking succeeded -- 21.067s
            Ignored 420 units with compilation errors in first pass.
            Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
            Starting http://localhost:50508/com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/junit.html on browser FF38
            200 - GET /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/junit.html (127.0.0.1)
            200 - GET /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit.nocache.js (127.0.0.1)
            200 - GET /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/F15EDC9561305959F6AA0F8373CC9D64.cache.js (127.0.0.1)
            200 - GET /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/gwt/standard/standard.css (127.0.0.1)
            200 - POST /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/junithost (127.0.0.1) 219 bytes
            200 - GET /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/sc/modules/ISC_Core.js (127.0.0.1)
            200 - GET /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/sc/modules/ISC_Foundation.js (127.0.0.1)
            200 - GET /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/sc/modules/ISC_Containers.js (127.0.0.1)
            200 - GET /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/sc/modules/ISC_Grids.js (127.0.0.1)
            200 - GET /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/sc/modules/ISC_Forms.js (127.0.0.1)
            200 - GET /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/sc/modules/ISC_RichTextEditor.js (127.0.0.1)
            200 - GET /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/sc/modules/ISC_Calendar.js (127.0.0.1)
            200 - GET /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/sc/modules/ISC_DataBinding.js (127.0.0.1)
            RHINO USAGE WARNING: Missed Context.javaToJS() conversion:
            Rhino runtime detected object [U]com.gargoylesoftware.htmlunit.ScriptException[/U]: TypeError: Cannot read property "Dialog" from undefined (script in javascript:"" from (-1, -1) to (-1, -1)#39) of class [U]com.gargoylesoftware.htmlunit.ScriptException[/U] where it expected String, Number, Boolean or Scriptable instance. Please check your code for missing Context.javaToJS() call.
            Mar 13, 2017 6:30:11 PM com.google.gwt.junit.server.JUnitHostImpl logOnServer
            SEVERE: <BROWSER> BEFORE new RHINO USAGE WARNING: Missed Context.javaToJS() conversion
            200 - POST /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/remote_logging (127.0.0.1) 14 bytes
            There are two problems with this result:
            • The "RHINO USAGE WARNING": Missed Context.javaToJS() conversion” error. This doesn't cause the JUnit test to fail.
            • Control appears to never be returned from the call to SmartGwtEntryPoint().onModuleLoad();. In the code there is a log message before and after that call. Only the before log message appears in the log.
            Last edited by dbscott525; 13 Mar 2017, 17:42.

            Comment


              #7
              That advice wasn't given in this thread. When moving to GWT 2.7+, it may be advisable, in general, to switch to manual script loading, switching dependencies from SmartGwtEE to SmartGwtEENoScript, but that relies on being able to modify the HTML page. Our HTML performs a number of functions - setting variables and loading scripts other than just the <module>.nocache.js. With JUnit, that doesn't appear to be possible as JUnit is forcing you to run their HTML.

              In fact, we faced an almost identical situation earlier, from another customer, in this thread. We actually added a feature to the BuiltInDS Sample GWT Module file to allow the script loading path to be customized. You haven't specified what version of SGWT you're using, but you should find the following code at the bottom of your BuiltInDS.gwt.xml sample project:

              Code:
                  <!-- Uncomment the lines below in GWT 2.7+ to enable configuring of the path of the module
                       relative to the main HTML page.  By default for our sample projects, the main page is
                       directly in the root (war) directory above the module directory, so the relative
                       path is just the module (directory) name.
              
                       The syntax is <moduleName>=<relative path> as the example binding below illustrates.
                       Multiple bindings can be added to support multiple modules inheriting this module file.
                  -->
                  <!-- <define-configuration-property name="scriptInjector.pageRelativeModulePath"
                                                      is-multi-valued="true"/> -->
                  <!-- <extend-configuration-property name="scriptInjector.pageRelativeModulePath"
                                                      value="builtinds=builtinds"/> -->
              To avoid the "double path" problem, you'd replace "builtinds=builtinds" with "builtinds=." where you'd use your module name, which I believe is com.cedarcone.Orchestrate.OrchestrateJUnit, instead of builtinds. If you do it right, you should see something like this in the linker output:

              Code:
                 Invoking Linker SmartGwtScriptInjector
                    Setting page-relative module path for module 'com.smartgwt.sample.BuiltInDS.JUnit' using gwt.xml config
              What we find in our own testing with GWTTestCase is that the linker generates a valid loadScriptTagFile.js each time the test case is run, and it's being loaded by the <module>.nocache.js file. So from that perspective, it actually works better than running an app as a Web Application through the GWT Plugin, where the <module>.nocache.js file is not annotated as expected even though our custom linker runs. However, you still have a problem that bits of your original base HTML page are not present in the JUnit HTML, and those are critical to set variables, load a skin, and load DataSources.

              To solve that, you can move any such code into a hand-crafted JS file, extra.js, and then declare it manually in your module definition. So for example, at the top of you module, you can configure it like:

              Code:
                  <inherits name='com.google.gwt.user.User'/>
                  <inherits name="com.smartgwt.tools.SmartGwtTools"/>
                  <inherits name="com.smartgwtee.tools.Tools"/>
                  <inherits name="com.smartgwtee.SmartGwtEE"/>
                  <script src="extra.js"/>
              You'll need to manually copy the extra.js down into your JUnit module directory, or use "../extra.js" and place it in the directory above if your web server allows that. Let us know how far you are able to progress with the above information.
              Last edited by Isomorphic; 14 Mar 2017, 03:07.

              Comment


                #8
                We've updated the previous summary above of how to work around the JUnit limitations.

                Comment


                  #9
                  Thank you for your response.

                  By implementing your suggestions I was able to successfully run one of our 30 tests.

                  Originally posted by Isomorphic View Post
                  To avoid the "double path" problem, you'd replace "builtinds=builtinds" with "builtinds=." where you'd use your module name, which I believe is com.cedarcone.Orchestrate.OrchestrateJUnit, instead of builtinds
                  Through some trial and error my final gwt.xml file is

                  Code:
                  <?xml version=[I]"1.0"[/I] encoding=[I]"UTF-8"[/I]?>
                  <module>
                       <inherits name=[I]"com.google.gwt.core.Core"[/I] />
                       <inherits name=[I]"com.google.gwt.logging.Logging"[/I] />
                       <inherits name=[I]"com.google.gwt.user.User"[/I] />
                       <inherits name=[I]"com.smartgwt.tools.SmartGwtTools"[/I] />
                       <inherits name=[I]"com.smartgwtee.SmartGwtEE"[/I] />
                       <!-- <inherits name="com.smartgwtee.SmartGwtEENoScript" /> -->
                       <inherits name=[I]"com.smartgwtee.tools.Tools"[/I] />
                       <inherits name=[I]'com.cedarcone.Orchestrate.OrchestrateCommon'[/I] />
                   
                       <source path=[I]'test'[/I] />
                       <entry-point class=[I]'com.cedarcone.Orchestrate.test.client.ExampleTest'[/I] />
                   
                       <define-configuration-property name=[I]"scriptInjector.pageRelativeModulePath"[/I] is-multi-valued=[I]"true"[/I] />
                       <extend-configuration-property name=[I]"scriptInjector.pageRelativeModulePath"[/I] value=[I]"com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit=."[/I] />
                  </module>
                  This resulted in this log file:

                  Code:
                  Mar 14, 2017 6:07:47 PM java.util.prefs.WindowsPreferences <init>
                  WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
                  log4j:WARN No appenders could be found for logger (org.eclipse.jetty.util.log).
                  log4j:WARN Please initialize the log4j system properly.
                  Compiling module com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit
                     Ignored 420 units with compilation errors in first pass.
                  Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
                     Compiling 1 permutation
                        Compiling permutation 0...
                     Compile of permutations succeeded
                     Compilation succeeded -- 34.735s
                  Linking into P:\Git\CedarCone\Orchestrate\www-test\com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit
                     Invoking Linker Cross-Site-Iframe
                        Ignoring the following script tags in the gwt.xml file
                  sc/initsc.js
                  sc/modules/ISC_Core.js
                  sc/modules/ISC_Foundation.js
                  sc/modules/ISC_Containers.js
                  sc/modules/ISC_Grids.js
                  sc/modules/ISC_Forms.js
                  sc/modules/ISC_RichTextEditor.js
                  sc/modules/ISC_Calendar.js
                  sc/modules/ISC_DataBinding.js
                  sc/skins/Enterprise/load_skin.js
                   
                     Invoking Linker SmartGwtScriptInjector
                        Setting page-relative module path for module 'com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit' using gwt.xml config
                        Creating loadScriptTagFiles.js to manually load the following script tags:
                  sc/initsc.js
                  sc/modules/ISC_Core.js
                  sc/modules/ISC_Foundation.js
                  sc/modules/ISC_Containers.js
                  sc/modules/ISC_Grids.js
                  sc/modules/ISC_Forms.js
                  sc/modules/ISC_RichTextEditor.js
                  sc/modules/ISC_Calendar.js
                  sc/modules/ISC_DataBinding.js
                  sc/skins/Enterprise/load_skin.js
                     Link succeeded
                     Linking succeeded -- 16.422s
                  Ignored 420 units with compilation errors in first pass.
                  Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
                  Starting http://localhost:54108/com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/junit.html on browser FF38
                  200 - GET /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/junit.html (127.0.0.1)
                  200 - GET /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit.nocache.js (127.0.0.1)
                  200 - GET /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/C5A50482FE3F11D0DA89DCB85521C778.cache.js (127.0.0.1)
                  200 - GET /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/loadScriptTagFiles.js (127.0.0.1)
                  200 - GET /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/sc/initsc.js (127.0.0.1)
                  200 - GET /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/sc/modules/ISC_Core.js (127.0.0.1)
                  200 - GET /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/sc/modules/ISC_Foundation.js (127.0.0.1)
                  200 - GET /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/sc/modules/ISC_Containers.js (127.0.0.1)
                  200 - GET /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/gwt/standard/standard.css (127.0.0.1)
                  200 - GET /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/sc/modules/ISC_Grids.js (127.0.0.1)
                  200 - GET /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/sc/modules/ISC_Forms.js (127.0.0.1)
                  200 - GET /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/sc/modules/ISC_RichTextEditor.js (127.0.0.1)
                  200 - GET /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/sc/modules/ISC_Calendar.js (127.0.0.1)
                  200 - GET /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/sc/modules/ISC_DataBinding.js (127.0.0.1)
                  200 - GET /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/sc/skins/Enterprise/load_skin.js (127.0.0.1)
                  200 - GET /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/sc/skins/Enterprise/skin_styles.css (127.0.0.1)
                  200 - POST /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/junithost (127.0.0.1) 228 bytes
                  Mar 14, 2017 6:08:52 PM com.google.gwt.junit.server.JUnitHostImpl logOnServer
                  SEVERE: <BROWSER> TEST STARTED: com.cedarcone.Orchestrate.test.gwt.AnswerCompatibilityTest
                  200 - POST /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/remote_logging (127.0.0.1) 14 bytes
                  Mar 14, 2017 6:08:54 PM com.google.gwt.junit.server.JUnitHostImpl logOnServer
                  SEVERE: <BROWSER> TEST COMPLETE: com.cedarcone.Orchestrate.test.gwt.AnswerCompatibilityTest
                  200 - POST /com.cedarcone.Orchestrate.OrchestrateJUnit.JUnit/remote_logging (127.0.0.1) 14 bytes
                  Originally posted by Isomorphic View Post
                  We actually added a feature to the BuiltInDS Sample GWT Module file to allow the script loading path to be customized. You haven't specified what version of SGWT you're using, but you should find the following code at the bottom of your BuiltInDS.gwt.xml sample project:
                  We are using SmartGWT 5.1-p20170201. We get this version through the utility that downloads the jar files to our Maven repository. When this is done, BuiltInDS.gwt.xml is not included. Where can I find BuiltInDS.gwt.xml along with sample application that goes with it? I Googled this and only found something on GitHub which does not contain the lines you have shown.

                  Currently to log/print information I’m using this code:

                  Code:
                      [B]protected[/B] [B]void[/B] log(String line) {
                          [B]if[/B] (logger == [B]null[/B]) {
                              logger = Logger.[I]getLogger[/I]("GWT Unit Test");
                          }
                          logger.severe(line);
                      }
                  The log results look like this:

                  Code:
                  Mar 14, 2017 6:08:52 PM com.google.gwt.junit.server.JUnitHostImpl logOnServer
                  SEVERE: <BROWSER> TEST STARTED: com.cedarcone.Orchestrate.test.gwt.AnswerCompatibilityTest
                  Can you suggest an alternative to logging/printing that would look a little more friendlier?

                  Originally posted by Isomorphic View Post
                  To solve that, you can move any such code into a hand-crafted JS file, extra.js, and then declare it manually in your module definition. So for example, at the top of you module, you can configure it like:
                  What would be the content of extra.js?
                  Last edited by dbscott525; 14 Mar 2017, 17:23.

                  Comment


                    #10
                    Originally posted by dbscott525 View Post
                    We are using SmartGWT 5.1-p20170201. We get this version through the utility that downloads the jar files to our Maven repository. When this is done, BuiltInDS.gwt.xml is not included. Where can I find BuiltInDS.gwt.xml along with sample application that goes with it? I Googled this and only found something on GitHub which does not contain the lines you have shown.
                    That module file is part of our BuiltInDS sample, which is included in SGWT EE (but not SGWT LGPL). You can download the latest SGWT 5.1p here. Just select the link you want based on date, and then click on smartgwtee-eval-5.1p.zip.

                    Originally posted by dbscott525 View Post
                    Currently to log/print information I’m using this code:

                    Code:
                    [B]protected[/B] [B]void[/B] log(String line) {
                    [B]if[/B] (logger == [B]null[/B]) {
                    logger = Logger.[I]getLogger[/I]("GWT Unit Test");
                    }
                    logger.severe(line);
                    }
                    The log results look like this:

                    Code:
                    Mar 14, 2017 6:08:52 PM com.google.gwt.junit.server.JUnitHostImpl logOnServer
                    SEVERE: <BROWSER> TEST STARTED: com.cedarcone.Orchestrate.test.gwt.AnswerCompatibilityTest
                    Can you suggest an alternative to logging/printing that would look a little more friendlier?
                    You should use the logging APIs in the SC class - that will send the logs in a manner consistent with logs from the SmartClient JS Framework and subject to your log4j config. (There's an SC.logInfo() in addition to SC.logWarn(), etc.)

                    Originally posted by dbscott525 View Post
                    What would be the content of extra.js?
                    If you're not having any residual issues after the initial suggested fix, then don't worry. Our BuiltInDS HTML does more than load the <module>.nocache.js - it also sets the isomorphicDir global variable and loads DataSources. That won't happen with the JUnit HTML, so I was suggesting a mechanism for running extra content like that if you were still facing a problem.

                    Comment

                    Working...
                    X