8 Replies Latest reply on Jun 18, 2008 10:42 PM by 807591

    Exception while running junit test case

    807591
      Hi

      Am writing a ControlTestCase that extends junit. This is to test a control . When i have the test case and teh control to be tested am not getting any exceptions but when the test case(ControlTestCase) is is a different project am gettign this trace

      org.apache.beehive.controls.test.ControlTestException: Exception initializing controls for type 'SharedControl.src.SimpleTestCase'
           at org.apache.beehive.controls.test.util.ControlContainerContextManager.instantiateControls(ControlContainerContextManager.java:49)
           at org.apache.beehive.controls.test.junit.ControlTestCase.initializeControls(ControlTestCase.java:66)
           at org.apache.beehive.controls.test.junit.ControlTestCase.setUp(ControlTestCase.java:46)
           at junit.framework.TestCase.runBare(TestCase.java:125)
           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:118)
           at junit.framework.TestSuite.runTest(TestSuite.java:208)
           at junit.framework.TestSuite.run(TestSuite.java:203)
           at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
           at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
           at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
      Caused by: java.lang.ClassNotFoundException: SharedControl.src.SimpleTestCaseClientInitializer
           at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
           at java.security.AccessController.doPrivileged(Native Method)
           at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
           at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
           at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
           at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
           at org.apache.beehive.controls.api.bean.Controls.initializeClient(Controls.java:131)
           at org.apache.beehive.controls.test.util.ControlContainerContextManager.instantiateControls(ControlContainerContextManager.java:44)
           ... 12 more
        • 1. Re: Exception while running junit test case
          791266
          What do you think this means?
          Caused by: java.lang.ClassNotFoundException: SharedControl.src.SimpleTestCaseClientInitializer
          Check your classpath.

          Kaj
          • 2. Re: Exception while running junit test case
            807591
            The Class should be generated while am running the test case.

            But itts not happening
            • 3. Re: Exception while running junit test case
              800322
              I can't shake the feeling that it means something slightly different; some IDE misconfiguration and other mess-up. It's trying to use the project's source directory as a classpath. Maybe because the class in question has no package defined? It'd also lead to importing problems if the tests are not in the default package, too.
              • 4. Re: Exception while running junit test case
                791266
                CeciNEstPasUnProgrammeur wrote:
                I can't shake the feeling that it means something slightly different; some IDE misconfiguration and other mess-up. It's trying to use the project's source directory as a classpath. Maybe because the class in question has no package defined? It'd also lead to importing problems if the tests are not in the default package, too.
                That could be the case.

                @Op. Is the class placed within a package?
                • 5. Re: Exception while running junit test case
                  800322
                  Sorry, I mean "it's using the source dir as package". Can't edit my post. :p

                  Try using a real package.
                  • 6. Re: Exception while running junit test case
                    807591
                    Even I have got the same error:
                    ----------------------------------------------------------
                    org.apache.beehive.controls.test.ControlTestException: Exception initializing controls for type 'sharedcontrols.tests.EmployeeControlTestCase'
                         at org.apache.beehive.controls.test.util.ControlContainerContextManager.instantiateControls(ControlContainerContextManager.java:49)
                         at org.apache.beehive.controls.test.junit.ControlTestCase.initializeControls(ControlTestCase.java:66)
                         at org.apache.beehive.controls.test.junit.ControlTestCase.setUp(ControlTestCase.java:46)
                         at junit.framework.TestCase.runBare(TestCase.java:125)
                         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:118)
                         at junit.framework.TestSuite.runTest(TestSuite.java:208)
                         at junit.framework.TestSuite.run(TestSuite.java:203)
                         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
                         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
                         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
                    Caused by: java.lang.ClassNotFoundException: sharedcontrols.tests.EmployeeControlTestCaseClientInitializer
                         at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
                         at java.security.AccessController.doPrivileged(Native Method)
                         at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
                         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
                         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
                         at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
                         at org.apache.beehive.controls.api.bean.Controls.initializeClient(Controls.java:131)
                         at org.apache.beehive.controls.test.util.ControlContainerContextManager.instantiateControls(ControlContainerContextManager.java:44)
                         ... 12 more


                    ----------------------------------------------------------


                    If I try to run a JUNIT test class inside a java project (Weblogic 9.2 IDE), I am getting the same exception.
                    The 'Control' classes are inside the 'UTILITY' project (one of the projects while we create a WLI process project).

                    Any clues please !!

                    NOTE: If I place the same controls under a standalone 'UTILITY' project, the test class works fine.
                    • 7. Re: Exception while running junit test case
                      807591
                      Got the solution.....
                      We need to enable the 'Annotation Processor' and add some of the relevant Beehive controls under Factory path (Weblogic 9.2 IDE).

                      It works fine....Thank you.
                      • 8. Re: Exception while running junit test case
                        807591
                        I am having same error. Can you please elaborate on how to enable the "Annotation Processor" and which jars need to be on classpath?