About running tests in a project built via tbroyer's maven multi-module archetype

294 views
Skip to first unread message

vitrums

unread,
Dec 1, 2016, 2:15:45 PM12/1/16
to GWT Users
Multi-module project structure with the magic of gwt-maven-plugin is great and I've managed to get it working with multiple client modules packaged as gwt-lib, and one main client module packaged as gwt-app (to develop and debug them), which has these modules as dependencies.  Also I managed to configure the project to use maven-deploy-plugin and site-maven-plugin to automatically deploy maven artifacts to my remote poor man's maven repository on github (automatically pushes jars + metadata to master of a devoted repo "mvn-repo"), and to use this repository within other maven projects to automatically grab the latest snapshots.

It feels, that there's only one final step is missing to get everything working the way it should - to have my testing phase running some GWTTestCase's. But running mvn test fails. (here sandbox-client is packaged as gwt-app and dependent on 1) vit-gin-client packaged as gwt-lib and 2) sandbox-shared with default packaging)

mvn test:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] sandbox
[INFO] sandbox-shared
[INFO] vit-gin-client
[INFO] sandbox-client
[INFO] sandbox-server
[INFO]                                                                        
[INFO] ------------------------------------------------------------------------
[INFO] Building sandbox 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]                                                                        
[INFO] ------------------------------------------------------------------------
[INFO] Building sandbox-shared 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ sandbox-shared ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory E:\Users\vitrums\workspace-neon\sandbox\sandbox-shared\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ sandbox-shared ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ sandbox-shared ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory E:\Users\vitrums\workspace-neon\sandbox\sandbox-shared\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ sandbox-shared ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ sandbox-shared ---
[INFO] No tests to run.
[INFO]                                                                        
[INFO] ------------------------------------------------------------------------
[INFO] Building vit-gin-client 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- gwt-maven-plugin:1.0-rc-6:enforce-encoding (default-enforce-encoding) @ vit-gin-client ---
[INFO]
[INFO] --- gwt-maven-plugin:1.0-rc-6:add-super-sources (default-add-super-sources) @ vit-gin-client ---
[INFO]
[INFO] --- gwt-maven-plugin:1.0-rc-6:add-test-super-sources (default-add-test-super-sources) @ vit-gin-client ---
[INFO]
[INFO] --- gwt-maven-plugin:1.0-rc-6:import-sources (default-import-sources) @ vit-gin-client ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- gwt-maven-plugin:1.0-rc-6:generate-module (default-generate-module) @ vit-gin-client ---
[INFO] E:\Users\vitrums\workspace-neon\sandbox\vit-gin-client\target\classes\com\mycompany\gin\VitGin.gwt.xml up to date - skipping
[INFO]
[INFO] --- gwt-maven-plugin:1.0-rc-6:generate-module-metadata (default-generate-module-metadata) @ vit-gin-client ---
[INFO] E:\Users\vitrums\workspace-neon\sandbox\vit-gin-client\target\classes\META-INF\gwt\mainModule up to date - skipping.
[INFO]
[INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ vit-gin-client ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory E:\Users\vitrums\workspace-neon\sandbox\vit-gin-client\src\main\resources
[INFO] skip non existing resourceDirectory E:\Users\vitrums\workspace-neon\sandbox\vit-gin-client\src\main\super
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ vit-gin-client ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- gwt-maven-plugin:1.0-rc-6:import-test-sources (default-import-test-sources) @ vit-gin-client ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory E:\Users\vitrums\workspace-neon\sandbox\vit-gin-client\src\test\java
[INFO]
[INFO] --- maven-resources-plugin:3.0.1:testResources (default-testResources) @ vit-gin-client ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory E:\Users\vitrums\workspace-neon\sandbox\vit-gin-client\src\test\resources
[INFO] skip non existing resourceDirectory E:\Users\vitrums\workspace-neon\sandbox\vit-gin-client\src\test\super
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ vit-gin-client ---
[INFO] No sources to compile
[INFO]
[INFO] --- gwt-maven-plugin:1.0-rc-6:test (default-test) @ vit-gin-client ---
[INFO] No tests to run.
[INFO]                                                                        
[INFO] ------------------------------------------------------------------------
[INFO] Building sandbox-client 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- gwt-maven-plugin:1.0-rc-6:enforce-encoding (default-enforce-encoding) @ sandbox-client ---
[INFO]
[INFO] --- gwt-maven-plugin:1.0-rc-6:add-super-sources (default-add-super-sources) @ sandbox-client ---
[INFO]
[INFO] --- gwt-maven-plugin:1.0-rc-6:add-test-super-sources (default-add-test-super-sources) @ sandbox-client ---
[INFO]
[INFO] --- gwt-maven-plugin:1.0-rc-6:generate-module (default-generate-module) @ sandbox-client ---
[INFO] E:\Users\vitrums\workspace-neon\sandbox\sandbox-client\target\classes\com\mycompany\App.gwt.xml up to date - skipping
[INFO]
[INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ sandbox-client ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory E:\Users\vitrums\workspace-neon\sandbox\sandbox-client\src\main\resources
[INFO] skip non existing resourceDirectory E:\Users\vitrums\workspace-neon\sandbox\sandbox-client\src\main\super
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ sandbox-client ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- gwt-maven-plugin:1.0-rc-6:import-sources (default-import-sources) @ sandbox-client ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-resources-plugin:3.0.1:testResources (default-testResources) @ sandbox-client ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory E:\Users\vitrums\workspace-neon\sandbox\sandbox-client\src\test\resources
[INFO] skip non existing resourceDirectory E:\Users\vitrums\workspace-neon\sandbox\sandbox-client\src\test\super
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ sandbox-client ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- gwt-maven-plugin:1.0-rc-6:import-test-sources (default-import-test-sources) @ sandbox-client ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO]
[INFO] --- gwt-maven-plugin:1.0-rc-6:test (default-test) @ sandbox-client ---
[INFO] GWT tests report directory: E:\Users\vitrums\workspace-neon\sandbox\sandbox-client\target\surefire-reports


-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.mycompany.AppSuite
Starting Jetty on port 0
   
[WARN] ServletContainerInitializers: detected. Class hierarchy: empty
[WARN] Failed to load servlet class 'com.mycompany.GreetingServiceImpl' declared in 'com.mycompany.AppJUnit.JUnit'
java
.lang.ClassNotFoundException: com.mycompany.GreetingServiceImpl
 at java
.net.URLClassLoader.findClass(URLClassLoader.java:381)
 at org
.eclipse.jetty.webapp.WebAppClassLoader.findClass(WebAppClassLoader.java:510)
 at org
.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:441)
 at org
