* Issue #5763 Fix TestJettyEmbedded test Signed-off-by: Jan Bartel <janb@webtide.com> * Better test directory usage Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com> Co-authored-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
This commit is contained in:
parent
0c1f9636b3
commit
8fd2e588a7
|
@ -13,6 +13,7 @@
|
|||
|
||||
package org.eclipse.jetty.maven.plugin;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -21,23 +22,31 @@ import org.eclipse.jetty.server.Server;
|
|||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.toolchain.test.jupiter.WorkDir;
|
||||
import org.eclipse.jetty.toolchain.test.jupiter.WorkDirExtension;
|
||||
import org.eclipse.jetty.util.resource.PathResource;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@ExtendWith(WorkDirExtension.class)
|
||||
public class TestJettyEmbedder
|
||||
{
|
||||
public WorkDir workDir;
|
||||
|
||||
@Test
|
||||
public void testJettyEmbedderFromDefaults() throws Exception
|
||||
{
|
||||
Path baseResource = workDir.getEmptyPathDir();
|
||||
MavenWebAppContext webApp = new MavenWebAppContext();
|
||||
webApp.setBaseResource(new PathResource(baseResource));
|
||||
MavenServerConnector connector = new MavenServerConnector();
|
||||
connector.setPort(0);
|
||||
|
||||
|
||||
JettyEmbedder jetty = new JettyEmbedder();
|
||||
jetty.setHttpConnector(connector);
|
||||
jetty.setExitVm(false);
|
||||
|
@ -49,12 +58,12 @@ public class TestJettyEmbedder
|
|||
jetty.setLoginServices(null);
|
||||
jetty.setContextXml(MavenTestingUtils.getTestResourceFile("embedder-context.xml").getAbsolutePath());
|
||||
jetty.setWebApp(webApp);
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
jetty.start();
|
||||
assertEquals("/embedder", webApp.getContextPath());
|
||||
assertTrue(webApp.isStarted());
|
||||
assertTrue(webApp.isAvailable());
|
||||
assertNotNull(jetty.getServer());
|
||||
assertTrue(jetty.getServer().isStarted());
|
||||
assertNotNull(jetty.getServer().getConnectors());
|
||||
|
@ -65,12 +74,14 @@ public class TestJettyEmbedder
|
|||
jetty.stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testJettyEmbedder()
|
||||
throws Exception
|
||||
{
|
||||
MavenWebAppContext webApp = new MavenWebAppContext();
|
||||
Path baseResource = workDir.getEmptyPathDir();
|
||||
webApp.setBaseResource(Resource.newResource(baseResource));
|
||||
Server server = new Server();
|
||||
Map<String,String> jettyProperties = new HashMap<>();
|
||||
jettyProperties.put("jetty.server.dumpAfterStart", "false");
|
||||
|
@ -78,10 +89,10 @@ public class TestJettyEmbedder
|
|||
ContextHandler otherHandler = new ContextHandler();
|
||||
otherHandler.setContextPath("/other");
|
||||
otherHandler.setBaseResource(Resource.newResource(MavenTestingUtils.getTestResourceDir("root")));
|
||||
|
||||
|
||||
MavenServerConnector connector = new MavenServerConnector();
|
||||
connector.setPort(0);
|
||||
|
||||
|
||||
JettyEmbedder jetty = new JettyEmbedder();
|
||||
jetty.setHttpConnector(connector);
|
||||
jetty.setExitVm(false);
|
||||
|
@ -98,7 +109,7 @@ public class TestJettyEmbedder
|
|||
{
|
||||
jetty.start();
|
||||
assertEquals("/embedder", webApp.getContextPath());
|
||||
assertTrue(webApp.isStarted());
|
||||
assertTrue(webApp.isAvailable());
|
||||
assertNotNull(jetty.getServer());
|
||||
assertTrue(jetty.getServer().isStarted());
|
||||
assertNotNull(jetty.getServer().getConnectors());
|
||||
|
|
Loading…
Reference in New Issue