google-code-export / gwt-test-utils

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

I am getting the duplicate method and signature issue with the following stack trace... #125

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Just a simple test case to run our tests.
2. We are using ExtJs in our project also.
3. When we try to run the test, the javaassist loader is complaining.

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

java.lang.ClassFormatError: Duplicate method name&signature in class file 
com/extjs/gxt/ui/client/widget/Layout
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(Unknown Source)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at javassist.Loader.findClass(Loader.java:380)
    at javassist.Loader.loadClass(Loader.java:312)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at com.jpmorgan.chui.entry.supersecretbackdoor.ChuiNewTest.setupNewChuiTest(ChuiNewTest.java:19)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    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.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at com.octo.gwt.test.internal.runner.AbstractGwtRunner.run(AbstractGwtRunner.java:40)
    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)

What version of the product are you using? On what operating system?

The latest 0.36

Please provide any additional information below.

N/A

Original issue reported on code.google.com by bejua...@gmail.com on 12 Mar 2012 at 10:27

GoogleCodeExporter commented 9 years ago
Your problem come from the GXT's Layout class, but I guess you didn't add the 
gwt-test-utils-gxt.jar dependency in your test classpath, am I right ?

Original comment by gael.laz...@gmail.com on 13 Mar 2012 at 6:10

GoogleCodeExporter commented 9 years ago
Gael,

Thanks for the quick response. Since I am new to GWT, its kind of taking me 
time to get familiarized with this. You are correct that adding 
gwt-test-utils-gxt.jar has got rid of that original issue. Now it seems to be 
asking me to create a field which is declared final private in one of my 
classes. 

I am trying to set it using reflection and it does not like this. Its asking me 
to use addGwtCreateHandler to set this object.

The code I used to set this object is given below:

    @Before
    public void setupChuiTest() throws SecurityException, NoSuchFieldException {
        chuiApp = new Chui();
        chuiApp.onModuleLoad();
        Field userServiceProxy = chuiApp.getClass().getDeclaredField("userServiceProxy");
        userServiceProxy.setAccessible(true);
        userServiceProxy = GWT
                .create(UserServiceRestProxy.class);
        Assert.assertTrue(chuiApp != null);
    }

com.octo.gwt.test.exceptions.GwtTestConfigurationException: A custom Generator 
should be used to instanciate 
'com.jpmorgan.chui.client.services.user.UserServiceRestProxy', but 
gwt-test-utils does not support GWT compiler API, so you have to add our own 
GwtCreateHandler with 'GwtTest.addGwtCreateHandler(..)' method or to declare 
your tested object with @Mock
    at com.octo.gwt.test.internal.handlers.DeferredGenerateWithCreateHandler.create(DeferredGenerateWithCreateHandler.java:21)
    at com.octo.gwt.test.internal.patchers.GwtPatcher.create(GwtPatcher.java:22)
    at com.google.gwt.core.client.GWT.create(GWT.java)
    at com.jpmorgan.chui.entry.supersecretbackdoor.Chui.<init>(Chui.java:107)
    at com.jpmorgan.chui.entry.supersecretbackdoor.ChuiTest.setupNewChuiTest(ChuiTest.java:30)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    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.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at com.octo.gwt.test.internal.runner.AbstractGwtRunner.run(AbstractGwtRunner.java:40)
    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)

Original comment by bejua...@gmail.com on 13 Mar 2012 at 1:52

GoogleCodeExporter commented 9 years ago
I think you didn't get something here.

I guess your Chui.userServiceProxy field is initialized with a 
"GWT.create(UserServiceRestProxy)" instruction, right ? (private final 
UserServiceResetProxy userServiceProxy = GWT.create(UserServiceRestProxy);)

Your approach is not right : gwt-test-utils complains because it cannot 
instanciate the UserServiceRestProxy (which must be an interface ?) and it 
knows that you're using a custom GWT code generator to create an implementation 
of this interface.

Like the error message says, you have 2 options :