.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:403)
 at org
.eclipse.jetty.server.handler.ContextHandler.loadClass(ContextHandler.java:1583)
 at com
.google.gwt.junit.JUnitShell.maybeCompileForWebMode(JUnitShell.java:1119)
 at com
.google.gwt.junit.CompileStrategy.maybeCompileModuleImpl2(CompileStrategy.java:183)
 at com
.google.gwt.junit.CompileStrategy.maybeCompileModuleImpl(CompileStrategy.java:113)
 at com
.google.gwt.junit.SimpleCompileStrategy.maybeCompileModule(SimpleCompileStrategy.java:36)
 at com
.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1313)
 at com
.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1281)
 at com
.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:670)
 at com
.google.gwt.junit.client.GWTTestCase.runTest(GWTTestCase.java:421)
 at junit
.framework.TestCase.runBare(TestCase.java:141)
 at junit
.framework.TestResult$1.protect(TestResult.java:122)
 at junit
.framework.TestResult.runProtected(TestResult.java:142)
 at junit
.framework.TestResult.run(TestResult.java:125)
 at junit
.framework.TestCase.run(TestCase.java:129)
 at com
.google.gwt.junit.client.GWTTestCase.run(GWTTestCase.java:247)
 at junit
.framework.TestSuite.runTest(TestSuite.java:255)
 at junit
.framework.TestSuite.run(TestSuite.java:250)
 at junit
.framework.TestSuite.runTest(TestSuite.java:255)
 at junit
.framework.TestSuite.run(TestSuite.java:250)
 at org
.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
 at org
.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:264)
 at org
.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
 at org
.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
 at org
.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
 at org
.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
 at org
.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
Compiling module com.mycompany.AppJUnit.JUnit
   
Ignored 3 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 -- 6,418s
Linking into E:\Users\vitrums\workspace-neon\sandbox\sandbox-client\target\gwt-tests\www\com.mycompany.AppJUnit.JUnit
   
Link succeeded
   
Linking succeeded -- 0,313s
Ignored 3 units with compilation errors in first pass.
Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
Tracing compile failure path for type 'com.mycompany.client.AppTest'
   
[ERROR] Errors in 'file:/E:/Users/vitrums/workspace-neon/sandbox/sandbox-client/target/test-classes/com/mycompany/client/AppTest.java'
     
[ERROR] Line 28: No source code is available for type com.mycompany.shared.FieldVerifier; did you forget to inherit a required module?
     
[ERROR] Line 42: No source code is available for type com.mycompany.shared.GreetingServiceAsync; did you forget to inherit a required module?
     
[ERROR] Line 52: No source code is available for type com.mycompany.shared.GreetingResponse; did you forget to inherit a required module?
     
[ERROR] Line 42: No source code is available for type com.mycompany.shared.GreetingService; did you forget to inherit a required module?
[ERROR] Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly
Tracing compile failure path for type 'com.mycompany.client.AppTest'
   
[ERROR] Errors in 'file:/E:/Users/vitrums/workspace-neon/sandbox/sandbox-client/target/test-classes/com/mycompany/client/AppTest.java'
     
[ERROR] Line 28: No source code is available for type com.mycompany.shared.FieldVerifier; did you forget to inherit a required module?
     
[ERROR] Line 42: No source code is available for type com.mycompany.shared.GreetingServiceAsync; did you forget to inherit a required module?
     
[ERROR] Line 52: No source code is available for type com.mycompany.shared.GreetingResponse; did you forget to inherit a required module?
     
[ERROR] Line 42: No source code is available for type com.mycompany.shared.GreetingService; did you forget to inherit a required module?
[ERROR] Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly
Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 9.727 sec <<< FAILURE! - in com.mycompany.AppSuite
testGreetingService
(com.mycompany.client.AppTest)  Time elapsed: 9.679 sec  <<< ERROR!
com
.google.gwt.junit.JUnitFatalLaunchException: The test class 'com.mycompany.client.AppTest' had compile errors; check log for details
 at com
.google.gwt.junit.JUnitShell.checkTestClassInCurrentModule(JUnitShell.java:732)
 at com
.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1325)
 at com
.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1281)
 at com
.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:670)
 at com
.google.gwt.junit.client.GWTTestCase.runTest(GWTTestCase.java:421)
 at junit
