@@ -244,22 +244,6 @@ public void testStartContainer() throws DockerException {
244244
245245 }
246246
247- /* @Test
248- public void testStartContainer2() throws DockerException {ContainerConfig appContainerConfig = new ContainerConfig();
249- appContainerConfig.setImage("4096e911ada1");
250- ContainerCreateResponse appContResponse = dockerClient.createContainer(appContainerConfig, "AppContainer");
251- System.out.println("Created an App container successfully: " + appContResponse.getId());
252- String appContId = appContResponse.getId();
253- HostConfig appHostConfig = new HostConfig(null);
254- Port p = new Port("tcp","8080","0.0.0.0","8082");
255- Ports ports = new Ports();
256- ports.addPort(p);
257- appHostConfig.setPortBindings(ports);
258- String[] links = {"mariaDB3:db"};
259- appHostConfig.setLinks(links);
260- dockerClient.startContainer(appContId, appHostConfig);
261- }
262- */
263247 @ Test
264248 public void testWaitContainer () throws DockerException {
265249
@@ -601,7 +585,7 @@ public void testRunShlex() throws DockerException {
601585 }
602586
603587
604- @ Test ( enabled = false )
588+ @ Test
605589 public void testNginxDockerfileBuilder () throws DockerException , IOException {
606590 File baseDir = new File (Thread .currentThread ().getContextClassLoader ().getResource ("nginx" ).getFile ());
607591
@@ -623,7 +607,7 @@ public void testNginxDockerfileBuilder() throws DockerException, IOException {
623607 String fullLog = logwriter .toString ();
624608 assertThat (fullLog , containsString ("Successfully built" ));
625609
626- String imageId = StringUtils .substringAfterLast (fullLog , "Successfully built " ).trim ();
610+ String imageId = StringUtils .substringBetween (fullLog , "Successfully built " , " \\ n \" } " ).trim ();
627611
628612 ImageInspectResponse imageInspectResponse = dockerClient .inspectImage (imageId );
629613 assertThat (imageInspectResponse , not (nullValue ()));
@@ -633,19 +617,19 @@ public void testNginxDockerfileBuilder() throws DockerException, IOException {
633617 assertThat (
imageInspectResponse .
getAuthor (),
equalTo (
"Guillaume J. Charmes \" [email protected] \" " ));
634618 }
635619
636- @ Test ( enabled = false )
620+ @ Test
637621 public void testDockerBuilderAddFile () throws DockerException , IOException {
638622 File baseDir = new File (Thread .currentThread ().getContextClassLoader ().getResource ("testAddFile" ).getFile ());
639623 dockerfileBuild (baseDir , "Successfully executed testrun.sh" );
640624 }
641625
642- @ Test ( enabled = false )
626+ @ Test
643627 public void testDockerBuilderAddFolder () throws DockerException , IOException {
644628 File baseDir = new File (Thread .currentThread ().getContextClassLoader ().getResource ("testAddFolder" ).getFile ());
645629 dockerfileBuild (baseDir , "Successfully executed testAddFolder.sh" );
646630 }
647631
648- @ Test ( enabled = false )
632+ @ Test
649633 public void testNetCatDockerfileBuilder () throws DockerException , IOException , InterruptedException {
650634 File baseDir = new File (Thread .currentThread ().getContextClassLoader ().getResource ("netcat" ).getFile ());
651635
@@ -667,7 +651,7 @@ public void testNetCatDockerfileBuilder() throws DockerException, IOException, I
667651 String fullLog = logwriter .toString ();
668652 assertThat (fullLog , containsString ("Successfully built" ));
669653
670- String imageId = StringUtils .substringAfterLast (fullLog , "Successfully built " ).trim ();
654+ String imageId = StringUtils .substringBetween (fullLog , "Successfully built " , " \\ n \" } " ).trim ();
671655
672656 ImageInspectResponse imageInspectResponse = dockerClient .inspectImage (imageId );
673657 assertThat (imageInspectResponse , not (nullValue ()));
@@ -758,7 +742,7 @@ private void dockerfileBuild(File baseDir, String expectedText) throws DockerExc
758742 String fullLog = logwriter .toString ();
759743 assertThat (fullLog , containsString ("Successfully built" ));
760744
761- String imageId = StringUtils .substringAfterLast (fullLog , "Successfully built " ).trim ();
745+ String imageId = StringUtils .substringBetween (fullLog , "Successfully built " , " \\ n \" } " ).trim ();
762746
763747 //Create container based on image
764748 ContainerConfig containerConfig = new ContainerConfig ();
@@ -788,6 +772,6 @@ private void dockerfileBuild(File baseDir, String expectedText) throws DockerExc
788772 IOUtils .closeQuietly (logResponse .getEntityInputStream ());
789773 }
790774
791- assertThat (logwriter2 .toString (), equalTo (expectedText ));
775+ assertThat (logwriter2 .toString (), endsWith (expectedText ));
792776 }
793777}
0 commit comments