1) Mock the 'userServiceProxy' instance with EasyMock or Mockito (see here : 
http://code.google.com/p/gwt-test-utils/wiki/MockingClasses)

2) write your own Java implementation of the UserServiceRestProxy and register 
your GwtCreateHandler to provide an instance of it whenever a call to 
GWT.create(UserServiceRestProxy.class) is made.
For example :

private class UserServiceRestProxyCreateHandler implements GwtCreateHandler {

    public Object create(Class<?> classLiteral) throws Exception {
         if (!UserServiceRestProxy.class.isAssignableFrom(classLiteral)) {
         // the UserServiceRestProxy is not suited to provide an instance of this classLiteral
         return null;
      }

    // return a custom implementation :)
    return new MyUserServiceRestProxyImplForTest();
  }
}

in the setup method of your unit test, I'd need to register this 
UserServiceRestProxyCreateHandler :

    @Before
    public void setupChuiTest() throws SecurityException, NoSuchFieldException {

               // register
               this.addGwtCreateHandler(new UserServiceRestProxyCreateHandler());

        chuiApp = new Chui();
        chuiApp.onModuleLoad();

    }

HTH

Original comment by gael.laz...@gmail.com on 13 Mar 2012 at 2:22

GoogleCodeExporter commented 9 years ago
I see this comment in console.

gwt-test-utils fake navigator user-agent

Original comment by bejua...@gmail.com on 13 Mar 2012 at 2:50

GoogleCodeExporter commented 9 years ago
Don't worry about it, this is a GXT notification which isn't relevant

Original comment by gael.laz...@gmail.com on 13 Mar 2012 at 3:14

GoogleCodeExporter commented 9 years ago
This error happens when a modal window is shown like loginModal.show() command.
It looks like the extjs.ContentPanel.getFrameSize() is returning nulls. The 
code inside the extjs is shown below:

    FastMap<String> map = getStyleAttribute(list);
    for (String s : map.keySet()) {
      if (isLeftorRight(s)) {
        width += Util.parseFloat(map.get(s), 0);
      } else {
        height += Util.parseFloat(map.get(s), 0);
      }
    }
    return new Size((int) Math.round(width), (int) Math.round(height));

  public FastMap<String> getStyleAttribute(List<String> attr) {
    return computedStyle.getStyleAttribute(dom, attr);
  }

In the above code at the point of height += Util.parseFloat(...) it fails.
Is this supported with the gwt-test-utils framework.

java.lang.UnsatisfiedLinkError: 
com.extjs.gxt.ui.client.util.Util.parseFloat(Ljava/lang/String;F)F
    at com.extjs.gxt.ui.client.util.Util.parseFloat(Native Method)
    at com.extjs.gxt.ui.client.core.El.getFrameSize(El.java:1083)
    at com.extjs.gxt.ui.client.widget.ContentPanel.getFrameSize(ContentPanel.java:877)
    at com.extjs.gxt.ui.client.widget.ContentPanel.onResize(ContentPanel.java:1164)
    at com.extjs.gxt.ui.client.widget.BoxComponent.setSize(BoxComponent.java:509)
    at com.extjs.gxt.ui.client.widget.BoxComponent.setSize(BoxComponent.java:559)
    at com.extjs.gxt.ui.client.widget.BoxComponent.afterRender(BoxComponent.java:685)
    at com.extjs.gxt.ui.client.widget.ScrollContainer.afterRender(ScrollContainer.java:199)
    at com.extjs.gxt.ui.client.widget.Component.render(Component.java:1111)
    at com.extjs.gxt.ui.client.widget.Component.onAttach(Component.java:1637)
    at com.extjs.gxt.ui.client.widget.Container.onAttach(Container.java:470)
    at com.google.gwt.user.client.ui.Widget.setParent(Widget.java:475)
    at com.google.gwt.user.client.ui.Panel.adopt(Panel.java:127)
    at com.google.gwt.user.client.ui.ComplexPanel.add(ComplexPanel.java:97)
    at com.google.gwt.user.client.ui.AbsolutePanel.add(AbsolutePanel.java:97)
    at com.extjs.gxt.ui.client.widget.Window.show(Window.java:917)
    at com.jpmorgan.chui.entry.supersecretbackdoor.Chui.showLoginModalWindow(Chui.java:176)
    at com.jpmorgan.chui.entry.supersecretbackdoor.Chui.onModuleLoad(Chui.java:157)
    at com.jpmorgan.chui.entry.supersecretbackdoor.ChuiTest.setupNewChuiTest(ChuiTest.java:69)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    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.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at com.octo.gwt.test.internal.runner.AbstractGwtRunner.run(AbstractGwtRunner.java:40)
    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)