.framework.TestCase.runBare(TestCase.java:141)
 at junit
.framework.TestResult$1.protect(TestResult.java:122)
 at junit
.framework.TestResult.runProtected(TestResult.java:142)
 at junit
.framework.TestResult.run(TestResult.java:125)
 at junit
.framework.TestCase.run(TestCase.java:129)
 at com
.google.gwt.junit.client.GWTTestCase.run(GWTTestCase.java:247)
 at junit
.framework.TestSuite.runTest(TestSuite.java:255)
 at junit
.framework.TestSuite.run(TestSuite.java:250)
 at junit
.framework.TestSuite.runTest(TestSuite.java:255)
 at junit
.framework.TestSuite.run(TestSuite.java:250)
 at org
.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
 at org
.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:264)
 at org
.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
 at org
.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
 at org
.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
 at org
.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
 at org
.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)


testFieldVerifier
(com.mycompany.client.AppTest)  Time elapsed: 0.002 sec  <<< ERROR!
com
.google.gwt.junit.JUnitFatalLaunchException: The test class 'com.mycompany.client.AppTest' had compile errors; check log for details
 at com
.google.gwt.junit.JUnitShell.checkTestClassInCurrentModule(JUnitShell.java:732)
 at com
.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1325)
 at com
.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1281)
 at com
.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:670)
 at com
.google.gwt.junit.client.GWTTestCase.runTest(GWTTestCase.java:421)
 at junit
.framework.TestCase.runBare(TestCase.java:141)
 at junit
.framework.TestResult$1.protect(TestResult.java:122)
 at junit
.framework.TestResult.runProtected(TestResult.java:142)
 at junit
.framework.TestResult.run(TestResult.java:125)
 at junit
.framework.TestCase.run(TestCase.java:129)
 at com
.google.gwt.junit.client.GWTTestCase.run(GWTTestCase.java:247)
 at junit
.framework.TestSuite.runTest(TestSuite.java:255)
 at junit
.framework.TestSuite.run(TestSuite.java:250)
 at junit
.framework.TestSuite.runTest(TestSuite.java:255)
 at junit
.framework.TestSuite.run(TestSuite.java:250)
 at org
.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
 at org
.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:264)
 at org
.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
 at org
.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
 at org
.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
 at org
.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
 at org
.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)




Results :


Tests in error:
 
AppTest>GWTTestCase.run:247->GWTTestCase.runTest:421 » JUnitFatalLaunch The te...
 
AppTest>GWTTestCase.run:247->GWTTestCase.runTest:421 » JUnitFatalLaunch The te...


Tests run: 2, Failures: 0, Errors: 2, Skipped: 0


[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] sandbox ............................................ SUCCESS [  0.005 s]
[INFO] sandbox-shared ..................................... SUCCESS [  0.978 s]
[INFO] vit-gin-client ..................................... SUCCESS [  1.521 s]
[INFO] sandbox-client ..................................... FAILURE [ 10.712 s]
[INFO] sandbox-server ..................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 15.742 s
[INFO] Finished at: 2016-12-01T21:54:22+03:00
[INFO] Final Memory: 13M/125M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal net.ltgt.gwt.maven:gwt-maven-plugin:1.0-rc-6:test (default-test) on project sandbox-client: There are test failures.
[ERROR]
[ERROR] Please refer to E:\Users\vitrums\workspace-neon\sandbox\sandbox-client\target\surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :sandbox-client


These are 2 classes I introduced under src/test/java/ in my sandbox-client module:

com/mycompany/AppSuite.java:

package com.mycompany;


import com.google.gwt.junit.tools.GWTTestSuite;
import com.mycompany.client.AppTest;


import junit.framework.Test;
import junit.framework.TestSuite;


public class AppSuite extends GWTTestSuite {
 
public static Test suite() {
   
TestSuite suite = new TestSuite("Tests for App");
    suite
.addTestSuite(AppTest.class);
   
return suite;
 
}
}

com/mycompany/client/AppTest.java:
package com.mycompany.client;

import com.mycompany.shared.FieldVerifier;
import com.mycompany.shared.GreetingResponse;
import com.mycompany.shared.GreetingService;
import com.mycompany.shared.GreetingServiceAsync;
import com.google.gwt.core.client.GWT;
import com.google.gwt.junit.client.GWTTestCase;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.ServiceDefTarget;


/**
 * GWT JUnit tests must extend GWTTestCase.
 */

public class AppTest extends GWTTestCase {


 
/**
   * Must refer to a valid module that sources this class.
   */

 
public String getModuleName() {
   
return "com.mycompany.AppJUnit";
 
}


 
/**
   * Tests the FieldVerifier.
   */

 
public void testFieldVerifier() {
    assertFalse
(FieldVerifier.isValidName(null));
    assertFalse
(FieldVerifier.isValidName(""));
    assertFalse
(FieldVerifier.isValidName("a"));
    assertFalse
(FieldVerifier.isValidName("ab"));
    assertFalse
(FieldVerifier.isValidName("abc"));
    assertTrue
(FieldVerifier.isValidName("abcd"));
 
}


 
/**
   * This test will send a request to the server using the greetServer method in
   * GreetingService and verify the response.
   */

 
public void testGreetingService() {
   
// Create the service that we will test.
   
GreetingServiceAsync greetingService = GWT.create(GreetingService.class);
   
ServiceDefTarget target = (ServiceDefTarget) greetingService;
    target
.setServiceEntryPoint(GWT.getModuleBaseURL() + "app/greet");


   
// Since RPC calls are asynchronous, we will need to wait for a response
   
// after this test method returns. This line tells the test runner to wait
   
// up to 10 seconds before timing out.
    delayTestFinish
(10000);


   
// Send a request to the server.
    greetingService
.greetServer("GWT User", new AsyncCallback<GreetingResponse>() {
     
public void onFailure(Throwable caught) {
       
// The request resulted in an unexpected error.
        fail
("Request failure: " + caught.getMessage());
     
}


     
public void onSuccess(GreetingResponse result) {
       
// Verify that the response is correct.
        assertTrue
(result.getGreeting().startsWith("Hello, GWT User!"));


       
// Now that we have received a response, we need to tell the test runner
       
// that the test is complete. You must call finishTest() after an
       
// asynchronous test finishes successfully, or the test will time out.
        finishTest
();
     
}
   
});
 
}
}

