Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Junit GWTTestCase with SmartGwt

    i'm using SmartGwt for xpath.
    i'm able to execute the code successfully in webapplication.
    I have written a GWTTestcase to test this.
    when i run that testcase, it is failing in runtime by throwing runtime exception.

    could someone please help me in resolving this issue

    Here is my method to test:

    Code:
    public class Abc{
    public boolean isPasswordExpired() {
    
     String credentialXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><domain:user xmlns:domain=\"urn:vfi-sapphire:np.domain.2001-07-01\"><passwd expire=\"0\" days=\"-1234\" minLen=\"0\" maxLen=\"0\"/></domain:user>";
    
    Map<String, String> namespace = new HashMap<String, String>();
    		namespace.put("domain", "urn:vfi-sapphire:np.domain.2001-07-01");
    
    
    		String expire_string = XMLTools.selectString(credentialXML, "//domain:user/passwd/@expire",namespace);
    		String days_string = XMLTools.selectString(credentialXML, "//domain:user/passwd/@days",namespace);
    			int expire = Integer.parseInt(expire_string);
    			int days = Integer.parseInt(days_string);
    			if( expire == 1  && days <= 0 ){
    				return true;
    			}
    }
    }
    The following is my Testcase to test the above code:
    Code:
    public class AbcTest extents GWTTestCase{
    
            public void testisPasswordExpired(){
                  Abc abc = new Abc();
                  assertFalse("Test Failed" , abc.isPasswordExpired());
            }
    
    	public String getModuleName() {
    		return "com.abc.xyz";
    	}
    
    }


    here is the exception info:

    java.lang.RuntimeException: Remote test failed at 10.64.123.39 / Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.19) Gecko/2010031422 Firefox/3.0.19
    at com.google.gwt.junit.JUnitShell.processTestResult(JUnitShell.java:1288)
    at com.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1408)
    at com.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1309)
    at com.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:650)
    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 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)
    Caused by: java.lang.Exception: com.google.gwt.core.client.JavaScriptException: (null): null
    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:237)
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:132)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
    at com.smartgwt.client.data.XMLTools.selectString(XMLTools.java)
    .................. ........... ........................


    Thanks

    #2
    I get the exact same error. Mine happens when I make a DMI RPC call. It fails with the same error when I run a GWTTestCase. Anyone know why this happens?

    Comment


      #3
      This may suggest that GwtTestCase, which uses a fake HTMLUnit browser, cannot be used to run tests involving XML manipulation since it isn't a real browser.

      There is a notion of runStyle which might be used to force the test to run in a real browser.

      However, because of issues like the above we recommend focusing on Selenium testing rather than GwtTestCase.

      Comment


        #4
        Hello Isomorphic,

        I looking for a way to automate unit testing my Smartgwt application and most of the suggestions points to Selenium. I have not been successful at finding tutorials or samples on how to use Selenium. Can you direct me to some documentations?

        Thanks in advance,
        vnta

        Comment

        Working...
        X