Original comment by bejua...@gmail.com on 13 Mar 2012 at 8:18

GoogleCodeExporter commented 9 years ago
Ok I'll fix this asap.

Original comment by gael.laz...@gmail.com on 13 Mar 2012 at 10:04

GoogleCodeExporter commented 9 years ago
Thanks for your  response Gael. Thank you for being supportive and responding 
to issues quickly.

Original comment by bejua...@gmail.com on 14 Mar 2012 at 4:33

GoogleCodeExporter commented 9 years ago
Any updates on this gael...
 On Mar 13, 2012 5:05 PM, <gwt-test-utils@googlecode.com> wrote:

Original comment by bejua...@gmail.com on 14 Mar 2012 at 1:24

GoogleCodeExporter commented 9 years ago
I can't work on this right now, I'll do this this evening at home ;)

But Which version of GXT are you using ? I can't see any Util.parseFloat(..) 
method in GXT 2.2.4

Original comment by gael.laz...@gmail.com on 14 Mar 2012 at 2:11

GoogleCodeExporter commented 9 years ago
I am using GXT 2.2.5

Original comment by bejua...@gmail.com on 14 Mar 2012 at 2:39

GoogleCodeExporter commented 9 years ago
Do you have a timeframe gael on when this bug will be fixed. Just wanted to 
find out as we are planning to convey this to our management. Sorry again and I 
know that this is something that you do in your freetime, so just wanted to get 
an idea.

Thanks
Sudhir

Original comment by bejua...@gmail.com on 15 Mar 2012 at 9:06

GoogleCodeExporter commented 9 years ago
I'll fix this in a couple of day since I'm really busy on other stuff right 
now. But maybe you could patch the Util.parseFloat method on your own, this 
won't be so difficult to do. Please read this wiki page : 

http://code.google.com/p/gwt-test-utils/wiki/HowToWriteCustomPatchers

so, your custom patcher should be something like : 

@PatchClass(Util.class)
class UtilPatcher {

  @PatchMethod
  static float parseFloat(String value, int defaultValue) {
    // return whatever you want here;
  }

}

Original comment by gael.laz...@gmail.com on 15 Mar 2012 at 9:55

GoogleCodeExporter commented 9 years ago
I did patch these methods parseFloat and parseInt in patcher class and it now 
complains about something else. Here is the stack trace. 

java.lang.NullPointerException
    at com.extjs.gxt.ui.client.core.Template.insert(Template.java:167)
    at com.extjs.gxt.ui.client.widget.layout.FormLayout.renderField(FormLayout.java:335)
    at com.extjs.gxt.ui.client.widget.layout.FormLayout.renderComponent(FormLayout.java:308)
    at com.extjs.gxt.ui.client.widget.Layout.renderAll(Layout.java:352)
    at com.extjs.gxt.ui.client.widget.Layout.onLayout(Layout.java:318)
    at com.extjs.gxt.ui.client.widget.layout.AnchorLayout.onLayout(AnchorLayout.java:99)
    at com.extjs.gxt.ui.client.widget.layout.FormLayout.onLayout(FormLayout.java:267)
    at com.extjs.gxt.ui.client.widget.Layout.layout(Layout.java:114)
    at com.extjs.gxt.ui.client.widget.Layout$3.handleEvent(Layout.java:170)
    at com.extjs.gxt.ui.client.util.DelayedTask$1.run(DelayedTask.java:30)
    at com.extjs.gxt.ui.client.util.DelayedTask.delay(DelayedTask.java:52)
    at com.extjs.gxt.ui.client.widget.Layout.onResize(Layout.java:344)
    at com.extjs.gxt.ui.client.widget.Layout$2.handleEvent(Layout.java:135)
    at com.extjs.gxt.ui.client.widget.Layout$2.handleEvent(Layout.java:129)
    at com.extjs.gxt.ui.client.event.BaseObservable.callListener(BaseObservable.java:178)
    at com.extjs.gxt.ui.client.event.BaseObservable.fireEvent(BaseObservable.java:86)
    at com.extjs.gxt.ui.client.widget.Component.fireEvent(Component.java:456)
    at com.extjs.gxt.ui.client.widget.BoxComponent.setSize(BoxComponent.java:522)
    at com.extjs.gxt.ui.client.widget.BoxComponent.setSize(BoxComponent.java:559)
    at com.extjs.gxt.ui.client.widget.BoxComponent.afterRender(BoxComponent.java:685)
    at com.extjs.gxt.ui.client.widget.ScrollContainer.afterRender(ScrollContainer.java:199)
    at com.extjs.gxt.ui.client.widget.Component.render(Component.java:1111)
    at com.extjs.gxt.ui.client.widget.Component.onAttach(Component.java:1637)
    at com.extjs.gxt.ui.client.widget.Container.onAttach(Container.java:470)
    at com.google.gwt.user.client.ui.Widget.setParent(Widget.java:475)
    at com.google.gwt.user.client.ui.Panel.adopt(Panel.java:127)
    at com.google.gwt.user.client.ui.ComplexPanel.add(ComplexPanel.java:97)
    at com.google.gwt.user.client.ui.AbsolutePanel.add(AbsolutePanel.java:97)
    at com.extjs.gxt.ui.client.widget.Window.show(Window.java:917)
    at com.jpmorgan.chui.entry.supersecretbackdoor.Chui.showLoginModalWindow(Chui.java:174)
    at com.jpmorgan.chui.entry.supersecretbackdoor.Chui.onModuleLoad(Chui.java:157)
    at com.jpmorgan.chui.entry.supersecretbackdoor.ChuiTest.setupNewChuiTest(ChuiTest.java:68)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    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.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at com.octo.gwt.test.internal.runner.AbstractGwtRunner.run(AbstractGwtRunner.java:40)
    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)

Original comment by bejua...@gmail.com on 16 Mar 2012 at 2:27

GoogleCodeExporter commented 9 years ago
If you don't care about testing your widget's sizes, I'll suggest you to patch 
the com.extjs.gxt.ui.client.widget.BoxComponent.setSize(..) method with an 
empty @PatchMethod because GXT does a lot of things (animations etc) while 
resizing.

Original comment by gael.laz...@gmail.com on 16 Mar 2012 at 2:32

GoogleCodeExporter commented 9 years ago
The code where its failing is given below:

This is in Template.class (com.extjs.gxt.ui.client.core.Template)

  /**
   * Applies the supplied values to the template and inserts the new node(s) at
   * the given index.
   * 
   * @param el the context element
   * @param index the insert index
   * @param values the values
   * @return the new element
   */
  public Element insert(Element el, int index, Params values) {
    int count = DOM.getChildCount(el);
    Element before = el.getChildNodes().getItem(index).cast();
    if (count == 0 || before == null) {
      return appendInternal(t, el, values.getValues());
    } else {
      return insertBefore(before, values);
    }
  }

Original comment by bejua...@gmail.com on 16 Mar 2012 at 3:15

GoogleCodeExporter commented 9 years ago
As per your comment, the setSize method is not static, how would you patch this 
method if its not static and its complaining that it has to be static