with com/mycompany/AppJUnit.gwt.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!--
  When updating your version of GWT, you should also update this DTD reference,
  so that your app can take advantage of the latest GWT module capabilities.
-->

<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.8.0//EN"
  "http://gwtproject.org/doctype/2.8.0/gwt-module.dtd">

<module>
 
<!-- Inherit our applications main module.                      -->
 
<inherits name='com.mycompany.App'/>
 
 
<!-- Specify the path to any remote services.                   -->
 
<servlet path="/app/greet" class="com.mycompany.GreetingServiceImpl" />


</module>

src/main/java/com/company/GreetingServiceImpl.java belongs to sandbox-server module.

p.s. Also it would be great if someone had a similar sample app somewhere on github and could give a link to show all pieces of this puzzle working properly.

vitrums

unread,
Dec 1, 2016, 11:53:46 PM12/1/16
to GWT Users
It's also not clear for me why greetingService test classes must've been completely excluded from the modular-webapp archetype. Archetypes in general serve to unify the maximum of core best practices relevant to some particular project structure (tests including), don't they?

Thomas Broyer

unread,
Dec 2, 2016, 4:47:44 AM12/2/16
to GWT Users


On Friday, December 2, 2016 at 5:53:46 AM UTC+1, vitrums wrote:
It's also not clear for me why greetingService test classes must've been completely excluded from the modular-webapp archetype.

Because, actually, using <servlet> in GWTTestCases is not seen as a good practice (anymore). GWTTestCases should be unit tests, running in a GWT/browser environment, not integration tests. For that, the preferred way is to use end-to-end tests.
 
Archetypes in general serve to unify the maximum of core best practices relevant to some particular project structure (tests including), don't they?

Archetypes are meant as scaffolding tools to cut boilerplate down. Putting "too much" things into an archetype means that you have to delete/refactor many things before actually being able to use the generated project.
The gwt-maven-archetypes could include some tests, but the code is so light that it'd be far-fetched and not realistic.

In your specific case, if you want to replicate the test using GreetingService; you'd have to create a new standard JAR module with your server code. The WAR module would depend on it (to include into the WAR/webapp); and the client (gwt-app) module could depend on it with <scope>test</scope>.

vitrums

unread,
Dec 2, 2016, 11:48:36 AM12/2/16
to GWT Users
Even though I can read .pom configuration files, I'm not strong in configuring them myself, when it comes to multi-module project. Especially when it comes to packaging servlets as jar. So I introduced the new module sandbox-server-lib. But which files should it consume from sandbox-server? E.g. if I move only com.mycompany.GreetingServiceImpl.java under sandbox-server-lib I won't have servlet mappings, necessary for jetty to operate during tests in sandbox-client (should I duplicate some files and have them in both modules)? If I move /src/main/webapp, then I'm not even sure what will be left for  sandbox-server to package as war and how to deploy it in container. And which dependencies, plugins and configurations would sandbox-server-lib's pom require (and what left from sandbox-server after all these operations)? I know I'm terribly lost :)

Thomas Broyer

unread,
Dec 2, 2016, 12:16:13 PM12/2/16
to GWT Users


On Friday, December 2, 2016 at 5:48:36 PM UTC+1, vitrums wrote:
Even though I can read .pom configuration files, I'm not strong in configuring them myself, when it comes to multi-module project. Especially when it comes to packaging servlets as jar.

Well, servlets are nothing more than Java classes extending from a specific abstract class. What makes it a servlet is how it's used at runtime (when used in a WAR to be deployed to a servlet container, then there needs to be a servlet mapping, defined either using a @WebServlet annotation or some XML in either a WEB-INF/web.xml file in the WAR, or a META-INF/web-fragment.xml in a JAR sitting in the WEB-INF/lib of the WAR.
 
So I introduced the new module sandbox-server-lib. But which files should it consume from sandbox-server? E.g. if I move only com.mycompany.GreetingServiceImpl.java under sandbox-server-lib I won't have servlet mappings, necessary for jetty to operate during tests in sandbox-client (should I duplicate some files and have them in both modules)?

There's no "servlet mappings […] for jetty to operate during tests"; the servlet mapping for GWTTestCase tests is defined by a <servlet> element in a gwt.xml file.
In other words, when everything is in a single project (like the one generated by webAppCreator, or the wizard in Eclipse, or the archetype from the org.codehaus.mojo:gwt-maven-plugin), the src/main/webapp/WEB-INF/web.xml is completely ignored during tests.
 
