Developing tests JUnit.... use GWTTestCase is a mistake

10 views
Skip to first unread message

Maverick

unread,
Oct 5, 2007, 6:03:45 AM10/5/07
to GWT-Ext Developer Forum
Sorry for my English...

What steps will reproduce the problem?
1. Very simple application - two buttons on the form. This application
i
download on the forum of group gwt and appended GWTExt button...

package com.google.gwt.sample.testdemo.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
import com.google.gwt.user.client.ui.*;
import com.gwtext.client.widgets.event.ButtonListener;

/**
* A simple GWT application that fetches strings from a server via a
GWT RPC,
* and displays them in the UI. Each time a button is clicked, a new
String
* greeting is displayed.
*
*/
public class GenericHello implements EntryPoint {

private static String[] greetings = new String[] {
"World", "GWT", "There", "Everybody", "AJAX", "Maverick"};
private int index = 0;

public com.gwtext.client.widgets.Button bext = new
com.gwtext.client.widgets.Button("GWTExt");
public Button b = new Button("GWT");

/**
* Standard GWT entry point hook.
*/
public void onModuleLoad() {
// Set up a local endpoint to the remote RPC service
final HelloAsync hello = (HelloAsync) GWT.create(Hello.class);

ServiceDefTarget endpoint = (ServiceDefTarget) hello;
endpoint.setServiceEntryPoint(GWT.getModuleBaseURL() +
"getgreeting");

// Create a button and a label, one above the other
VerticalPanel vp = new VerticalPanel();
RootPanel.get().add(vp);


final Label l = new Label();
b.setEnabled(false); // start disabled; enabled below

vp.add(bext);
vp.add(b);
vp.add(l);

// populate the server's initial contents via an RPC call
hello.setGreetings(greetings, new AsyncCallback() {
public void onFailure(Throwable caught) {
}

public void onSuccess(Object result) {
// once we succeed, it's safe to let user click the button
b.setEnabled(true);
}
});

// attach some useful behavior to the button
b.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
// cycle 'index', incrementing each time the button is clicked
if (index >= greetings.length) {
index = 0;
}
// fetch a string from server, and format up a greeting
hello.getGreeting(index++, new AsyncCallback() {
public void onFailure(Throwable caught) {
l.setText("");
}

public void onSuccess(Object result) {
l.setText("Hello, " + (String) result + "!");
}
});
}
});
}
}


2. Very simple test

package com.google.gwt.sample.testdemo.test;

import com.google.gwt.core.client.GWT;
import com.google.gwt.junit.client.GWTTestCase;
import com.google.gwt.sample.testdemo.client.Hello;
import com.google.gwt.sample.testdemo.client.HelloAsync;
import com.google.gwt.sample.testdemo.client.GenericHello;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.ServiceDefTarget;

public class TestHelloServlet extends GWTTestCase {
private HelloAsync hello = null;

public void testGWTButton(){
GenericHello gen = new GenericHello();
assertEquals(gen.b.getText(), "GWT");
}


3.

What is the expected output? What do you see instead?

[WARN] StandardContext[]shell: Failed to deserialize getException of
type
'java.lang.ExceptionInInitializerError'; no available constructor
java.lang.IllegalStateException: Can't overwrite cause
at java.lang.Throwable.initCause(Throwable.java:320)
at
com.google.gwt.junit.server.JUnitHostImpl.deserialize(JUnitHostImpl.java:
147)
at
com.google.gwt.junit.server.JUnitHostImpl.reportResultsAndGetNextMethod(JUnitHostImpl.java:
100)
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
com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:
348)
at
com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:
222)
at
com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:
174)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at
com.google.gwt.dev.shell.GWTShellServlet.service(GWTShellServlet.java:
249)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:
237)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:
157)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:
214)
at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:
104)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:
520)
at
org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:
198)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:
152)
at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:
104)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:
520)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:
137)
at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:
104)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:
118)
at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:
102)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:
520)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:
109)
at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:
104)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:
520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:
929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:
160)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:
799)
at
org.apache.coyote.http11.Http11Protocol
$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:
577)
at
org.apache.tomcat.util.threads.ThreadPool
$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:595)

Process finished with exit code 255

java.lang.ExceptionInInitializerError
at com.gwtext.client.widgets.Button.<init>(Button.java:31)
at
com.google.gwt.sample.testdemo.client.GenericHello.<init>(GenericHello.java:
30)
at
com.google.gwt.sample.testdemo.test.TestHelloServlet.testGWTButton(TestHelloServlet.java:
271)
at
com.google.gwt.sample.testdemo.test.__TestHelloServlet_unitTestImpl.doRunTest(transient
source for
com.google.gwt.sample.testdemo.test.__TestHelloServlet_unitTestImpl:
23)
at
com.google.gwt.junit.client.impl.GWTTestCaseImpl.runTest(GWTTestCaseImpl.java:
397)
at
com.google.gwt.junit.client.impl.GWTTestCaseImpl.access
$1(GWTTestCaseImpl.java:387)
at
com.google.gwt.junit.client.impl.GWTTestCaseImpl
$JUnitHostListener.onSuccess(GWTTestCaseImpl.java:67)
at
com.google.gwt.junit.client.impl.JUnitHost_Proxy
$2.onCompletionImpl(transient
source for com.google.gwt.junit.client.impl.JUnitHost_Proxy:134)
at
com.google.gwt.junit.client.impl.JUnitHost_Proxy
$2.onCompletionAndCatch(transient
source for com.google.gwt.junit.client.impl.JUnitHost_Proxy:110)
at
com.google.gwt.junit.client.impl.JUnitHost_Proxy
$2.onCompletion(transient
source for com.google.gwt.junit.client.impl.JUnitHost_Proxy:104)
at sun.reflect.GeneratedMethodAccessor30.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at
com.google.gwt.dev.shell.moz.MethodDispatch.invoke(MethodDispatch.java:
80)
at org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(Native
Method)
at org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(OS.java:
1428)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2840)
at com.google.gwt.dev.GWTShell.pumpEventLoop(GWTShell.java:689)
at com.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:442)
at com.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:167)
at com.google.gwt.junit.client.GWTTestCase.runTest(GWTTestCase.java:
194)
at com.google.gwt.junit.client.GWTTestCase.run(GWTTestCase.java:114)
at
com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:
40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:
90)


What version of the product are you using? On what operating system?
0.9.1, 0.9.2 , Fedora Core 7, all Linux OS

When i try to test interface of user-part - i see this message ...
One more time - sorry for my English... I mean, you understand...

Please, it's very impotent for our Project..

I would be grateful for any Board...

Sanjiv Jivan

unread,
Oct 8, 2007, 7:46:49 PM10/8/07
to gwt...@googlegroups.com
Maverick,
There's no indication in error that this is related to GWT-Ext. It appears related to your RPC call where your service is throwing an Exception and the Exception class does not have a default constructor. You can try removing all references to the GWT-Ext button and use a GWT button to confirm this.

Sanjiv

        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
com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:
348)
        at
com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall (RemoteServiceServlet.java:
222)
        at
com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:
174)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at
com.google.gwt.dev.shell.GWTShellServlet.service(GWTShellServlet.java:
249)
        at javax.servlet.http.HttpServlet.service (HttpServlet.java:802)
        at com.gwtext.client.widgets.Button .<init>(Button.java:31)
        at sun.reflect.GeneratedMethodAccessor30.invoke (Unknown Source)

        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
        at
com.google.gwt.dev.shell.moz.MethodDispatch.invoke(MethodDispatch.java:
80)
        at org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(Native
Method)
        at org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(OS.java:
1428)
        at org.eclipse.swt.widgets.Display.readAndDispatch (Display.java:2840)

        at com.google.gwt.dev.GWTShell.pumpEventLoop(GWTShell.java:689)
        at com.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:442)
        at com.google.gwt.junit.JUnitShell.runTest (JUnitShell.java:167)

Maverick

unread,
Oct 9, 2007, 8:24:09 AM10/9/07
to GWT-Ext Developer Forum
Hi, Sanjiv... Thank you for message...

Please note that in log

==============================================


java.lang.ExceptionInInitializerError
at com.gwtext.client.widgets.Button.<init>(Button.java:31)

==============================================

This is the reason for the error ... If i remove GWT-Ext button - it
works, all well...
So far in the form of GWT-component - testing is not possible ...
If
If you want - i can send you very small project for testing...

If I use normal GWT-components - testing is OK ...

Maverick...


On Oct 9, 2:46 am, "Sanjiv Jivan" <sanjiv.ji...@gmail.com> wrote:
> Maverick,
> There's no indication in error that this is related to GWT-Ext. It appears
> related to your RPC call where your service is throwing an Exception and the
> Exception class does not have a default constructor. You can try removing
> all references to the GWT-Ext button and use a GWT button to confirm this.
>
> Sanjiv
>

> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

> > ApplicationFilterChain.java:
> > 237)
> > at
> > org.apache.catalina.core.ApplicationFilterChain.doFilter(
> > ApplicationFilterChain.java:
> > 157)
> > at
> > org.apache.catalina.core.StandardWrapperValve.invoke(
> > StandardWrapperValve.java:
> > 214)


> > at
> > org.apache.catalina.core.StandardValveContext.invokeNext(
> > StandardValveContext.java:
> > 104)
> > at
> > org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:
> > 520)
> > at

> > org.apache.catalina.core.StandardContextValve.invokeInternal(
> > StandardContextValve.java:
> > 198)
> > at
> > org.apache.catalina.core.StandardContextValve.invoke(
> > StandardContextValve.java:
> > 152)


> > at
> > org.apache.catalina.core.StandardValveContext.invokeNext(
> > StandardValveContext.java:
> > 104)
> > at
> > org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:

> > at com.gwtext.client.widgets.Button.<init>(Button.java:31)

> > DelegatingMethodAccessorImpl.java:
> > 25)
> > at
> > com.google.gwt.dev.shell.moz.MethodDispatch.invoke(MethodDispatch.java:
> > 80)
> > at org.eclipse.swt.internal.gtk.OS._g_main_context_iteration
> > (Native
> > Method)
> > at org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(
> > OS.java:
> > 1428)

> > at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java


> > :2840)
> > at com.google.gwt.dev.GWTShell.pumpEventLoop(GWTShell.java:689)
> > at com.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java
> > :442)
> > at com.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:167)
> > at
>

> ...
>
> read more »

Sanjiv Jivan

unread,
Oct 9, 2007, 8:38:27 AM10/9/07
to gwt...@googlegroups.com
ah, I see. I'll look into it an get back to you. I think you've created an issue in tracker for this so i'll just update the issue there.

On 10/9/07, Maverick <mav...@gmail.com> wrote:

Hi, Sanjiv... Thank you for message...

Please note that in log

==============================================
java.lang.ExceptionInInitializerError
        at com.gwtext.client.widgets.Button.<init>( Button.java:31)
> >         hello.getGreeting (index++, new AsyncCallback() {
> >         at javax.servlet.http.HttpServlet.service (HttpServlet.java:709)
> >         at com.gwtext.client.widgets.Button .<init>(Button.java:31)
> >         at com.google.gwt.junit.JUnitShell.runTest (JUnitShell.java:167)
> >         at
>
> ...
>
> read more »



Reply all
Reply to author
Forward
0 new messages