3

I want to write test case for GWT composite component i created, I had class Count which extends com.google.gwt.user.client.ui.Composite and in this Count i had a text box and some handler for this to display labels according to the values.

Now i want to write test case for this class, i tried like code below but it always show same Error : java.lang.NoSuchMethodError: org.mortbay.thread.Timeout.(Ljava/lang/Object;)V

my code is:

    package com.rubirules.uibuilder.client;
import org.junit.Test;
import com.google.gwt.junit.client.GWTTestCase;
public class CountTest extends GWTTestCase {
    @Override
    public String getModuleName() {
        return "com.rubirules.uibuilder.client.Count";
    }
    @Test
    public void testNullConstructor(){  
            assertFalse(true);
                        //TODO need to add some code to test Count class
    }
}

also i want to know what is the use of getModuleName() method? I had given the string path of my class under test.

the compleate error message is:

java.lang.NoSuchMethodError: org.mortbay.thread.Timeout.<init>(Ljava/lang/Object;)V
    at org.mortbay.io.nio.SelectorManager$SelectSet.<init>(SelectorManager.java:306)
    at org.mortbay.io.nio.SelectorManager.doStart(SelectorManager.java:223)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
    at org.mortbay.jetty.nio.SelectChannelConnector.doStart(SelectChannelConnector.java:303)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
    at org.mortbay.jetty.Server.doStart(Server.java:233)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
    at com.google.gwt.dev.shell.jetty.JettyLauncher.start(JettyLauncher.java:672)
    at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:509)
    at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1093)
    at com.google.gwt.junit.JUnitShell.getUnitTestShell(JUnitShell.java:707)
    at com.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:652)
    at com.google.gwt.junit.client.GWTTestCase.runTest(GWTTestCase.java:441)
    at junit.framework.TestCase.runBare(TestCase.java:134)
    at junit.framework.TestResult$1.protect(TestResult.java:110)
    at junit.framework.TestResult.runProtected(TestResult.java:128)
    at junit.framework.TestResult.run(TestResult.java:113)
    at junit.framework.TestCase.run(TestCase.java:124)
    at com.google.gwt.junit.client.GWTTestCase.run(GWTTestCase.java:296)
    at junit.framework.TestSuite.runTest(TestSuite.java:243)
    at junit.framework.TestSuite.run(TestSuite.java:238)
    at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
   [WARN] failed SelectChannelConnector@0.0.0.0:0
java.lang.NoSuchMethodError: org.mortbay.thread.Timeout.<init>(Ljava/lang/Object;)V
    at org.mortbay.io.nio.SelectorManager$SelectSet.<init>(SelectorManager.java:306)
    at org.mortbay.io.nio.SelectorManager.doStart(SelectorManager.java:223)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
    at org.mortbay.jetty.nio.SelectChannelConnector.doStart(SelectChannelConnector.java:303)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
    at org.mortbay.jetty.Server.doStart(Server.java:233)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
    at com.google.gwt.dev.shell.jetty.JettyLauncher.start(JettyLauncher.java:672)
    at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:509)
    at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1093)
    at com.google.gwt.junit.JUnitShell.getUnitTestShell(JUnitShell.java:707)
    at com.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:652)
    at com.google.gwt.junit.client.GWTTestCase.runTest(GWTTestCase.java:441)
    at junit.framework.TestCase.runBare(TestCase.java:134)
    at junit.framework.TestResult$1.protect(TestResult.java:110)
    at junit.framework.TestResult.runProtected(TestResult.java:128)
    at junit.framework.TestResult.run(TestResult.java:113)
    at junit.framework.TestCase.run(TestCase.java:124)
    at com.google.gwt.junit.client.GWTTestCase.run(GWTTestCase.java:296)
    at junit.framework.TestSuite.runTest(TestSuite.java:243)
    at junit.framework.TestSuite.run(TestSuite.java:238)
    at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
   [WARN] failed Server@2edfcb
java.lang.NoSuchMethodError: org.mortbay.thread.Timeout.<init>(Ljava/lang/Object;)V
    at org.mortbay.io.nio.SelectorManager$SelectSet.<init>(SelectorManager.java:306)
    at org.mortbay.io.nio.SelectorManager.doStart(SelectorManager.java:223)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
    at org.mortbay.jetty.nio.SelectChannelConnector.doStart(SelectChannelConnector.java:303)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
    at org.mortbay.jetty.Server.doStart(Server.java:233)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
    at com.google.gwt.dev.shell.jetty.JettyLauncher.start(JettyLauncher.java:672)
    at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:509)
    at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1093)
    at com.google.gwt.junit.JUnitShell.getUnitTestShell(JUnitShell.java:707)
    at com.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:652)
    at com.google.gwt.junit.client.GWTTestCase.runTest(GWTTestCase.java:441)
    at junit.framework.TestCase.runBare(TestCase.java:134)
    at junit.framework.TestResult$1.protect(TestResult.java:110)
    at junit.framework.TestResult.runProtected(TestResult.java:128)
    at junit.framework.TestResult.run(TestResult.java:113)
    at junit.framework.TestCase.run(TestCase.java:124)
    at com.google.gwt.junit.client.GWTTestCase.run(GWTTestCase.java:296)
    at junit.framework.TestSuite.runTest(TestSuite.java:243)
    at junit.framework.TestSuite.run(TestSuite.java:238)
    at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Dipak
  • 6,532
  • 8
  • 63
  • 87

2 Answers2

2

I recommend you to use gwt-test-utils, It has complete documentations and samples.

Saeed Zarinfam
  • 9,818
  • 7
  • 59
  • 72
  • sir, actually i feel like my problem is with the getModuleName() method, i don't know exact module path. When i use null and didn't refer on Count it shows no error, but to use Count class i have to give exact module path. Do you know what will be the module path? – Dipak Jan 02 '13 at 09:47
  • It is the path of your *.gwt.xml located plus module name. For example: com.googlecode.gwt.test.sample.SpringSample – Saeed Zarinfam Jan 02 '13 at 11:53
2

Please check how Google GWT Team writes test case for widgets. You can find examples in the GWT repository on GitHub.

Implement getModuleName() so that it returns a string which reflects the path to your GWT module file com.rubirules.uibuilder.UIbuilder.

Kalle Richter
  • 8,008
  • 26
  • 77
  • 177
appbootup
  • 9,537
  • 3
  • 33
  • 65
  • package com.google.gwt.user.client.ui; public class ButtonTest extends GWTTestCase { private static final String html = "helloworld"; @Override public String getModuleName() { return "com.google.gwt.user.User"; } will you tell me what exactly this getModuleName() returns? – Dipak Jan 02 '13 at 09:58
  • It is a hard coded string "com.google.gwt.user.User" corresponding to gwt module file for gwt-user.jar – appbootup Jan 02 '13 at 10:17
  • Thank you for that link. I got solved my problem, i changed com.google.appengine.eclipse.sdkbundle_1.7.4 to 1.7.3 and my getNameModule path to com.rubirules.uibuilder.UIbuilder, corresponding to module file. thank you. :) – Dipak Jan 02 '13 at 10:47