If I move /src/main/webapp, then I'm not even sure what will be left for  sandbox-server to package as war and how to deploy it in container. And which dependencies, plugins and configurations would sandbox-server-lib's pom require (and what left from sandbox-server after all these operations)?

Try with "nothing" :-)
Well, in the server-lib you'll need a dependency on javax.servlet to be able to compile your servlet, and in server (the WAR) you'll add a dependency on server-lib. No plugin should be needed. 
 
I know I'm terribly lost :)

Yes, you look like you're lost :-)
I'm afraid you can't develop in any given technology without learning the "basics" (between quotes, because it can mean a lot of things; learning curves are steep these days, and tending to become each year steeper than the preceding) : what is the classpath, a classloader, a JAR, a WAR, how to build a (simple) JAR (using the command-line, or some build tool), how to build a (simple) WAR. GWT adds a lot of things to those "basics", particularly when your build tool is as opinionated (and broken-by-design) as Maven.

I'm a bottom-up learner, first learning how things work (from documentation, not experimentation) before doing something with them, rather than a top-down learner, first doing things (possibly copy/pasting snippets here and there "until it works") then trying to understand how and why it all worked. That makes me a terrible teacher for top-down learners, who are better served with heavy full-stack frameworks and full scaffolding (ultimately leading to a huge amount of third-party code to do a simple hello world, if you ask me). Please note that I'm not judging "top-down learners", everybody is different and learns differently; I'm only acknowledging I'm generally unable to help them. I'm not sure what kind of learner you are, just letting you know that if you're a top-down one, then I'm probably not the right "teacher", and my gwt-maven-archetypes haven't been tailored for you (I am expecting average knowledge of Maven and GWT).

vitrums

unread,
Dec 2, 2016, 1:07:19 PM12/2/16
to GWT Users
Yes, you look like you're lost :-)
I'm afraid you can't develop in any given technology without learning the "basics" (between quotes, because it can mean a lot of things; learning curves are steep these days, and tending to become each year steeper than the preceding) : what is the classpath, a classloader, a JAR, a WAR, how to build a (simple) JAR (using the command-line, or some build tool), how to build a (simple) WAR. GWT adds a lot of things to those "basics", particularly when your build tool is as opinionated (and broken-by-design) as Maven.

I'm a bottom-up learner, first learning how things work (from documentation, not experimentation) before doing something with them, rather than a top-down learner, first doing things (possibly copy/pasting snippets here and there "until it works") then trying to understand how and why it all worked. That makes me a terrible teacher for top-down learners, who are better served with heavy full-stack frameworks and full scaffolding (ultimately leading to a huge amount of third-party code to do a simple hello world, if you ask me). Please note that I'm not judging "top-down learners", everybody is different and learns differently; I'm only acknowledging I'm generally unable to help them. I'm not sure what kind of learner you are, just letting you know that if you're a top-down one, then I'm probably not the right "teacher", and my gwt-maven-archetypes haven't been tailored for you (I am expecting average knowledge of Maven and GWT).

First of all, thank you for being responsive. As a learner I try to combine both approaches. I.e., when I recently required the funcionality of my snapshots being automatically stored in the hand-crafted remote maven repository and further have them as maven dependencies in other projects, I first tried to comprehend maven by learning pom reference, gwt-maven-plugin wiki and other resources, and then successfully applied the knowledge to introduce this feature. But of cause it gave me only the superficial understanding of the subject. And therefore I can understand some things erroneously.

With your help I can see now clearer how servlet path is being resolved for containers on different stages and it finally makes sense. But I still struggle to have the tests from single-module project created by webAppCreater running the same way in the multi-module one. To focus on this problem I once again started a new project named myartifact, and left all packages by default (everything is withing com.example.project). But there're still some unresolved dependencies on sandbox-shared.

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.example.project.AppSuite

Starting Jetty on port 0
   
[WARN] ServletContainerInitializers: detected. Class hierarchy: empty
Compiling module com.example.project.AppJUnit.JUnit

   
Ignored 3 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 -- 6,136s
Linking into E:\Users\vitrums\workspace-neon\myartifact\myartifact-client\target\gwt-tests\www\com.example.project.AppJUnit.JUnit
   
Link succeeded
   
Linking succeeded -- 0,273s

Ignored 3 units with compilation errors in first pass.
Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
Tracing compile failure path for type 'com.example.project.AppGwtTest'
   
[ERROR] Errors in 'file:/E:/Users/vitrums/workspace-neon/myartifact/myartifact-client/target/test-classes/com/example/project/AppGwtTest.java'
     
[ERROR] Line 24: No source code is available for type com.example.project.FieldVerifier; did you forget to inherit a required module?
     
[ERROR] Line 48: No source code is available for type com.example.project.GreetingResponse; did you forget to inherit a required module?
     
[ERROR] Line 38: No source code is available for type com.example.project.GreetingServiceAsync; did you forget to inherit a required module?
     
[ERROR] Line 38: No source code is available for type com.example.project.GreetingService; did you forget to inherit a required module?
[ERROR] Hint: Your source appears not to live underneath a subpackage called 'client'; no problem, but you'll need to use the <source> directive in your module to make it accessible
Tracing compile failure path for type '
com.example.project.AppGwtTest'
   [ERROR] Errors in '
