@Override public void perform() { afterSuite.fire(new AfterSuite()); } }
public void afterSuite() throws Exception { manager.fire(new AfterSuite()); }
private void after(List<DockerCube> dockerCubes) { for (DockerCube dockerCube : dockerCubes) { // stop container dockerCube.stop(); dockerCube.destroy(); systemPropertiesCubeSetter.removeCubeSystemProperties(new AfterDestroy(dockerCube.getId())); systemPropertiesCubeSetter.removeDockerHostProperty(new AfterSuite()); } dockerCubes.clear(); }
@Test public void should_unset_docker_host_ip() { // given SystemPropertiesCubeSetter systemPropertiesCubeSetter = new SystemPropertiesCubeSetter(); System.setProperty("arq.cube.docker.host", "192.168.99.100"); // when systemPropertiesCubeSetter.removeDockerHostProperty(new AfterSuite()); // then assertThat(System.getProperty("arq.cube.docker.host")).isNull(); }
@Test public void shouldStopSuiteContainers() throws Exception { fire(new AfterSuite()); assertEventFired(StopSuiteContainers.class, 1); }
@Test public void shouldStopSuiteContainers() throws Exception { fire(new AfterSuite()); assertEventFired(StopSuiteContainers.class, 1); }
@Test public void shouldStopAndDestroyAutoContainers() { Map<String, String> dockerData = new HashMap<String, String>(); dockerData.put("autoStartContainers", "a,b"); dockerData.put("dockerContainers", "a:\n image: a\nb:\n image: a\n"); CubeConfiguration cubeConfiguration = CubeConfiguration.fromMap(new HashMap<String, String>()); bind(ApplicationScoped.class, CubeConfiguration.class, cubeConfiguration); CubeDockerConfiguration dockerConfiguration = CubeDockerConfiguration.fromMap(dockerData, null); bind(ApplicationScoped.class, CubeDockerConfiguration.class, dockerConfiguration); fire(new AfterSuite()); assertEventFired(StopCube.class, 2); assertEventFired(DestroyCube.class, 2); assertEventFiredOnOtherThread(StopCube.class); assertEventFiredOnOtherThread(DestroyCube.class); }
@Override public void evaluate() throws Throwable { List<Throwable> errors = new ArrayList<>(); // Inject Arquillian resources container = containerBuilder.build(); final LocalCubeRegistry localCubeRegistry = new LocalCubeRegistry(); final DockerCube dockerCube = Injector.prepareContainer(container, dockerClientExecutor, localCubeRegistry); try { dockerCube.create(); dockerCube.start(); systemPropertiesCubeSetter.createCubeSystemProperties(new AfterStart(dockerCube.getId()), localCubeRegistry); // Run tests base.evaluate(); } catch (Throwable t) { errors.add(t); } finally { // stop container dockerCube.stop(); dockerCube.destroy(); systemPropertiesCubeSetter.removeCubeSystemProperties(new AfterDestroy(dockerCube.getId())); systemPropertiesCubeSetter.removeDockerHostProperty(new AfterSuite()); } MultipleFailureException.assertEmpty(errors); } };
bind(ApplicationScoped.class, DockerClientExecutor.class, executor); fire(new AfterSuite()); Mockito.verify(executor).removeNetwork(Matchers.eq("mynetwork"));