2 Replies Latest reply on Oct 12, 2005 1:59 PM by Dustin Hunter

    Cleaning up the Embeddable Container

    Dustin Hunter Newbie

      I'm trying to use the Embeddable container within a unit test framework. If I attempt to follow these steps for each unit test class

      Initialize container

      Run unit test(s)

      Shutdown container


      I get a slew of errors. First, if I try to re-initialize a container, I get
      [testng] javax.naming.NameAlreadyBoundException
       [testng] at org.jnp.server.NamingServer.bind(NamingServer.java:130)
       [testng] at org.jnp.interfaces.NamingContext.bind(NamingContext.java:551)
       [testng] at org.jnp.interfaces.NamingContext.bind(NamingContext.java:516)
       [testng] at javax.naming.InitialContext.bind(InitialContext.java:359)
       [testng] at org.jboss.tm.TransactionManagerInitializer.bindRef(TransactionManagerInitializer.java:413)
       [testng] at org.jboss.tm.TransactionManagerInitializer.start(TransactionManagerInitializer.java:113)
       [testng] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       [testng] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       [testng] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       [testng] at java.lang.reflect.Method.invoke(Method.java:585)
       [testng] at org.jboss.joinpoint.plugins.reflect.ReflectMethodJoinPoint.dispatch(ReflectMethodJoinPoint.java:57)
       [testng] at org.jboss.kernel.plugins.dependency.KernelControllerContextActions$LifecycleAction.installAction(Kern
      ...


      Ok... that makes sense. However, if I try to call EJB3StandaloneBootstrap.shutdown() I get an error on ever mbean:
      [testng] java.lang.IllegalStateException: Not installed: Naming
       [testng] at org.jboss.dependency.plugins.AbstractController.uninstall(AbstractController.java:171)
       [testng] at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.undeployBean(AbstractKernelDeployer.java:3
      33)
       [testng] at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.undeployBeans(AbstractKernelDeployer.java:
      312)
       [testng] at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.undeploy(AbstractKernelDeployer.java:121)
       [testng] at org.jboss.ejb3.embedded.EJB3StandaloneBootstrap.shutdown(EJB3StandaloneBootstrap.java:173)
       [testng] at com.intuit.engine.efp.efe.test.EfeBaseTest.destroy(EfeBaseTest.java:97)
       [testng] at com.intuit.engine.efp.efe.mpc.persistence.ExtendedAttributeTest.tearDown(ExtendedAttributeTest.java:3
      1)
       [testng] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       [testng] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       [testng] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       [testng] at java.lang.reflect.Method.invoke(Method.java:585)
       [testng] at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:294)
       [testng] at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:282)
       [testng] at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:151)
       [testng] at org.testng.TestRunner.invokeClassConfigurations(TestRunner.java:669)
       [testng] at org.testng.TestRunner.privateRun(TestRunner.java:596)
       [testng] at org.testng.TestRunner.run(TestRunner.java:479)
       [testng] at org.testng.SuiteRunner.privateRun(SuiteRunner.java:191)
       [testng] at org.testng.SuiteRunner.run(SuiteRunner.java:117)
       [testng] at org.testng.TestNG.run(TestNG.java:277)
       [testng] at org.testng.TestNG.privateMain(TestNG.java:364)
       [testng] at org.testng.TestNG.main(TestNG.java:313)
       [testng] WARN 10-10 12:51:21,199 (AbstractKernelDeployer.java:undeployBeans:317) -Ignored error during uninstall of
       AbstractKernelControllerContext@b32ed4{ metadata=AbstractBeanMetaData@180f545{name=InitialContextProperties bean=java.u
      til.Hashtable properties= constructor=AbstractConstructorMetaData@166aab6{parameters=[java.util.Map]}}name=InitialContex
      tProperties target={java.naming.factory.initial=org.jnp.interfaces.LocalOnlyContextFactory, java.naming.factory.url.pkgs
      =org.jboss.naming:org.jnp.interfaces} state=Installed depends=AbstractDependencyInfo@151ac10{idependOn=[]}}
       [testng] java.lang.IllegalStateException: Not installed: InitialContextProperties
       [testng] at org.jboss.dependency.plugins.AbstractController.uninstall(AbstractController.java:171)
       [testng] at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.undeployBean(AbstractKernelDeployer.java:3
      33)
       [testng] at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.undeployBeans(AbstractKernelDeployer.java:
      312)
       [testng] at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.undeploy(AbstractKernelDeployer.java:121)
       [testng] at org.jboss.ejb3.embedded.EJB3StandaloneBootstrap.shutdown(EJB3StandaloneBootstrap.java:173)
       [testng] at com.intuit.engine.efp.efe.test.EfeBaseTest.destroy(EfeBaseTest.java:97)
       [testng] at com.intuit.engine.efp.efe.mpc.persistence.ExtendedAttributeTest.tearDown(ExtendedAttributeTest.java:3
      1)
       [testng] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       [testng] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       [testng] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       [testng] at java.lang.reflect.Method.invoke(Method.java:585)
       [testng] at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:294)
       [testng] at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:282)
       [testng] at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:151)
       [testng] at org.testng.TestRunner.invokeClassConfigurations(TestRunner.java:669)
       [testng] at org.testng.TestRunner.privateRun(TestRunner.java:596)
       [testng] at org.testng.TestRunner.run(TestRunner.java:479)
       [testng] at org.testng.SuiteRunner.privateRun(SuiteRunner.java:191)
       [testng] at org.testng.SuiteRunner.run(SuiteRunner.java:117)
       [testng] at org.testng.TestNG.run(TestNG.java:277)
       [testng] at org.testng.TestNG.privateMain(TestNG.java:364)
       [testng] at org.testng.TestNG.main(TestNG.java:313)
       [testng] WARN 10-10 12:51:21,230 (AbstractKernelDeployer.java:undeployBeans:317) -Ignored error during uninstall of
       AbstractKernelControllerContext@6a3960{ metadata=AbstractBeanMetaData@f77511{name=JavaCompInitializer bean=org.jboss.ej
      b3.embedded.JavaCompInitializer properties=[jndiProperties] constructor=null}name=JavaCompInitializer target=org.jboss.e
      jb3.embedded.JavaCompInitializer@26dfcc state=Installed depends=AbstractDependencyInfo@2eef15{idependOn=[AbstractDepende
      ncyItem@152853d{name=JavaCompInitializer dependsOn=InitialContextProperties whenRequired=Configured dependentState=Insta
      lled resolved=true}] unresolved=[AbstractDependencyItem@152853d{name=JavaCompInitializer dependsOn=InitialContextPropert
      ies whenRequired=Configured dependentState=Installed resolved=true}]}}
       [testng] java.lang.IllegalStateException: Not installed: JavaCompInitializer
       [testng] at org.jboss.dependency.plugins.AbstractController.uninstall(AbstractController.java:171)
       [testng] at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.undeployBean(AbstractKernelDeployer.java:3
      33)
       [testng] at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.undeployBeans(AbstractKernelDeployer.java:
      312)
       [testng] at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.undeploy(AbstractKernelDeployer.java:121)
       [testng] at org.jboss.ejb3.embedded.EJB3StandaloneBootstrap.shutdown(EJB3StandaloneBootstrap.java:173)
       [testng] at com.intuit.engine.efp.efe.test.EfeBaseTest.destroy(EfeBaseTest.java:97)
       [testng] at com.intuit.engine.efp.efe.mpc.persistence.ExtendedAttributeTest.tearDown(ExtendedAttributeTest.java:3
      1)
       [testng] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       [testng] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       [testng] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       [testng] at java.lang.reflect.Method.invoke(Method.java:585)
       [testng] at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:294)
       [testng] at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:282)
       [testng] at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:151)
       [testng] at org.testng.TestRunner.invokeClassConfigurations(TestRunner.java:669)
       [testng] at org.testng.TestRunner.privateRun(TestRunner.java:596)
       [testng] at org.testng.TestRunner.run(TestRunner.java:479)
       [testng] at org.testng.SuiteRunner.privateRun(SuiteRunner.java:191)
       [testng] at org.testng.SuiteRunner.run(SuiteRunner.java:117)
       [testng] at org.testng.TestNG.run(TestNG.java:277)
       [testng] at org.testng.TestNG.privateMain(TestNG.java:364)
       [testng] at org.testng.TestNG.main(TestNG.java:313)


      I can get around this by creating a static boolean flag indicating whether the container has been initialized, however, I'm not sure that is what was intended. From a pure unit testing stance, it would be better to shutdown and recreate the container so that artifacts from one test do not affect another.

      Any comments on the intended behaviour when running suites of tests?

      Alpha3 looks great so far...