google-code-export / gwt-test-utils

Automatically exported from code.google.com/p/gwt-test-utils
1 stars 0 forks source link

UnsatisfiedLinkError using VisualizationUtils.loadVisualizationApi #44

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.
public class MyTest extends GwtTest{

    private Dashboard dshbrd = null;
    private ServiceView view = null;
    private boolean loaded = false;

    @Override
    public String getModuleName() {
        return "org.ebayopensource.turmeric.monitoring.Console";
    }

    protected void loadApi(final Runnable testRunnable) {
        if (loaded) {
            testRunnable.run();
        }
        else {
            VisualizationUtils.loadVisualizationApi(new Runnable() {
                public void run() {
                    loaded = true;
                    try {
                        testRunnable.run();
                    }
                    catch (Exception e) {
                        e.printStackTrace();
                        Assert.fail();
                    }

                }
            }, "corechart");
        }
    }

    @Test
    public void testSetServiceCallTrendDataInHourlyData() {
        dshbrd = new DashboardContainer();
        view = new ServiceView(dshbrd);
        final List<TimeSlotData> graphData = createGraphData(1);

        loadApi(new Runnable() {
            public void run() {
                view.setServiceCallTrendData(graphData, 3600l, 1, "Test Service Call Graph Title");
            }
        });
    }

    private List<TimeSlotData> createGraphData(int dataPerHour) {
        long now = new Date().getTime();
        long oneMinute = 1000;// in milisecs
        List<TimeSlotData> graphData = new ArrayList<TimeSlotData>();
        TimeSlotData dataItem = null;
        TimeSlotValue plotValue = null;

        for (int i = 0; i < 2; i++) {
            dataItem = new TimeSlotData();
            dataItem.setReturnData(new ArrayList<TimeSlotValue>());
            for (int j = 0; j < dataPerHour; j++) {
                plotValue = new DummyTimeSlotValue("", (double) j, now + (oneMinute * j));
                dataItem.getReturnData().add(plotValue);
            }
            graphData.add(dataItem);
        }
        return graphData;

    }

What is the expected output? What do you see instead?
The test running successfully. What I get instead is this:

java.lang.UnsatisfiedLinkError: 
com.google.gwt.core.client.JsArrayString.set(ILjava/lang/String;)V
    at com.google.gwt.core.client.JsArrayString.set(Native Method)
    at com.google.gwt.ajaxloader.client.ArrayHelper.toJsArrayString(ArrayHelper.java:153)
    at com.google.gwt.visualization.client.VisualizationUtils.loadVisualizationApi(VisualizationUtils.java:30)
    at org.ebayopensource.turmeric.gwttestutils.MyTest.loadApi(MyTest.java:38)
    at org.ebayopensource.turmeric.gwttestutils.MyTest.testSetServiceCallTrendDataInHourlyData(MyTest.java:60)
    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:597)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at com.octo.gwt.test.GwtRunnerBase.run(GwtRunnerBase.java:63)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
    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)

What version of the product are you using? On what operating system?
I've tried this with 0.28 and 0.28-SNAPSHOT

Please provide any additional information below.
I'm trying to test some views that include graphs using the visualization API. 
The important call is VisualizationUtils.loadVisualizationApi(), which starts 
the graph rendering.

Original issue reported on code.google.com by mchi...@intalio.com on 31 May 2011 at 7:00

GoogleCodeExporter commented 9 years ago

Original comment by gael.laz...@gmail.com on 1 Jun 2011 at 8:17

GoogleCodeExporter commented 9 years ago
The gwt-google-api are not supported (yet) by gwt-test-utils.

In your case, you could easily provide a patcher to stub the 
VisualizationUtils.loadVisualizationAPi(..) method. It would be :

@PatchClass(VisualizationUtils.class)
public class VisualizationUtilsPatcher extends AutomaticPatcher {

  @PatchMethod
  public static void loadVisualizationApi(String version, Runnable onLoad,
      JsArrayString packages) {
      // do nothing instead of the orginial code
  }
}

