1 2 3 4 5 6 Previous Next 80 Replies Latest reply on Dec 14, 2009 4:50 PM by alesj Go to original post
      • 45. Re: Testing Deployers with new Reflect + ClassPool
        alesj

         

        "flavia.rainone@jboss.com" wrote:

        Ales, you mentioned on a private chat that jboss-classpool should not use VFS because that would result in a circular dependency. Have you taken a look at the class pool tests? They already use VFS stuff, even though the pom doesn't declare any direct dependency to VFS. I wonder if those tests are ok or if I'll have to "fix" them, by removing the VFS part.

        No, I meant Deployers-VFS.
        Using VFS is of course fine, as it helps you assemble archives to test.

        • 46. Re: Testing Deployers with new Reflect + ClassPool
          flavia.rainone

          The tests have been ported:
          https://jira.jboss.org/jira/browse/JBREFLECT-73.

          To make sure I didn't miss anything..... could you please check those tests, Ales?

          • 47. Re: Testing Deployers with new Reflect + ClassPool
            alesj

             

            "flavia.rainone@jboss.com" wrote:
            could you please check those tests, Ales?

            Getting this failure:
            -------------------------------------------------------------------------------
            Test set: org.jboss.test.classpool.jbosscl.test.RepositoryClassPoolTestCase
            -------------------------------------------------------------------------------
            Tests run: 18, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 16.469 sec <<< FAILURE!
            testURLChildOfGlobalUcl(org.jboss.test.classpool.jbosscl.test.RepositoryClassPoolTestCase) Time elapsed: 0.109 sec <<< ERROR!
            java.lang.NullPointerException
             at org.jboss.test.classpool.support.TestScenario.assertLoadClass(TestScenario.java:315)
             at org.jboss.test.classpool.support.ClassPoolTestScenario.loadClass(ClassPoolTestScenario.java:78)
             at org.jboss.test.classpool.support.ClassPoolTestScenario.loadClass(ClassPoolTestScenario.java:44)
             at org.jboss.test.classpool.support.TestScenario.loadClass(TestScenario.java:193)
             at org.jboss.test.classpool.jbosscl.test.RepositoryTest.testURLChildOfGlobalUcl(RepositoryTest.java:156)
            



            • 48. Re: Testing Deployers with new Reflect + ClassPool
              flavia.rainone

               

              "alesj" wrote:
              Getting this failure:

              Have you done a clean checkout? I have just done a clean checkout myself and the tests pass for me.

              • 49. Re: Testing Deployers with new Reflect + ClassPool
                alesj

                Yup, just deleted/nuked my classpools directory,
                got a clean co, build, same failure. :-(

                • 50. Re: Testing Deployers with new Reflect + ClassPool
                  alesj

                  Running from IDE I get this for all org.jboss.test.classpool.jbosscl.test.RepositoryClassPoolTestCase tests

                  junit.framework.AssertionFailedError: Should not have been able to load org.jboss.test.classpool.support.excluded.a.A
                   at org.jboss.test.classpool.support.TestScenario.assertCannotLoaderSupportClasses(TestScenario.java:260)
                   at org.jboss.test.classpool.support.TestScenario.destroyLoaders(TestScenario.java:118)
                   at org.jboss.test.classpool.jbosscl.test.JBossClClassPoolTest.tearDown(JBossClClassPoolTest.java:160)
                   at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
                   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                   at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)


                  • 51. Re: Testing Deployers with new Reflect + ClassPool
                    flavia.rainone

                     

                    "alesj" wrote:
                    Running from IDE I get this for all org.jboss.test.classpool.jbosscl.test.RepositoryClassPoolTestCase tests
                    junit.framework.AssertionFailedError: Should not have been able to load org.jboss.test.classpool.support.excluded.a.A
                     at org.jboss.test.classpool.support.TestScenario.assertCannotLoaderSupportClasses(TestScenario.java:260)
                     at org.jboss.test.classpool.support.TestScenario.destroyLoaders(TestScenario.java:118)
                     at org.jboss.test.classpool.jbosscl.test.JBossClClassPoolTest.tearDown(JBossClClassPoolTest.java:160)
                     at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
                     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                     at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)


                    That error is fully expected as the classes belonging to the excluded package must be excluded from the classpath during test execution :-)

                    What about the NPE I couldn't reproduce in my computer?

                    • 52. Re: Testing Deployers with new Reflect + ClassPool
                      kabirkhan

                      I updated from svn and the tests work for me.

                      • 53. Re: Testing Deployers with new Reflect + ClassPool
                        flavia.rainone

                         

                        "kabir.khan@jboss.com" wrote:
                        I updated from svn and the tests work for me.

                        Thanks for verifying that :-)

                        Ales told me that the NPE is reproducible only under JDK5. Still, I have tested it with JDK5 and again couldn't see any failure.

                        I have also cleaned up my m2 repo, forcing maven to do a fresh download of all classpool dependencies. But still the tests run just fine.

                        • 54. Re: Testing Deployers with new Reflect + ClassPool
                          alesj

                           

                          "flavia.rainone@jboss.com" wrote:

                          That error is fully expected as the classes belonging to the excluded package must be excluded from the classpath during test execution :-)

                          I guess you now do this explicitly in maven?

                          You should do it programatically,
                          the same way we do it in our CL, Deployers, Weld, ... tests.

                          Check CL tests, where we create new ClassLoaderSystem, set parent policy, filters, ...
                          This way we will be able to run them in any env - IDE, mvn, ant, ivy, ...

                          "flavia.rainone@jboss.com" wrote:

                          What about the NPE I couldn't reproduce in my computer?

                          This was in attempt to get to the bottom of the NPE, debuging via IDE. ;-)

                          • 55. Re: Testing Deployers with new Reflect + ClassPool
                            alesj

                             

                            "alesj" wrote:

                            I guess you now do this explicitly in maven?

                            Ah, I see now what you've done.
                             <plugin>
                             <groupId>org.apache.maven.plugins</groupId>
                             <artifactId>maven-antrun-plugin</artifactId>
                             <version>1.2</version>
                             <executions>
                             <execution>
                             <id>create-test-jars</id>
                             <goals>
                             <goal>run</goal>
                             </goals>
                             <phase>process-test-classes</phase>
                             <configuration>
                             <tasks>
                             <property name="test.jar.suffix" value="-test-classpool-"/>
                             <property name="archive.dir" value="${project.build.directory}/archives"/>
                             <mkdir dir="${archive.dir}"/>
                             <jar destfile="${archive.dir}/a1.jar"
                             basedir="${project.build.testOutputDirectory}"
                             includes="org/jboss/test/classpool/support/excluded/a/*.class"/>
                            


                            Well, this works too, but, as it's shows, it makes harder to test/debug tests.
                            I thought you would use VFS's Assembled notion.
                            Or is there a valid reason you didn't?

                            To simplify + speed-up things, what you can do,
                            is to put this created artifacts directly into test's resources.
                            (they will get copied to the proper location by any env)
                            Then all you need to do is to add programmatic exclusion of test classes.


                            • 56. Re: Testing Deployers with new Reflect + ClassPool
                              kabirkhan

                               

                              "alesj" wrote:

                              I guess you no
                              Well, this works too, but, as it's shows, it makes harder to test/debug tests.
                              I thought you would use VFS's Assembled notion.
                              Or is there a valid reason you didn't?

                              Not really, I wasn't familiar with that at the time

                              "flavia" wrote:

                              Thanks for verifying that :-)

                              Ales told me that the NPE is reproducible only under JDK5. Still, I have tested it with JDK5 and again couldn't see any failure.

                              Using JDK 5 I see this error:
                              Tests run: 18, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 5.023 sec <<< FAILURE!
                              testURLChildOfGlobalUcl(org.jboss.test.classpool.jbosscl.test.RepositoryClassPoolTestCase) Time elapsed: 0.065 sec <<< ERROR!
                              java.lang.IllegalStateException: Illegal call. A class cannot be retrieved from ClassPool org.jboss.classpool.plugins.as.NonDelegatingClassPool@15141466 [class path: <null>:] - dcl:null because the corresponding ClassLoader is garbage collected
                               at org.jboss.classpool.base.BaseClassPool.get(BaseClassPool.java:130)
                               at org.jboss.test.classpool.support.ClassPoolTestScenario.assertLoadCtClassArray(ClassPoolTestScenario.java:173)
                               at org.jboss.test.classpool.support.ClassPoolTestScenario.assertLoadCtClassArray(ClassPoolTestScenario.java:163)
                               at org.jboss.test.classpool.support.ClassPoolTestScenario.assertLoadCtClass(ClassPoolTestScenario.java:155)
                               at org.jboss.test.classpool.support.ClassPoolTestScenario.loadClass(ClassPoolTestScenario.java:79)
                               at org.jboss.test.classpool.support.ClassPoolTestScenario.loadClass(ClassPoolTestScenario.java:44)
                               at org.jboss.test.classpool.jbosscl.test.RepositoryTest.testURLChildOfGlobalUcl(RepositoryTest.java:155)
                              


                              • 57. Re: Testing Deployers with new Reflect + ClassPool
                                kabirkhan

                                I've had a look

                                 public void testURLChildOfGlobalUcl() throws Exception
                                 {
                                 L globalLoader = testScenario.createLoader(new CLDeploymentBuilder("GLOBAL", JAR_A_1));
                                 L childALoader = createChildURLLoader(globalLoader, JAR_B_1);
                                
                                 testScenario.loadClass(childALoader, globalLoader, CLASS_A);
                                 testScenario.loadClass(childALoader, CLASS_B);
                                
                                 L childBLoader = createChildURLLoader(globalLoader, JAR_A_2);
                                 System.out.println("========> G" + globalLoader);
                                 System.out.println("========> A " + childALoader);
                                 System.out.println("========> B " + childBLoader);
                                 testScenario.loadClass(childBLoader, globalLoader, CLASS_A);
                                 }
                                

                                The output shows G and A to always have a classloader, probably because the testScenario call maintains a strong reference to the loader? B sometimes is shown to have null loader, so createChildURLLoader needs to be reworked somehow to maintain a strong reference to the loader.

                                • 58. Re: Testing Deployers with new Reflect + ClassPool
                                  flavia.rainone

                                   

                                  "kabir.khan@jboss.com" wrote:
                                  The output shows G and A to always have a classloader, probably because the testScenario call maintains a strong reference to the loader? B sometimes is shown to have null loader, so createChildURLLoader needs to be reworked somehow to maintain a strong reference to the loader.


                                  Thanks for looking into that. I'll fix it.
                                  Which JVM you useds?

                                  • 59. Re: Testing Deployers with new Reflect + ClassPool
                                    kabirkhan

                                    JDK 5 on OS X