file:/E:/Users/vitrums/workspace-neon/myartifact/myartifact-client/target/test-classes/com/example/project/AppGwtTest.java'
      [ERROR] Line 24: No source code is available for type com.example.project.FieldVerifier; did you forget to inherit a required module?
      [ERROR] Line 48: No source code is available for type com.example.project.GreetingResponse; did you forget to inherit a required module?
      [ERROR] Line 38: No source code is available for type com.example.project.GreetingServiceAsync; did you forget to inherit a required module?
      [ERROR] Line 38: No source code is available for type com.example.project.GreetingService; did you forget to inherit a required module?
[ERROR] Hint: Your source appears not to live underneath a subpackage called '
client'; no problem, but you'll need to use the <source> directive in your module to make it accessible
Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 8.946 sec <<< FAILURE! - in com.example.project.AppSuite
testGreetingService
(com.example.project.AppGwtTest)  Time elapsed: 8.879 sec  <<< ERROR!
com
.google.gwt.junit.JUnitFatalLaunchException: The test class 'com.example.project.AppGwtTest' had compile errors; check log for details
 at com
.google.gwt.junit.JUnitShell.checkTestClassInCurrentModule(JUnitShell.java:732)

 at com
.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1325)
 at com
.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1281)
 at com
.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:670)
 at com
.google.gwt.junit.client.GWTTestCase.runTest(GWTTestCase.java:421)
 at junit
.framework.TestCase.runBare(TestCase.java:141)
 at junit
.framework.TestResult$1.protect(TestResult.java:122)
 at junit
.framework.TestResult.runProtected(TestResult.java:142)
 at junit
.framework.TestResult.run(TestResult.java:125)
 at junit
.framework.TestCase.run(TestCase.java:129)
 at com
.google.gwt.junit.client.GWTTestCase.run(GWTTestCase.java:247)
 at junit
.framework.TestSuite.runTest(TestSuite.java:255)
 at junit
.framework.TestSuite.run(TestSuite.java:250)
 at junit
.framework.TestSuite.runTest(TestSuite.java:255)
 at junit
.framework.TestSuite.run(TestSuite.java:250)
 at org
.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
 at org
.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:264)
 at org
.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
 at org
.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
 at org
.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
 at org
.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
 at org
.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)



testFieldVerifier
(com.example.project.AppGwtTest)  Time elapsed: 0.002 sec  <<< ERROR!
com
.google.gwt.junit.JUnitFatalLaunchException: The test class 'com.example.project.AppGwtTest' had compile errors; check log for details
 at com
.google.gwt.junit.JUnitShell.checkTestClassInCurrentModule(JUnitShell.java:732)

 at com
.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1325)
 at com
.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1281)
 at com
.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:670)
 at com
.google.gwt.junit.client.GWTTestCase.runTest(GWTTestCase.java:421)
 at junit
.framework.TestCase.runBare(TestCase.java:141)
 at junit
.framework.TestResult$1.protect(TestResult.java:122)
 at junit
.framework.TestResult.runProtected(TestResult.java:142)
 at junit
.framework.TestResult.run(TestResult.java:125)
 at junit
.framework.TestCase.run(TestCase.java:129)
 at com
.google.gwt.junit.client.GWTTestCase.run(GWTTestCase.java:247)
 at junit
.framework.TestSuite.runTest(TestSuite.java:255)
 at junit
.framework.TestSuite.run(TestSuite.java:250)
 at junit
.framework.TestSuite.runTest(TestSuite.java:255)
 at junit
.framework.TestSuite.run(TestSuite.java:250)
 at org
.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
 at org
.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:264)
 at org
.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
 at org
.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
 at org
.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
 at org
.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
 at org
.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)




Results :


Tests in error:

 
AppGwtTest>GWTTestCase.run:247->GWTTestCase.runTest:421 » JUnitFatalLaunch The...
 
AppGwtTest>GWTTestCase.run:247->GWTTestCase.runTest:421 » JUnitFatalLaunch The...



Tests run: 2, Failures: 0, Errors: 2, Skipped: 0


[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] myartifact ......................................... SUCCESS [  0.003 s]
[INFO] myartifact-shared .................................. SUCCESS [  0.490 s]
[INFO] myartifact-server-lib .............................. SUCCESS [  0.039 s]
[INFO] myartifact-client .................................. FAILURE [ 10.314 s]
[INFO] myartifact-server .................................. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.031 s
[INFO] Finished at: 2016-12-02T20:37:32+03:00
[INFO] Final Memory: 17M/220M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal net.ltgt.gwt.maven:gwt-maven-plugin:1.0-rc-6:test (default-test) on project myartifact-client: There are test failures.
[ERROR]
[ERROR] Please refer to E:\Users\vitrums\workspace-neon\myartifact\myartifact-client\target\surefire-reports for the individual test results.

