3 Replies Latest reply on Feb 15, 2010 5:08 AM by Galder Zamarreño

    JUnit tests with DefaultCacheManager

    John Ament Master

      So I have a JUnit test case that's calling a groovy script to execute some code that will populate a cache with data, then the test is to verify the data in there.

       

      When we added the call to construct a DefaultCacheManager, then have maven run the test, the following occurs:

       

      {code}java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/transaction/SystemException
          at java.lang.ClassLoader.defineClass1(Native Method)
          at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
          at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
          at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
          at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
          at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
          at java.security.AccessController.doPrivileged(Native Method)
          at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
          at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
          at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
          at java.lang.Class.getDeclaredMethods0(Native Method)
          at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
          at java.lang.Class.privateGetPublicMethods(Class.java:2547)
          at java.lang.Class.getMethods(Class.java:1410)
          at org.infinispan.util.Util.getFactoryMethod(Util.java:60)
          at org.infinispan.util.Util.getInstance(Util.java:72)
          at org.infinispan.factories.EmptyConstructorNamedCacheFactory.construct(EmptyConstructorNamedCacheFactory.java:64)
          at org.infinispan.factories.AbstractComponentRegistry.getOrCreateComponent(AbstractComponentRegistry.java:306)
          at org.infinispan.factories.AbstractComponentRegistry.invokeInjectionMethod(AbstractComponentRegistry.java:244)
          at org.infinispan.factories.AbstractComponentRegistry$Component.injectDependencies(AbstractComponentRegistry.java:803)
          at org.infinispan.factories.AbstractComponentRegistry.registerComponent(AbstractComponentRegistry.java:219)
          at org.infinispan.factories.ComponentRegistry.registerComponent(ComponentRegistry.java:118)
          at org.infinispan.factories.AbstractComponentRegistry.registerComponent(AbstractComponentRegistry.java:186)
          at org.infinispan.factories.AbstractComponentRegistry.getOrCreateComponent(AbstractComponentRegistry.java:314)
          at org.infinispan.factories.AbstractComponentRegistry.invokeInjectionMethod(AbstractComponentRegistry.java:244)
          at org.infinispan.factories.AbstractComponentRegistry$Component.injectDependencies(AbstractComponentRegistry.java:803)
          at org.infinispan.factories.AbstractComponentRegistry.registerComponent(AbstractComponentRegistry.java:219)
          at org.infinispan.factories.ComponentRegistry.registerComponent(ComponentRegistry.java:118)
          at org.infinispan.factories.AbstractComponentRegistry.registerComponent(AbstractComponentRegistry.java:186)
          at org.infinispan.factories.AbstractComponentRegistry.getOrCreateComponent(AbstractComponentRegistry.java:314)
          at org.infinispan.factories.AbstractComponentRegistry.invokeInjectionMethod(AbstractComponentRegistry.java:244)
          at org.infinispan.factories.AbstractComponentRegistry$Component.injectDependencies(AbstractComponentRegistry.java:803)
          at org.infinispan.factories.AbstractComponentRegistry.registerComponent(AbstractComponentRegistry.java:219)
          at org.infinispan.factories.ComponentRegistry.registerComponent(ComponentRegistry.java:118)
          at org.infinispan.factories.AbstractComponentRegistry.registerComponent(AbstractComponentRegistry.java:186)
          at org.infinispan.factories.InternalCacheFactory.bootstrap(InternalCacheFactory.java:89)
          at org.infinispan.factories.InternalCacheFactory.createAndWire(InternalCacheFactory.java:76)
          at org.infinispan.factories.InternalCacheFactory.createCache(InternalCacheFactory.java:57)
          at org.infinispan.manager.DefaultCacheManager.createCache(DefaultCacheManager.java:387)
          at org.infinispan.manager.DefaultCacheManager.getCache(DefaultCacheManager.java:354)
          at com.coat.ssg.scorecard.test.GetSalesTest.setUp(GetSalesTest.java:57)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          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 org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
          at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
          at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
          at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
          at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009){code}

      we construct the cache manager in the unit test with the following line:

       

      cacheManager = new DefaultCacheManager(scorecardHome+"/conf/cachemgmt.xml");