コード例 #1
0
 @Test
 public void testAutoStar1tingContainerBuilderStarts() {
   X.reset();
   Reader script =
       new StringReader(
           ""
               + "def pico = builder.container(parent:parent) { \n"
               + "  component(com.picocontainer.script.testmodel.A)\n"
               + "}");
   PicoContainer parent = new PicoBuilder().withLifecycle().withCaching().build();
   PicoContainer pico =
       buildContainer(
           new GroovyContainerBuilder(script, getClass().getClassLoader()), parent, "SOME_SCOPE");
   // PicoContainer.getParent() is now ImmutablePicoContainer
   assertNotSame(parent, pico.getParent());
   assertEquals("<A", X.componentRecorder);
   X.reset();
 }
コード例 #2
0
 @Test
 public void testNonAutoStartingContainerBuildDoesntAutostart() {
   X.reset();
   Reader script =
       new StringReader(
           ""
               + "import com.picocontainer.script.testmodel.A\n"
               + "def pico = builder.container(parent:parent) { \n"
               + "  component(A)\n"
               + "}");
   PicoContainer parent = new PicoBuilder().withLifecycle().withCaching().build();
   ContainerBuilder containerBuilder =
       new GroovyContainerBuilder(script, getClass().getClassLoader())
           .setPostBuildAction(new NoOpPostBuildContainerAction());
   PicoContainer pico = buildContainer(containerBuilder, parent, "SOME_SCOPE");
   // PicoContainer.getParent() is now ImmutablePicoContainer
   assertNotSame(parent, pico.getParent());
   assertEquals("", X.componentRecorder);
   X.reset();
 }