[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :myartifact-client


myartifact-client/pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 
<modelVersion>4.0.0</modelVersion>


 
<parent>
   
<groupId>com.example.project</groupId>
   
<artifactId>myartifact</artifactId>
   
<version>0.0.1-SNAPSHOT</version>
 
</parent>


 
<artifactId>myartifact-client</artifactId>
 
<packaging>gwt-app</packaging>


 
<prerequisites>
   
<maven>${mavenVersion}</maven>
 
</prerequisites>


 
<dependencies>
   
<dependency>
     
<groupId>${project.groupId}</groupId>
     
<artifactId>myartifact-shared</artifactId>
     
<version>${project.version}</version>
   
</dependency>
   
<dependency>
     
<groupId>${project.groupId}</groupId>
     
<artifactId>myartifact-shared</artifactId>
     
<version>${project.version}</version>
     
<classifier>sources</classifier>
   
</dependency>
   
<dependency>
     
<groupId>${project.groupId}</groupId>
     
<artifactId>myartifact-server-lib</artifactId>
     
<version>${project.version}</version>
     
<scope>test</scope>
   
</dependency>
   
<dependency>
     
<groupId>com.google.gwt</groupId>
     
<artifactId>gwt-user</artifactId>
   
</dependency>
   
<dependency>
     
<groupId>com.google.gwt</groupId>
     
<artifactId>gwt-dev</artifactId>
   
</dependency>
 
</dependencies>


 
<build>
   
<plugins>
     
<plugin>
       
<groupId>net.ltgt.gwt.maven</groupId>
       
<artifactId>gwt-maven-plugin</artifactId>
       
<configuration>
         
<moduleName>com.example.project.App</moduleName>
         
<moduleShortName>app</moduleShortName>
       
</configuration>
     
</plugin>
     
     
<!-- Skip normal test execution, we use gwt:test instead -->
     
<plugin>
       
<artifactId>maven-surefire-plugin</artifactId>
       
<version>2.17</version>
       
<configuration>
         
<skip>true</skip>
       
</configuration>
     
</plugin>
   
</plugins>
 
</build>
</project>


Thomas Broyer

unread,
Dec 2, 2016, 1:24:37 PM12/2/16
to GWT Users
You might have just uncovered a bug in gwt:test. I think a workaround would be to move the maven-source-plugin to the process-classes phase.

vitrums

unread,
Dec 2, 2016, 2:06:23 PM12/2/16
to GWT Users
You might have just uncovered a bug in gwt:test. I think a workaround would be to move the maven-source-plugin to the process-classes phase.

And it worked like a charm :)

myartifact/pom.xml:
        <plugin>
         
<artifactId>maven-source-plugin</artifactId>
         
<version>3.0.1</version>
         
<executions>
           
<execution>
             
<id>attach-sources</id>
             
<phase>process-classes</phase>  <!-- fix -->
             
<!-- <phase>package</phase> -->
             
<goals>
               
<goal>jar-no-fork</goal>
             
</goals>
           
</execution>
         
</executions>
       
</plugin>

mvn test:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] myartifact
[INFO] myartifact-shared
[INFO] myartifact-server-lib
[INFO] myartifact-client
[INFO] myartifact-server
[INFO]                                                                        
[INFO] ------------------------------------------------------------------------
[INFO] Building myartifact 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]                                                                        
[INFO] ------------------------------------------------------------------------
[INFO] Building myartifact-shared 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ myartifact-shared ---

