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.
These are 2 classes I introduced under src/test/java/ in my sandbox-client module:
-- 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.
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment