1. #1
    Sencha User
    Join Date
    Jan 2010
    Posts
    132
    Answers
    2
    Vote Rating
    1
    darkling235 is on a distinguished road

      0  

    Default Answered: Junit Nullpointer

    Answered: Junit Nullpointer


    I'm trying to run a simple Junit test but I can't create a Window.
    Literally I'm just doing new Window() but it throws a nullpointer. I single stepped through it and discovered the line where its null:

    Code:
        XElement headerElem = appearance.getHeaderElem(getElement());
        headerElem.appendChild(header.getElement());
    The headerElem in ContentPanel (Window's superclass) is null for some reason. I haven't altered the appearence code or anything. As far as I can tell the classpath is accurate. The ContentAppearance specifically returns null a few levels deeper, inside the getHeaderElem method in XElement's selectNode method.

    Code:
      /**
       * Selects a single element.
       * 
       * @param selector the CSS selector
       * @return the matching element or null if no match
       */
      public final XElement selectNode(String selector) {
        Element el = DomQuery.selectNode(selector, this);
        if (el != null) {
          return XElement.as(el);
        }
        return null;
      }

    This is a larger chunk of the relevant code from Content Panel.
    Code:
    public ContentPanel(ContentPanelAppearance appearance) {
        super(true);
        this.appearance = appearance;
    
        setDeferHeight(true);
    
        SafeHtmlBuilder sb = new SafeHtmlBuilder();
        appearance.render(sb);
    
        setElement(XDOM.create(sb.toSafeHtml()));
    
        header = new Header(appearance.getHeaderAppearance());
        ComponentHelper.setParent(this, header);
    
        XElement headerElem = appearance.getHeaderElem(getElement());
        headerElem.appendChild(header.getElement());
    
        buttonBar = new ButtonBar();
        buttonBar.setMinButtonWidth(75);
        buttonBar.setPack(BoxLayoutPack.END);
    I have no idea why or what to do next to debug it. It's worth pointing out the same code works when run normally. I've checked into this being a classpath issue but I'm not sure why the elements would be built or accessed differently between a normal run and a Junit test. If anyone has any suggestions I'd be most appreciative.
    Thanks

  2. Are you using GWT 2.5? It turns out that in GWT 2.5.0 they updated the version of HtmlUnit used internally such that some calls made to the 'browser' no longer function correctly. In this case, we are specifically interested in getElementsByTagNameNS('*','*').

    If so, I have two suggestions:
    * Run unit tests with GWT 2.4
    * Run unit tests in a real browser (check out https://developers.google.com/web-to...evGuideTesting for some more details about running via manual, selenium, and RMI)

    I'm working to see if another HtmlUnit version might work instead, or if we can make a change in GWT 2.5.1 or later to allow this feature to work again, but don't yet have any concrete answers in that direction yet.

  3. #2
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,634
    Answers
    107
    Vote Rating
    79
    Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice

      0  

    Default


    Are you using GWT 2.5? It turns out that in GWT 2.5.0 they updated the version of HtmlUnit used internally such that some calls made to the 'browser' no longer function correctly. In this case, we are specifically interested in getElementsByTagNameNS('*','*').

    If so, I have two suggestions:
    * Run unit tests with GWT 2.4
    * Run unit tests in a real browser (check out https://developers.google.com/web-to...evGuideTesting for some more details about running via manual, selenium, and RMI)

    I'm working to see if another HtmlUnit version might work instead, or if we can make a change in GWT 2.5.1 or later to allow this feature to work again, but don't yet have any concrete answers in that direction yet.

  4. #3
    Sencha User
    Join Date
    Jan 2010
    Posts
    132
    Answers
    2
    Vote Rating
    1
    darkling235 is on a distinguished road

      0  

    Default


    I am using SDK 2.5 but it doesn't seem to work. I've tried running it in Prod mode but nothing happens. It just sits there and eventually everything times out. I attempted to create a barebones project that doesn't use GXT and see what happens but this failed to run as well.
    Code:
    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)
    which makes me suspect in addition to some issues with GXT my eclipse may not be configured to properly run the JUNIT tests.


    I finally managed to get things to run by working in prod and Manual mode.
    After setting it to prod things still didn't work until I added
    Code:
    -Dgwt.args="-runStyle Manual:1"
    to the VM args. Then it produced a url that let me send me browser there and upon connection, ran my unit tests. I'm not sure why this was necessary or what the extremely round about approach means but it is working

  5. #4
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,634
    Answers
    107
    Vote Rating
    79
    Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice

      0  

    Default


    Sorry if I wasn't clear - this is a regression introduced in GWT 2.5 that isn't present in GWT 2.4. You should try with GWT 2.4.0 - if it works, you are likely facing this bug.

    Production mode will not help - HtmlUnit is unable to run a method that is necessary.

    As you've noted, running in a real browser will work, but can be messy, especially when trying to run from an automated build server. I'm looking into some other GWT changes that might make that process easier, but doesn't change the fact that GWT 2.5.0's HtmlUnit can't run many GXT widgets.

  6. #5
    Sencha User
    Join Date
    Jan 2010
    Posts
    132
    Answers
    2
    Vote Rating
    1
    darkling235 is on a distinguished road

      0  

    Default


    Tried subbing in 2.4 but no go. Possibly a classloader conflict which I'll dig into shortly

    Code:
    java.lang.NoSuchMethodError: com.google.gwt.dev.util.arg.ArgHandlerEnableGeneratorResultCaching.<init>(Lcom/google/gwt/dev/util/arg/OptionEnableGeneratorResultCaching;)V
        at com.google.gwt.junit.JUnitShell$ArgProcessor.<init>(JUnitShell.java:194)
        at com.google.gwt.junit.JUnitShell.getUnitTestShell(JUnitShell.java:694)
        at com.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:653)
        at com.google.gwt.junit.client.GWTTestCase.runTest(GWTTestCase.java:441)
        at junit.framework.TestCase.runBare(TestCase.java:130)
        at junit.framework.TestResult$1.protect(TestResult.java:106)
        at junit.framework.TestResult.runProtected(TestResult.java:124)
        at junit.framework.TestResult.run(TestResult.java:109)
        at junit.framework.TestCase.run(TestCase.java:120)
        at com.google.gwt.junit.client.GWTTestCase.run(GWTTestCase.java:296)
        at junit.framework.TestSuite.runTest(TestSuite.java:230)
        at junit.framework.TestSuite.run(TestSuite.java:225)
        at junit.framework.TestSuite.runTest(TestSuite.java:230)
        at junit.framework.TestSuite.run(TestSuite.java:225)
        at junit.framework.TestSuite.runTest(TestSuite.java:230)
        at junit.framework.TestSuite.run(TestSuite.java:225)
        at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
        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)

  7. #6
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,634
    Answers
    107
    Vote Rating
    79
    Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice

      0  

    Default


    Code:
    ArgHandlerEnableGeneratorResultCaching
    Almost certainly a jar version issue - this class had the listed constructor in 2.4, but in 2.5, we see this:
    Code:
    /**
     * An ArgHandler to provide the -XenableGeneratorResultCaching flag.
     * 
     * Note: This is no longer needed since generator result caching is now enabled by default.
     * It's left here for an interim period, so that uses of the flag can be removed.
     * TODO(jbrosenberg): remove this after interim period.
     */
    public class ArgHandlerEnableGeneratorResultCaching extends ArgHandlerFlag {
    
      public ArgHandlerEnableGeneratorResultCaching() {
      }

  8. #7
    Sencha User
    Join Date
    Jan 2010
    Posts
    132
    Answers
    2
    Vote Rating
    1
    darkling235 is on a distinguished road

      0  

    Default


    Yes it took me a while but I finally straightened out all the classloader issues and got the junit working. For anyone else struggling with this remember to change the libary definitions in the eclipse's junit run config classpath as well as the code.

Thread Participants: 1

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar