@Test(expected = ValidationException.class) public void shouldThrowExceptionOnWrongContainerReference() throws Exception { addContainer("test-contianer").getContainerConfiguration().setMode("suite"); try { fire(createEvent(DeploymentWithContainerReference.class)); } catch (Exception e) { Assert.assertTrue("Validate correct error message", e.getMessage().contains("does not match any found/configured Containers")); throw e; } }
@Test(expected = ValidationException.class) public void shouldThrowExceptionOnMissingProtocolReference() throws Exception { addContainer("test-contianer").getContainerConfiguration().setMode("suite"); try { fire(createEvent(DeploymentWithProtocolReference.class)); } catch (Exception e) { Assert.assertTrue("Validate correct error message", e.getMessage().contains("not maching any defined Protocol")); throw e; } }
@Test(expected = ValidationException.class) public void shouldThrowExceptionOnManagedDeploymentOnCustomContainer() throws Exception { addContainer(CONTAINER_NAME_1).getContainerConfiguration().setMode("custom"); try { fire(createEvent(DeploymentManagedWithCustomContainerReference.class)); } catch (Exception e) { Assert.assertTrue("Validate correct error message", e.getMessage().contains("This container is set to mode custom ")); throw e; } }
@Test(expected = ValidationException.class) public void shouldThrowExceptionOnMissingProtocolReference() throws Exception { addContainer("test-contianer").getContainerConfiguration().setMode("suite"); try { fire(createEvent(DeploymentWithProtocolReference.class)); } catch (Exception e) { Assert.assertTrue("Validate correct error message", e.getMessage().contains("not maching any defined Protocol")); throw e; } }
@Test public void shouldUseDefaultDefinedProtocolIfFound() { addContainer("test-contianer").getContainerConfiguration().setMode("suite"); addProtocol(PROTOCOL_NAME_1, true); fire(createEvent(DeploymentWithDefaults.class)); verify(deployableContainer, times(0)).getDefaultProtocol(); }
@Test public void shouldUseDefaultDefinedProtocolIfFound() { addContainer("test-contianer").getContainerConfiguration().setMode("suite"); addProtocol(PROTOCOL_NAME_1, true); fire(createEvent(DeploymentWithDefaults.class)); verify(deployableContainer, times(0)).getDefaultProtocol(); }
@Test public void shouldAllowMultipleSameNamedArchiveDeploymentWithDifferentTargets() throws Exception { addContainer(CONTAINER_NAME_1).getContainerConfiguration().setMode("suite"); addContainer(CONTAINER_NAME_2).getContainerConfiguration().setMode("suite"); addProtocol(PROTOCOL_NAME_1, true); fire(createEvent(DeploymentMultipleSameNameArchiveDifferentTarget.class)); verifyScenario("X", "Y"); }
@Test public void shouldUseContainerDefaultProtocolIfNonDefaultDefined() { addContainer("test-contianer").getContainerConfiguration().setMode("suite"); addProtocol(PROTOCOL_NAME_1, false); addProtocol(PROTOCOL_NAME_2, false); fire(createEvent(DeploymentWithDefaults.class)); verify(deployableContainer, times(1)).getDefaultProtocol(); verifyScenario("_DEFAULT_"); }
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionOnMultipleSameNamedArchiveDeployments() throws Exception { addContainer("test-contianer").getContainerConfiguration().setMode("suite"); try { fire(createEvent(DeploymentMultipleSameNameArchive.class)); } catch (Exception e) { throw e; } }
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionOnMultipleNoNamedDeployments() throws Exception { addContainer("test-contianer").getContainerConfiguration().setMode("suite"); try { fire(createEvent(DeploymentMultipleNoNamed.class)); } catch (Exception e) { throw e; } }
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionOnMultipleNoNamedDeployments() throws Exception { addContainer("test-contianer").getContainerConfiguration().setMode("suite"); try { fire(createEvent(DeploymentMultipleNoNamed.class)); } catch (Exception e) { throw e; } }
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionOnMultipleSameNamedArchiveDeployments() throws Exception { addContainer("test-contianer").getContainerConfiguration().setMode("suite"); try { fire(createEvent(DeploymentMultipleSameNameArchive.class)); } catch (Exception e) { throw e; } }
@Test public void shouldUseContainerDefaultProtocolIfNonDefaultDefined() { addContainer("test-contianer").getContainerConfiguration().setMode("suite"); addProtocol(PROTOCOL_NAME_1, false); addProtocol(PROTOCOL_NAME_2, false); fire(createEvent(DeploymentWithDefaults.class)); verify(deployableContainer, times(1)).getDefaultProtocol(); verifyScenario("_DEFAULT_"); }
@Test public void shouldAllowNonManagedDeploymentOnCustomContainer() throws Exception { addContainer(CONTAINER_NAME_1).getContainerConfiguration().setMode("custom"); fire(createEvent(DeploymentNonManagedWithCustomContainerReference.class)); verifyScenario("DeploymentNonManagedWithCustomContainerReference"); }
@Test public void shouldAllowNonManagedDeploymentOnCustomContainer() throws Exception { addContainer(CONTAINER_NAME_1).getContainerConfiguration().setMode("custom"); fire(createEvent(DeploymentNonManagedWithCustomContainerReference.class)); verifyScenario("DeploymentNonManagedWithCustomContainerReference"); }
@Test public void shouldAddAdditionalObserverClasses() { addContainer("test-contianer").getContainerConfiguration().setMode("suite"); addProtocol(PROTOCOL_NAME_1, true); fire(createEvent(DeploymentWithObserver.class)); DeploymentScenario scenario = getManager().resolve(DeploymentScenario.class); Archive<?> archive = scenario.deployments().get(0).getDescription().getArchive(); verifyThatIsContainedInArchive(archive, DeploymentWithObserver.class); verifyThatIsContainedInArchive(archive, ObserverClass.class); verifyThatIsContainedInArchive(archive, SecondObserverClass.class); }
@Test public void shouldAddAdditionalObserverClasses() { addContainer("test-contianer").getContainerConfiguration().setMode("suite"); addProtocol(PROTOCOL_NAME_1, true); fire(createEvent(DeploymentWithObserver.class)); DeploymentScenario scenario = getManager().resolve(DeploymentScenario.class); Archive<?> archive = scenario.deployments().get(0).getDescription().getArchive(); verifyThatIsContainedInArchive(archive, DeploymentWithObserver.class); verifyThatIsContainedInArchive(archive, ObserverClass.class); verifyThatIsContainedInArchive(archive, SecondObserverClass.class); }
@Test public void shouldNotCallPackagingSPIsOnNonTestableArchive() throws Exception { addContainer("test-contianer").getContainerConfiguration().setMode("suite"); addProtocol(PROTOCOL_NAME_1, true); fire(createEvent(DeploymentNonTestableWithDefaults.class)); CallMap spi = getManager().resolve(CallMap.class); Assert.assertFalse(spi.wasCalled(ApplicationArchiveProcessor.class)); Assert.assertFalse(spi.wasCalled(AuxiliaryArchiveAppender.class)); Assert.assertFalse(spi.wasCalled(AuxiliaryArchiveProcessor.class)); verifyScenario("_DEFAULT_"); }
@Test public void shouldNotCallPackagingSPIsOnNonTestableArchive() throws Exception { addContainer("test-contianer").getContainerConfiguration().setMode("suite"); addProtocol(PROTOCOL_NAME_1, true); fire(createEvent(DeploymentNonTestableWithDefaults.class)); CallMap spi = getManager().resolve(CallMap.class); Assert.assertFalse(spi.wasCalled(ApplicationArchiveProcessor.class)); Assert.assertFalse(spi.wasCalled(AuxiliaryArchiveAppender.class)); Assert.assertFalse(spi.wasCalled(AuxiliaryArchiveProcessor.class)); verifyScenario("_DEFAULT_"); }
@Test public void shouldCallPackagingSPIsOnTestableArchive() throws Exception { addContainer("test-contianer").getContainerConfiguration().setMode("suite"); addProtocol(PROTOCOL_NAME_1, true); fire(createEvent(DeploymentWithDefaults.class)); CallMap spi = getManager().resolve(CallMap.class); Assert.assertTrue(spi.wasCalled(ApplicationArchiveProcessor.class)); Assert.assertTrue(spi.wasCalled(AuxiliaryArchiveAppender.class)); Assert.assertTrue(spi.wasCalled(AuxiliaryArchiveProcessor.class)); verifyScenario("_DEFAULT_"); }