DistributionTester is definitely a better name

Signed-off-by: olivier lamy <oliver.lamy@gmail.com>
This commit is contained in:
olivier lamy 2019-02-11 19:08:57 +10:00
parent dd4041dae1
commit 214bc03270
3 changed files with 38 additions and 41 deletions

View File

@ -83,7 +83,7 @@ import org.eclipse.jetty.util.log.Logger;
* <b>So API can change without any further notice.</b> * <b>So API can change without any further notice.</b>
* </p> * </p>
*/ */
public class DistributionRunner { public class DistributionTester {
private Process pid; private Process pid;
@ -105,7 +105,7 @@ public class DistributionRunner {
private String jettyHome; private String jettyHome;
private String mavenLocalRepository = System.getProperty("user.home") + "/.m2/repository"; private String mavenLocalRepository = System.getProperty("user.home") + "/.m2/repository";
private static final Logger LOGGER = Log.getLogger(DistributionRunner.class); private static final Logger LOGGER = Log.getLogger(DistributionTester.class);
private List<String> logs = new ArrayList<>(); private List<String> logs = new ArrayList<>();
@ -113,17 +113,17 @@ public class DistributionRunner {
private Map<String,String> mavenRemoteRepositories = new HashMap<>(); private Map<String,String> mavenRemoteRepositories = new HashMap<>();
private DistributionRunner(Path jettyBase) private DistributionTester(Path jettyBase)
throws Exception { throws Exception {
this.jettyBase = jettyBase; this.jettyBase = jettyBase;
} }
/** /**
* *
* @return DistributionRunner setup jettyHome directory and start httpClient. * @return DistributionTester setup jettyHome directory and start httpClient.
* @throws Exception * @throws Exception
*/ */
private DistributionRunner initialise() throws Exception { private DistributionTester initialise() throws Exception {
if (StringUtils.isNotEmpty(jettyHome)) { if (StringUtils.isNotEmpty(jettyHome)) {
jettyHomeDir = Paths.get(jettyHome).toFile(); jettyHomeDir = Paths.get(jettyHome).toFile();
@ -261,7 +261,7 @@ public class DistributionRunner {
// using LOGGER generates too long lines.. // using LOGGER generates too long lines..
//LOGGER.info("[{}] {}",mode, line); //LOGGER.info("[{}] {}",mode, line);
System.out.println("[" + mode + "] " + line); System.out.println("[" + mode + "] " + line);
DistributionRunner.this.logs.add(line); DistributionTester.this.logs.add(line);
} }
} catch (IOException ignore) { } catch (IOException ignore) {
// ignore // ignore
@ -698,25 +698,25 @@ public class DistributionRunner {
/** /**
* *
* @return a new configured instance of {@link DistributionRunner} * @return a new configured instance of {@link DistributionTester}
* @throws Exception * @throws Exception
*/ */
public DistributionRunner build() public DistributionTester build()
throws Exception { throws Exception {
if (jettyBase == null) { if (jettyBase == null) {
this.jettyBase = Files.createTempDirectory("jetty_base_test"); this.jettyBase = Files.createTempDirectory("jetty_base_test");
this.jettyBase.toFile().deleteOnExit(); this.jettyBase.toFile().deleteOnExit();
} }
DistributionRunner distributionRunner = new DistributionRunner(jettyBase); DistributionTester distributionTester = new DistributionTester(jettyBase);
distributionRunner.jettyVersion = jettyVersion; distributionTester.jettyVersion = jettyVersion;
distributionRunner.jettyHome = jettyHome; distributionTester.jettyHome = jettyHome;
distributionRunner.mavenLocalRepository = mavenLocalRepository; distributionTester.mavenLocalRepository = mavenLocalRepository;
distributionRunner.waitStartTime = waitStartTime; distributionTester.waitStartTime = waitStartTime;
distributionRunner.maxWaitToStop = maxWaitToStop; distributionTester.maxWaitToStop = maxWaitToStop;
if(!this.mavenRemoteRepositories.isEmpty()) { if(!this.mavenRemoteRepositories.isEmpty()) {
distributionRunner.mavenRemoteRepositories.putAll(this.mavenRemoteRepositories); distributionTester.mavenRemoteRepositories.putAll(this.mavenRemoteRepositories);
} }
return distributionRunner.initialise(); return distributionTester.initialise();
} }
} }
} }

View File

@ -21,32 +21,31 @@ package org.eclipse.jetty.tests.distribution;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import java.io.File; import java.io.File;
import java.nio.file.Path;
public class HttpModuleTests public class HttpModuleTests
{ {
@Test @Test
public void http_module() throws Exception public void http_module() throws Exception
{ {
DistributionRunner distributionRunner = DistributionRunner.Builder.newInstance() // DistributionTester distributionTester = DistributionTester.Builder.newInstance() //
.jettyVersion(System.getProperty("jetty_version")) // .jettyVersion(System.getProperty("jetty_version")) //
.mavenLocalRepository(System.getProperty("mavenRepoPath")) // .mavenLocalRepository(System.getProperty("mavenRepoPath")) //
.waitStartTime(30) // .waitStartTime(30) //
.build(); // .build(); //
try try
{ {
distributionRunner.start("--create-startd", "--approve-all-licenses", "--add-to-start=resources,server,http,webapp,deploy,jsp,jmx,jmx-remote,servlet,servlets"); distributionTester.start("--create-startd", "--approve-all-licenses", "--add-to-start=resources,server,http,webapp,deploy,jsp,jmx,jmx-remote,servlet,servlets");
distributionRunner.stop(); distributionTester.stop();
File war = distributionRunner.resolveArtifact("org.eclipse.jetty.tests:test-simple-webapp:war:" + System.getProperty("jetty_version")); File war = distributionTester.resolveArtifact("org.eclipse.jetty.tests:test-simple-webapp:war:" + System.getProperty("jetty_version"));
distributionRunner.installWarFile(war, "test"); distributionTester.installWarFile(war, "test");
distributionRunner.start(); distributionTester.start();
distributionRunner.assertLogsContains("Started @"); distributionTester.assertLogsContains("Started @");
distributionRunner.assertUrlStatus("/test/index.jsp", 200); distributionTester.assertUrlStatus("/test/index.jsp", 200);
distributionRunner.assertUrlContains("/test/index.jsp", "Hello"); distributionTester.assertUrlContains("/test/index.jsp", "Hello");
} finally { } finally {
distributionRunner.stop(); distributionTester.stop();
distributionRunner.cleanup(); distributionTester.cleanup();
} }
} }

View File

@ -19,11 +19,9 @@
package org.eclipse.jetty.tests.distribution; package org.eclipse.jetty.tests.distribution;
import java.io.File; import java.io.File;
import java.nio.file.Path;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnJre; import org.junit.jupiter.api.condition.DisabledOnJre;
import org.junit.jupiter.api.condition.EnabledOnJre;
import org.junit.jupiter.api.condition.JRE; import org.junit.jupiter.api.condition.JRE;
public class JpmsActivatedTests public class JpmsActivatedTests
@ -32,25 +30,25 @@ public class JpmsActivatedTests
@DisabledOnJre(JRE.JAVA_8) @DisabledOnJre(JRE.JAVA_8)
public void jpms_activated() throws Exception public void jpms_activated() throws Exception
{ {
DistributionRunner distributionRunner = DistributionRunner.Builder.newInstance() // DistributionTester distributionTester = DistributionTester.Builder.newInstance() //
.jettyVersion(System.getProperty("jetty_version")) // .jettyVersion(System.getProperty("jetty_version")) //
.mavenLocalRepository(System.getProperty("mavenRepoPath")) // .mavenLocalRepository(System.getProperty("mavenRepoPath")) //
.waitStartTime(30) // .waitStartTime(30) //
.build(); // .build(); //
try try
{ {
distributionRunner.start("--create-startd", "--approve-all-licenses", "--add-to-start=resources,server,http,webapp,deploy,jsp,jmx,jmx-remote,servlet,servlets"); distributionTester.start("--create-startd", "--approve-all-licenses", "--add-to-start=resources,server,http,webapp,deploy,jsp,jmx,jmx-remote,servlet,servlets");
distributionRunner.stop(); distributionTester.stop();
File war = distributionRunner.resolveArtifact("org.eclipse.jetty.tests:test-simple-webapp:war:" + System.getProperty("jetty_version")); File war = distributionTester.resolveArtifact("org.eclipse.jetty.tests:test-simple-webapp:war:" + System.getProperty("jetty_version"));
distributionRunner.installWarFile(war, "test"); distributionTester.installWarFile(war, "test");
distributionRunner.start("--jpms"); distributionTester.start("--jpms");
distributionRunner.assertLogsContains("Started @"); distributionTester.assertLogsContains("Started @");
distributionRunner.assertUrlStatus("/test/index.jsp", 200); distributionTester.assertUrlStatus("/test/index.jsp", 200);
distributionRunner.assertUrlContains("/test/index.jsp", "Hello"); distributionTester.assertUrlContains("/test/index.jsp", "Hello");
} finally { } finally {
distributionRunner.stop(); distributionTester.stop();
distributionRunner.cleanup(); distributionTester.cleanup();
} }
} }