public void execute(@Observes BeforeSuite event) { container.fire(new SetupContainers()); container.fire(new StartSuiteContainers()); }
public void execute(@Observes BeforeSuite event) { container.fire(new SetupContainers()); container.fire(new StartSuiteContainers()); }
@Before public void createSetup() { ContainerRegistry reg = Mockito.mock(ContainerRegistry.class); Container container = Mockito.mock(Container.class); Mockito.when(container.getState()).thenReturn(State.STARTED); Mockito.when(container.getName()).thenReturn("_DEFAULT_"); Container containerStopped = Mockito.mock(Container.class); Mockito.when(containerStopped.getState()).thenReturn(State.STOPPED); Mockito.when(containerStopped.getName()).thenReturn("_CONTAINER_STOPPED_"); Mockito.when(reg.getContainer("_DEFAULT_")).thenReturn(container); Mockito.when(reg.getContainer("_CONTAINER_STOPPED_")).thenReturn(containerStopped); Mockito.when(reg.getContainer(new TargetDescription("_DEFAULT_"))).thenReturn(container); Mockito.when(reg.getContainer(new TargetDescription("_CONTAINER_STOPPED_"))).thenReturn(containerStopped); bind(ApplicationScoped.class, DeploymentScenario.class, new DeploymentScenario()); bind(ApplicationScoped.class, ContainerRegistry.class, reg); fire(new SetupContainers()); // binds the Deployer }
@Before public void createSetup() { ContainerRegistry reg = Mockito.mock(ContainerRegistry.class); Container container = Mockito.mock(Container.class); Mockito.when(container.getState()).thenReturn(State.STARTED); Mockito.when(container.getName()).thenReturn("_DEFAULT_"); Container containerStopped = Mockito.mock(Container.class); Mockito.when(containerStopped.getState()).thenReturn(State.STOPPED); Mockito.when(containerStopped.getName()).thenReturn("_CONTAINER_STOPPED_"); Mockito.when(reg.getContainer("_DEFAULT_")).thenReturn(container); Mockito.when(reg.getContainer("_CONTAINER_STOPPED_")).thenReturn(containerStopped); Mockito.when(reg.getContainer(new TargetDescription("_DEFAULT_"))).thenReturn(container); Mockito.when(reg.getContainer(new TargetDescription("_CONTAINER_STOPPED_"))).thenReturn(containerStopped); bind(ApplicationScoped.class, DeploymentScenario.class, new DeploymentScenario()); bind(ApplicationScoped.class, ContainerRegistry.class, reg); fire(new SetupContainers()); // binds the Deployer }
@Before public void createSetup() { registry = new LocalContainerRegistry(injector.get()); when(serviceLoader.onlyOne(eq(DeployableContainer.class))).thenReturn(deployableContainer); ContainerDef suiteContainerDef = mock(ContainerDef.class); when(suiteContainerDef.getContainerName()).thenReturn(MANAGED_SERVER_NAME); when(suiteContainerDef.getMode()).thenReturn("suite"); ContainerDef manualContainerDef = Mockito.mock(ContainerDef.class); when(manualContainerDef.getContainerName()).thenReturn(MANUAL_SERVER_NAME); when(manualContainerDef.getMode()).thenReturn("manual"); ContainerDef customContainerDef = Mockito.mock(ContainerDef.class); when(customContainerDef.getMode()).thenReturn("custom"); when(customContainerDef.getContainerName()).thenReturn(CUSTOM_SERVER_NAME); registry.create(suiteContainerDef, serviceLoader); registry.create(manualContainerDef, serviceLoader); registry.create(customContainerDef, serviceLoader); bind(ApplicationScoped.class, ContainerRegistry.class, registry); bind(ApplicationScoped.class, DeploymentScenario.class, new DeploymentScenario()); fire(new SetupContainers()); }
@Before public void createSetup() { registry = new LocalContainerRegistry(injector.get()); when(serviceLoader.onlyOne(eq(DeployableContainer.class))).thenReturn(deployableContainer); ContainerDef suiteContainerDef = mock(ContainerDef.class); when(suiteContainerDef.getContainerName()).thenReturn(MANAGED_SERVER_NAME); when(suiteContainerDef.getMode()).thenReturn("suite"); ContainerDef manualContainerDef = Mockito.mock(ContainerDef.class); when(manualContainerDef.getContainerName()).thenReturn(MANUAL_SERVER_NAME); when(manualContainerDef.getMode()).thenReturn("manual"); ContainerDef customContainerDef = Mockito.mock(ContainerDef.class); when(customContainerDef.getMode()).thenReturn("custom"); when(customContainerDef.getContainerName()).thenReturn(CUSTOM_SERVER_NAME); registry.create(suiteContainerDef, serviceLoader); registry.create(manualContainerDef, serviceLoader); registry.create(customContainerDef, serviceLoader); bind(ApplicationScoped.class, ContainerRegistry.class, registry); bind(ApplicationScoped.class, DeploymentScenario.class, new DeploymentScenario()); fire(new SetupContainers()); }
@Test public void shouldNotStartCustomContainersInRegistry() throws Exception { registry.create(container5, serviceLoader).setState(Container.State.STOPPED); fire(new SetupContainers()); verify(deployableContainer, times(1)).setup(isA(DummyContainerConfiguration.class)); fire(new StartSuiteContainers()); verify(deployableContainer, times(0)).start(); fire(new StartClassContainers()); verify(deployableContainer, times(0)).start(); Assert.assertEquals(Container.State.SETUP, registry.getContainer(CONTAINER_5_NAME).getState()); }
@Test public void shouldSetupAllContainersInRegistry() throws Exception { registry.create(container1, serviceLoader); registry.create(container2, serviceLoader); registry.create(container3, serviceLoader); registry.create(container4, serviceLoader); registry.create(container5, serviceLoader); fire(new SetupContainers()); assertEventFiredInContext(SetupContainer.class, ContainerContext.class); assertEventFired(SetupContainer.class, 5); assertEventFiredInContext(BeforeSetup.class, ContainerContext.class); assertEventFired(BeforeSetup.class, 5); assertEventFiredInContext(AfterSetup.class, ContainerContext.class); assertEventFired(AfterSetup.class, 5); verify(deployableContainer, times(5)).setup(isA(DummyContainerConfiguration.class)); }