[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory E:\Users\vitrums\workspace-neon\myartifact\myartifact-shared\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ myartifact-shared ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 4 source files to E:\Users\vitrums\workspace-neon\myartifact\myartifact-shared\target\classes
[INFO]
[INFO] --- maven-source-plugin:3.0.1:jar-no-fork (attach-sources) @ myartifact-shared ---
[INFO] Building jar: E:\Users\vitrums\workspace-neon\myartifact\myartifact-shared\target\myartifact-shared-0.0.1-SNAPSHOT-sources.jar
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ myartifact-shared ---

[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory E:\Users\vitrums\workspace-neon\myartifact\myartifact-shared\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ myartifact-shared ---

[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ myartifact-shared ---
[INFO]                                                                        
[INFO] ------------------------------------------------------------------------
[INFO] Building myartifact-server-lib 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ myartifact-server-lib ---

[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ myartifact-server-lib ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to E:\Users\vitrums\workspace-neon\myartifact\myartifact-server-lib\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ myartifact-server-lib ---

[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ myartifact-server-lib ---

[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ myartifact-server-lib ---
[INFO]                                                                        
[INFO] ------------------------------------------------------------------------
[INFO] Building myartifact-client 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- gwt-maven-plugin:1.0-rc-6:enforce-encoding (default-enforce-encoding) @ myartifact-client ---
[INFO]
[INFO] --- gwt-maven-plugin:1.0-rc-6:add-super-sources (default-add-super-sources) @ myartifact-client ---
[INFO]
[INFO] --- gwt-maven-plugin:1.0-rc-6:add-test-super-sources (default-add-test-super-sources) @ myartifact-client ---
[INFO]
[INFO] --- gwt-maven-plugin:1.0-rc-6:generate-module (default-generate-module) @ myartifact-client ---
[INFO] E:\Users\vitrums\workspace-neon\myartifact\myartifact-client\target\classes\com\example\project\App.gwt.xml up to date - skipping
[INFO]
[INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ myartifact-client ---

[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory E:\Users\vitrums\workspace-neon\myartifact\myartifact-client\src\main\resources
[INFO] skip non existing resourceDirectory E:\Users\vitrums\workspace-neon\myartifact\myartifact-client\src\main\super
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ myartifact-client ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to E:\Users\vitrums\workspace-neon\myartifact\myartifact-client\target\classes
[INFO]
[INFO] --- gwt-maven-plugin:1.0-rc-6:import-sources (default-import-sources) @ myartifact-client ---

[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-resources-plugin:3.0.1:testResources (default-testResources) @ myartifact-client ---

[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory E:\Users\vitrums\workspace-neon\myartifact\myartifact-client\src\test\resources
[INFO] skip non existing resourceDirectory E:\Users\vitrums\workspace-neon\myartifact\myartifact-client\src\test\super
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ myartifact-client ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to E:\Users\vitrums\workspace-neon\myartifact\myartifact-client\target\test-classes
[INFO]
[INFO] --- gwt-maven-plugin:1.0-rc-6:import-test-sources (default-import-test-sources) @ myartifact-client ---

[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO]
[INFO] --- gwt-maven-plugin:1.0-rc-6:test (default-test) @ myartifact-client ---
[INFO] GWT tests report directory: E:\Users\vitrums\workspace-neon\myartifact\myartifact-client\target\surefire-reports


-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.example.project.AppSuite
Starting Jetty on port 0
   
[WARN] ServletContainerInitializers: detected. Class hierarchy: empty
Compiling module com.example.project.AppJUnit.JUnit

   
Ignored 1 unit 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 -- 21,181s

Linking into E:\Users\vitrums\workspace-neon\myartifact\myartifact-client\target\gwt-tests\www\com.example.project.AppJUnit.JUnit
   
Link
succeeded
   
Linking succeeded -- 0,355s
Ignored 1 unit with compilation errors in first pass.

Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
Starting http://localhost:50070/com.example.project.AppJUnit.JUnit/junit.html on browser FF38
200 - GET /com.example.project.AppJUnit.JUnit/junit.html (127.0.0.1)
200 - GET /com.example.project.AppJUnit.JUnit/com.example.project.AppJUnit.JUnit.nocache.js (127.0.0.1)
200 - GET /com.example.project.AppJUnit.JUnit/83FA091D70963A1A3E4C52B7399675F9.cache.js (127.0.0.1)
200 - GET /com.example.project.AppJUnit.JUnit/gwt/clean/clean.css (127.0.0.1)
200 - POST /com.example.project.AppJUnit.JUnit/junithost (127.0.0.1) 216 bytes
200 - POST /com.example.project.AppJUnit.JUnit/app/greet (127.0.0.1) 178 bytes
200 - POST /com.example.project.AppJUnit.JUnit/junithost (127.0.0.1) 188 bytes
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 26.749 sec - in com.example.project.AppSuite


Results :


Tests run: 2, Failures: 0, Errors: 0, Skipped: 0


[INFO]                                                                        
[INFO] ------------------------------------------------------------------------
[INFO] Building myartifact-server 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ myartifact-server ---

[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory E:\Users\vitrums\workspace-neon\myartifact\myartifact-server\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ myartifact-server ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to E:\Users\vitrums\workspace-neon\myartifact\myartifact-server\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ myartifact-server ---

[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory E:\Users\vitrums\workspace-neon\myartifact\myartifact-server\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ myartifact-server ---

[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ myartifact-server ---

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] myartifact ......................................... SUCCESS [  0.004 s]
[INFO] myartifact-shared .................................. SUCCESS [  2.136 s]
[INFO] myartifact-server-lib .............................. SUCCESS [  0.127 s]
[INFO] myartifact-client .................................. SUCCESS [ 28.844 s]
[INFO] myartifact-server .................................. SUCCESS [  0.128 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 32.418 s
[INFO] Finished at: 2016-12-02T22:00:11+03:00
[INFO] Final Memory: 31M/207M
[INFO] ------------------------------------------------------------------------


Is it safe to leave it like this?

Thomas Broyer

unread,
Dec 3, 2016, 12:58:58 PM12/3/16
to GWT Users


On Friday, December 2, 2016 at 8:06:23 PM UTC+1, vitrums wrote:
Is it safe to leave it like this?

Absolutely.

And actually, there's no bug in gwt:test. gwt:test (actually, GWTTestCases, whether run through gwt:test or surefire:test or whatever) simply expects the sources to be on the classpath.
What you faced was just a limitation of Maven's linear lifecycle when combined with reactor builds: because source:jar-no-fork in shared-lib was bound to the package phase, and you didn't run it (you only run the lifecycle up to the test phase, in each module) the source-jar wasn't available (and neither was the jar BTW). When Maven needs to resolve a dependency from the reactor build and no artifact has been attached to the project, it simply defaults to using target/classes (it actually depends on the packaging), so you never got your sources when running tests. By attaching the source:jar-no-fork to the process-classes phase, when the test phase is run, the source-jar is attached to the project so it can be resolved.
My take on this is that you shouldn't ever run any lifecycle phase prior to package (at least in a reactor build), and this is why I attached the source:jar-no-fork to the package phase in the gwt-maven-archetypes. Failing to run at least up to the package phase means that your artifacts aren't fully built and attached, and Maven uses heuristics to replace them, and it can fail you and cause all sorts of issues (generally breaking your build, but it could also cause false-positives).

All this discussion makes me want to write (yet another) blog post on why Maven is broken by design, and how to avoid failing into its traps (basically: use "mvn verify" instead of "mvn install" as that's what you want 99% of the time, never run anything prior to the package phase in a reactor build, and use -DskipTests or -Dmaven.test.skip if you want to skip tests, or -Dtest=<pattern> to filter tests to run)

salk31

unread,
Dec 7, 2016, 6:43:47 AM12/7/16
to GWT Users
On Friday, December 2, 2016 at 9:47:44 AM UTC, Thomas Broyer wrote:


Because, actually, using <servlet> in GWTTestCases is not seen as a good practice (anymore). GWTTestCases should be unit tests, running in a GWT/browser environment, not integration tests. For that, the preferred way is to use end-to-end tests.
 
Hi Thomas, 

What is state of the art for "end-to-end tests" for GWT apps with server side component? The generic solutions like WebDriver?

Cheers

Sam 
Reply all
Reply to author
Forward
0 new messages