Skip to content

Commit

Permalink
Issue #4572 - Fixing non-IT jetty-maven-plugin test error
Browse files Browse the repository at this point in the history
Signed-off-by: Joakim Erdfelt <[email protected]>
  • Loading branch information
joakime committed Feb 24, 2020
1 parent 8c06600 commit ab178f3
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 20 deletions.
8 changes: 5 additions & 3 deletions jetty-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,11 @@
<artifactId>apache-jstl</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>jakarta.transaction</groupId>
<artifactId>jakarta.transaction-api</artifactId>
Expand All @@ -259,9 +264,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<configuration>
<dependencyLocationsEnabled>false</dependencyLocationsEnabled>
</configuration>
<reportSets>
<reportSet>
<reports>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public void doStart()
int attempts = maxChildStartChecks;
while (!tokenFile.exists() && attempts > 0)
{
Thread.currentThread().sleep(maxChildStartCheckMs);
Thread.sleep(maxChildStartCheckMs);
--attempts;
}
if (attempts <= 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@
import org.junit.jupiter.api.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertNotNull;

/**
* Test the JettyForkedChild class, which
* is the main that is executed by jetty:run/start in mode FORKED.
*
*/
public class TestForkedChild
{
Expand Down Expand Up @@ -107,11 +107,14 @@ public void setUp()
testDir.mkdirs();
tmpDir = new File(testDir, "tmp");
webappPropsFile = new File(testDir, "webapp.props");

stopPort = Integer.valueOf(System.getProperty("stop.port"));

String stopPortString = System.getProperty("stop.port");
assertNotNull(stopPortString, "stop.port System property");
stopPort = Integer.valueOf(stopPortString);
jettyPortString = System.getProperty("jetty.port");
assertNotNull(jettyPortString, "jetty.port System property");
jettyPort = Integer.valueOf(jettyPortString);

Random random = new Random();
token = Long.toString(random.nextLong() ^ System.currentTimeMillis(), 36).toUpperCase(Locale.ENGLISH);
tokenFile = testDir.toPath().resolve(token + ".txt").toFile();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
*
*
*/
public class TestJettyEmbedder
{

Expand Down Expand Up @@ -82,7 +78,7 @@ public void testJettyEmbedder()
MavenWebAppContext webApp = new MavenWebAppContext();
Server server = new Server();
Map<String,String> jettyProperties = new HashMap<>();
jettyProperties.put("jetty.server.dumpAfterStart", "true");
jettyProperties.put("jetty.server.dumpAfterStart", "false");

ContextHandler otherHandler = new ContextHandler();
otherHandler.setContextPath("/other");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void getContentResponse()
}
String response = httpClient.GET(url).getContentAsString();
assertTrue(response.contains(contentCheck), "it test " + System.getProperty("maven.it.name") +
", response not contentCheck: " + contentCheck + ", response:" + response);
", response not contentCheck: " + contentCheck + ", response:" + response);
System.out.println("contentCheck");
}
if (Boolean.getBoolean("helloTestServlet"))
Expand Down Expand Up @@ -104,8 +104,9 @@ public static int getPort()
int attempts = 70;
int port = -1;
String s = System.getProperty("jetty.port.file");
assertNotNull(s);
assertNotNull(s, "jetty.port.file System property");
Path p = Paths.get(s);
System.err.println("Looking for port file: " + p);
while (true)
{
if (Files.exists(p))
Expand All @@ -127,8 +128,9 @@ public static int getPort()
}
else
{
Thread.currentThread().sleep(1000);
Thread.sleep(1000);
}
System.err.printf(" attempts left: #%d%n", attempts);
}
}
return port;
Expand Down
7 changes: 3 additions & 4 deletions jetty-maven-plugin/src/test/resources/embedder-context.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_10_0.dtd">

<Configure class="org.eclipse.jetty.webapp.WebAppContext">

<Set name="contextPath">/embedder</Set>

<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath">/embedder</Set>
<Set name="resourceBase">src/test/resources/embedder</Set>
</Configure>
Empty file.

0 comments on commit ab178f3

Please sign in to comment.