java.lang.ExceptionInInitializerError
    at com.octo.gwt.test.internal.runner.AbstractGwtRunnerFactory.newInstance(AbstractGwtRunnerFactory.java:52)
    at com.octo.gwt.test.internal.runner.AbstractGwtRunnerFactory.create(AbstractGwtRunnerFactory.java:32)
    at com.octo.gwt.test.internal.runner.AbstractGwtRunner.<init>(AbstractGwtRunner.java:24)
    at com.octo.gwt.test.GwtRunner.<init>(GwtRunner.java:19)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:31)
    at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
    at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
    at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:33)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:33)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestMethodReference.<init>(JUnit4TestMethodReference.java:25)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:54)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
    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)
Caused by: com.octo.gwt.test.exceptions.GwtTestPatchException: 
@com.octo.gwt.test.patchers.PatchMethod has to be static : 
'com.jpmorgan.chui.client.gwtpatchers.GxtBoxComponentPatcher.setSize(int,int)'
    at com.octo.gwt.test.internal.AutomaticPatcher.getPatchMethods(AutomaticPatcher.java:237)
    at com.octo.gwt.test.internal.AutomaticPatcher.<init>(AutomaticPatcher.java:51)
    at com.octo.gwt.test.internal.PatcherFactory.createPatcher(PatcherFactory.java:47)
    at com.octo.gwt.test.internal.PatcherFactory.<init>(PatcherFactory.java:22)
    at com.octo.gwt.test.internal.ConfigurationLoader.visitPatchClasses(ConfigurationLoader.java:241)
    at com.octo.gwt.test.internal.ConfigurationLoader.<init>(ConfigurationLoader.java:81)
    at com.octo.gwt.test.internal.ConfigurationLoader.createInstance(ConfigurationLoader.java:42)
    at com.octo.gwt.test.internal.GwtClassLoader.<init>(GwtClassLoader.java:53)
    at com.octo.gwt.test.internal.GwtClassLoader.<clinit>(GwtClassLoader.java:36)
    ... 23 more

Original comment by bejua...@gmail.com on 16 Mar 2012 at 3:22

GoogleCodeExporter commented 9 years ago
This is explained in the wiki page I suggested you to read, espacially in the 
"5." of the paragraph 
http://code.google.com/p/gwt-test-utils/wiki/HowToWriteCustomPatchers#Writing_a_
custom_patcher

Also, thank you for pointed me out GXT Template.insert(..) source code, but I 
already had a look at it ;)

Original comment by gael.laz...@gmail.com on 16 Mar 2012 at 3:26

GoogleCodeExporter commented 9 years ago
Gael.. When I write the gwt tests, the @Before method does apply to each one of 
the tests or it does not. Say I have two @Test methods and one @Before method, 
does the @Before method gets executed for each testcase or just once for the 
whole class.

Original comment by bejua...@gmail.com on 20 Mar 2012 at 3:06

GoogleCodeExporter commented 9 years ago
The standard behaviour of JUnit is not modified : @Before methods are execute 
before each @Test method.
If you need a method which would be executed only one time, you have to use 
@BeforeClass and to make it static..

Original comment by gael.laz...@gmail.com on 20 Mar 2012 at 5:27

GoogleCodeExporter commented 9 years ago
Did you manage to patch the Util.parseFloat method already ?

Original comment by gael.laz...@gmail.com on 22 Mar 2012 at 2:44

GoogleCodeExporter commented 9 years ago
Yes that works for me now as I patched it already.

Original comment by bejua...@gmail.com on 28 Mar 2012 at 7:17

GoogleCodeExporter commented 9 years ago
Glad to read that ! I'm closing this issue ;)

Original comment by gael.laz...@gmail.com on 28 Mar 2012 at 7:24

GoogleCodeExporter commented 9 years ago

Original comment by gael.laz...@gmail.com on 28 Mar 2012 at 7:24