ClassCaseException with GWTTestSuite

26 views
Skip to first unread message

Arthur Kalmenson

unread,
Jun 25, 2009, 4:08:48 PM6/25/09
to codehaus-mojo-gwt-...@googlegroups.com
Hello everyone,

In my previous project I used GWTTestSuite and everything worked very well. I'm working on another project and GWTTestSuite refuses to work. My test suite looks as follows:

package com.sinai.maru;


import junit.framework.Test;

import junit.framework.TestSuite;


import com.google.gwt.junit.tools.GWTTestSuite;

import com.sinai.maru.client.view.ApplicationHeaderViewGwtTest;


public class GwtTestMediarUploadSuite extends GWTTestSuite {


public static Test suite() {

TestSuite suite = new TestSuite(

"GWTTestSuite for running all GWTTestCases.");


suite.addTestSuite(ApplicationHeaderViewGwtTest.class);


return suite;

}

}


When I run gwt:test I get the follow:

ares:mediar-upload arthur$ mvn gwt:test
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building MediAR Upload Project
[INFO]    task-segment: [gwt:test]
[INFO] ------------------------------------------------------------------------
[INFO] [gwt:test]
[INFO] using GWT jars from project dependencies : 1.6.4
[INFO] Unpack native libraries required to run GWT
[INFO] establishing classpath list (scope = test)
[ERROR] Error: java.lang.ClassCastException: class com.sinai.maru.GwtTestMediarUploadSuite
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] There was test failures.
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Thu Jun 25 16:07:15 EDT 2009
[INFO] Final Memory: 9M/18M
[INFO] ------------------------------------------------------------------------


The execution looks as follows with the error stacktrace turned on:

ares:mediar-upload arthur$ mvn -e gwt:test
+ Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building MediAR Upload Project
[INFO]    task-segment: [gwt:test]
[INFO] ------------------------------------------------------------------------
[INFO] [gwt:test]
[INFO] using GWT jars from project dependencies : 1.6.4
[INFO] Unpack native libraries required to run GWT
[INFO] establishing classpath list (scope = test)
[ERROR] Error: java.lang.ClassCastException: class com.sinai.maru.GwtTestMediarUploadSuite
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] There was test failures.
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: There was test failures.
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:703)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:553)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:523)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:371)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:332)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:181)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:356)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:137)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:356)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: There was test failures.
at org.codehaus.mojo.gwt.shell.TestMojo.doExecute(TestMojo.java:140)
at org.codehaus.mojo.gwt.shell.AbstractGwtShellMojo.execute(AbstractGwtShellMojo.java:129)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:483)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:678)
... 16 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Thu Jun 25 16:07:52 EDT 2009
[INFO] Final Memory: 9M/18M
[INFO] ------------------------------------------------------------------------


What is it trying to cast it to that it can't? Any help would be greatly appreciated.

Best regards,
--
Arthur Kalmenson

Arthur Kalmenson

unread,
Jun 25, 2009, 4:12:59 PM6/25/09
to codehaus-mojo-gwt-...@googlegroups.com
P.S. Renaming it to remove GwtTest (i.e. so it doesn't think it's a regular GWTTestCase) didn't do anything. I still get the ClassCastException.

--
Arthur Kalmenson

Arthur Kalmenson

unread,
Jun 26, 2009, 8:36:11 AM6/26/09
to codehaus-mojo-gwt-...@googlegroups.com
I tried creating a new project using the archetype and adding a GWTTestSuite to it. Even with the new project I'm still getting a ClassCastException. I've attached the test project, hopefully that'll help. Thanks again.

Best regards,
--
Arthur Kalmenson


gwt-test.tar.gz

Arthur Kalmenson

unread,
Jun 26, 2009, 8:47:24 AM6/26/09
to codehaus-mojo-gwt-...@googlegroups.com
Sorry for the spam, but I just tried running the GWTTestSuite through Eclipse using the regular JUnit runner (after explicitly adding the gwt-dev dependency and adding folders to the class path) and it works fine. I can't seem to reproduce the ClassCastException.

I tried looking at the source of the mojo and it fails in the doExecute( runtime ) line 129 of AbstractGwtShellMojo. That didn't help me though...

--
Arthur Kalmenson

Dean Povey

unread,
Jun 27, 2009, 6:36:48 PM6/27/09
to codehaus-mojo-gwt-...@googlegroups.com, codehaus-mojo-gwt-...@googlegroups.com
Try addTest rather than addTestSuite.

Cheers
Dean

Arthur Kalmenson

unread,
Jul 1, 2009, 10:09:21 PM7/1/09
to codehaus-mojo-gwt-...@googlegroups.com
How does that work exactly? Add test by test? I'm not sure why adding
the test class itself via addTestSuite doesn't work.

--
Arthur Kalmenson

Dean Povey

unread,
Jul 2, 2009, 12:33:57 AM7/2/09
to codehaus-mojo-gwt-...@googlegroups.com
Sorry my mistake, that clearly doesn't work.  The problem is you should be doing:

package com.sinai.maru;

import junit.framework.Test;
import junit.framework.TestSuite;
import com.google.gwt.junit.tools.GWTTestSuite;
import com.sinai.maru.client.view.ApplicationHeaderViewGwtTest;

public class GwtTestMediarUploadSuite extends GWTTestSuite {

    public static Test suite() {
        GWTTestSuite suite = new GWTTestSuite(
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

            "GWTTestSuite for running all GWTTestCases.");
            suite.addTestSuite(ApplicationHeaderViewGwtTest.class);
            return suite;
    }
}

Dean.

Dean Povey

unread,
Jul 2, 2009, 12:35:21 AM7/2/09
to codehaus-mojo-gwt-...@googlegroups.com
Err and I missed that you should be extending TestCase not GWTTestSuite.

Dean.

Dean Povey

unread,
Jul 2, 2009, 1:49:41 AM7/2/09
to codehaus-mojo-gwt-...@googlegroups.com
I should add that all of that is contrary to what the GWT documentation says you should do, but does fix the ClassCastException.  I worked this out once and then didn't bother to find out why.

Dean.

Arthur Kalmenson

unread,
Jul 27, 2009, 10:32:41 AM7/27/09
to codehaus-mojo-gwt-...@googlegroups.com
Hooray!! You're a life saver Dean.

Here's what my class looks like:


public class GwtCmsUiSuite extends TestCase {
public static Test suite() {
GWTTestSuite suite = new GWTTestSuite();
suite.addTestSuite(SomeGwtTest.class);
return suite;
}
}

Thanks again.

Best regards,
--
Arthur Kalmenson



Reply all
Reply to author
Forward
0 new messages