JsArrayXXX, which are part of the GWT core API, are not patched yet. I'm gonna 
provide some support very soon, but I doubt it will be enough to get the 
visualization API fully working with gwt-test-utils...

Original comment by gael.laz...@gmail.com on 1 Jun 2011 at 11:51

GoogleCodeExporter commented 9 years ago
Hi,

I created a patcher as you suggested. I still get the same issue. I added log4j 
to see what patchers are being loaded and it seems the one I created is not 
being used. Is there any other config I need to add for this to work?

I checked here: 
http://code.google.com/p/gwt-test-utils/wiki/HowToWriteCustomPatchers but it 
doesn't contain much info.

Regards.

Original comment by mchi...@intalio.com on 1 Jun 2011 at 4:04

GoogleCodeExporter commented 9 years ago
My mistake, I forgot to tell you to create a META-INF/gwt-test-utils.properties 
file in your test classpath (src/test/resources if you are a maven user).
In this file, simply add this line :

your.package = scan-package

where your.package is the package of the VisualizationUtilsPatcher 

scan-package tells gwt-test-utils to scan a package, searching for @PatchClass 
to apply while loading classes.

Original comment by gael.laz...@gmail.com on 1 Jun 2011 at 10:38

GoogleCodeExporter commented 9 years ago
The corresponding wiki page will be updated soon, I promise !

Original comment by gael.laz...@gmail.com on 1 Jun 2011 at 10:38

GoogleCodeExporter commented 9 years ago
I just fixed the JsArrayString UnsatisfiedLinkError. It's available in the 
lastest 0.30-SNAPSHOT (for gwt 2.3.0) and 0.28.4-SNAPSHOT (for gwt 2.2.0).

But I'm not sure it will entirely solve the full Visualization API 
compatibility..

Original comment by gael.laz...@gmail.com on 3 Jun 2011 at 4:13

GoogleCodeExporter commented 9 years ago
Hi,

thanks for the quick update. Now, I'm using the 0.28.4-SNAPSHOT in another test 
(it also involves visualization code) and I have my VisualizationUtilsPatcher 
configured properly. This time I get this:

java.lang.NoClassDefFoundError: com/google/gwt/visualization/client/DataTable
    at org.ebayopensource.turmeric.monitoring.client.presenter.DashboardPresenter.initTabPresenters(DashboardPresenter.java:203)
    at org.ebayopensource.turmeric.monitoring.client.presenter.DashboardPresenter.<init>(DashboardPresenter.java:73)
    at org.ebayopensource.turmeric.monitoring.client.presenter.MenuController.initPresenters(MenuController.java:175)
    at org.ebayopensource.turmeric.monitoring.client.presenter.MenuController.<init>(MenuController.java:81)
    at org.ebayopensource.turmeric.monitoring.client.AppController.initPresenters(AppController.java:84)
    at org.ebayopensource.turmeric.monitoring.client.AppController.<init>(AppController.java:56)
    at org.ebayopensource.turmeric.monitoring.test.ServicePresenterTest.setUp(ServicePresenterTest.java:50)
    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:597)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at com.octo.gwt.test.GwtRunnerBase.run(GwtRunnerBase.java:63)
    at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:59)
    at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:115)
    at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:140)
    at org.apache.maven.surefire.Surefire.run(Surefire.java:109)
    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:597)
    at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:290)
    at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1017)
Caused by: java.lang.ClassNotFoundException: caught an exception while 
obtaining a class file for com.google.gwt.visualization.client.DataTable
    at javassist.Loader.findClass(Loader.java:359)
    at javassist.Loader.loadClass(Loader.java:311)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    ... 35 more
Caused by: com.octo.gwt.test.exceptions.GwtTestPatchException: Unable to 
compile body { return (com.google.gwt.visualization.client.DataTable) 
com.octo.gwt.test.internal.patchers.dom.JavaScriptObjects.getObject(this, 
"create"); }
    at com.octo.gwt.test.internal.utils.GwtPatcherUtils.replaceImplementation(GwtPatcherUtils.java:161)
    at com.octo.gwt.test.internal.utils.GwtPatcherUtils.patch(GwtPatcherUtils.java:94)
    at com.octo.gwt.test.internal.GwtTranslator.applyPatcher(GwtTranslator.java:83)
    at com.octo.gwt.test.internal.GwtTranslator.patchClass(GwtTranslator.java:119)
    at com.octo.gwt.test.internal.GwtTranslator.onLoad(GwtTranslator.java:38)
    at javassist.Loader.findClass(Loader.java:340)
    ... 37 more
Caused by: javassist.CannotCompileException: [source error] not-available: this
    at javassist.CtBehavior.setBody(CtBehavior.java:409)
    at javassist.CtBehavior.setBody(CtBehavior.java:375)
    at com.octo.gwt.test.internal.utils.GwtPatcherUtils.replaceImplementation(GwtPatcherUtils.java:159)
    ... 42 more
Caused by: compile error: not-available: this
    at javassist.compiler.CodeGen.atKeyword(CodeGen.java:1874)
    at javassist.compiler.ast.Keyword.accept(Keyword.java:34)
    at javassist.compiler.JvstCodeGen.atMethodArgs(JvstCodeGen.java:357)
    at javassist.compiler.MemberCodeGen.atMethodCallCore(MemberCodeGen.java:555)
    at javassist.compiler.MemberCodeGen.atCallExpr(MemberCodeGen.java:523)
    at javassist.compiler.JvstCodeGen.atCallExpr(JvstCodeGen.java:243)
    at javassist.compiler.ast.CallExpr.accept(CallExpr.java:45)
    at javassist.compiler.CodeGen.checkCastExpr(CodeGen.java:1389)
    at javassist.compiler.CodeGen.atCastExpr(CodeGen.java:1363)
    at javassist.compiler.JvstCodeGen.atCastExpr(JvstCodeGen.java:177)
    at javassist.compiler.ast.CastExpr.accept(CastExpr.java:54)
    at javassist.compiler.CodeGen.compileExpr(CodeGen.java:229)
    at javassist.compiler.CodeGen.atReturnStmnt2(CodeGen.java:597)
    at javassist.compiler.JvstCodeGen.atReturnStmnt(JvstCodeGen.java:424)
    at javassist.compiler.CodeGen.atStmnt(CodeGen.java:362)
    at javassist.compiler.ast.Stmnt.accept(Stmnt.java:49)
    at javassist.compiler.CodeGen.atStmnt(CodeGen.java:350)
    at javassist.compiler.ast.Stmnt.accept(Stmnt.java:49)
    at javassist.compiler.CodeGen.atMethodBody(CodeGen.java:291)
    at javassist.compiler.Javac.compileBody(Javac.java:222)
    at javassist.CtBehavior.setBody(CtBehavior.java:401)
    ... 44 more

I checked my config (I'm using maven3), and it seems I have my jar in the 
classpath. Perhaps if I add another Patcher it could do the trick?. If not, I 
might have to simply skip that part in the tests for now.

Any thoughts?

Regards.

Original comment by mchi...@intalio.com on 3 Jun 2011 at 10:04

GoogleCodeExporter commented 9 years ago
I improved this stack trace so I could figured out the problem easier.
Could you please update to the lastest 0.28.4-SNAPSHOT and rerun your test to 
post the new stack trace ? 

Thank you very much ! 

Original comment by gael.laz...@gmail.com on 5 Jun 2011 at 6:18

GoogleCodeExporter commented 9 years ago
Note that the patcher wiki page has been updated : 
http://code.google.com/p/gwt-test-utils/wiki/HowToWriteCustomPatchers

Original comment by gael.laz...@gmail.com on 23 Jun 2011 at 8:52

GoogleCodeExporter commented 9 years ago

Original comment by gael.laz...@gmail.com on 29 Nov 2011 at 2:54