ARTEMIS-4525 determinstic webapp directory names
This commit uses the war file name as the webapp directory name instead of the default directory name that includes random charcters.
This commit is contained in:
parent
ffaa057ce1
commit
15dd24754a
|
@ -379,7 +379,9 @@ public class WebServerComponent implements ExternalComponent, WebServerComponent
|
|||
|
||||
webapp.setWar(warDirectory.resolve(warFile).toString());
|
||||
|
||||
webapp.setAttribute("org.eclipse.jetty.webapp.basetempdir", temporaryWarDir.toFile().getAbsolutePath());
|
||||
String baseTempDir = temporaryWarDir.toFile().getAbsolutePath();
|
||||
webapp.setAttribute("org.eclipse.jetty.webapp.basetempdir", baseTempDir);
|
||||
webapp.setTempDirectory(new File(baseTempDir + File.separator + warFile));
|
||||
|
||||
// Set the default authenticator factory to avoid NPE due to the following commit:
|
||||
// https://github.com/eclipse/jetty.project/commit/7e91d34177a880ecbe70009e8f200d02e3a0c5dd
|
||||
|
|
|
@ -560,15 +560,8 @@ public class WebServerComponentTest extends Assert {
|
|||
createTestWar(warName);
|
||||
final String url = "simple-app/";
|
||||
|
||||
AppDTO app = new AppDTO();
|
||||
app.url = url;
|
||||
app.war = warName;
|
||||
BindingDTO bindingDTO = new BindingDTO();
|
||||
bindingDTO.uri = "http://localhost:0";
|
||||
bindingDTO.apps = new ArrayList<>();
|
||||
WebServerDTO webServerDTO = new WebServerDTO();
|
||||
webServerDTO.setBindings(Collections.singletonList(bindingDTO));
|
||||
webServerDTO.path = "";
|
||||
WebServerDTO webServerDTO = createDefaultWebServerDTO(warName, url);
|
||||
|
||||
WebServerComponent webServerComponent = new WebServerComponent();
|
||||
Assert.assertFalse(webServerComponent.isStarted());
|
||||
testedComponents.add(webServerComponent);
|
||||
|
@ -603,6 +596,30 @@ public class WebServerComponentTest extends Assert {
|
|||
Assert.assertFalse(webServerComponent.isStarted());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testServerDeterministicWebappName() throws Exception {
|
||||
final String warName = "simple-app.war";
|
||||
createTestWar(warName);
|
||||
final String url = "simple-app/";
|
||||
|
||||
WebServerDTO webServerDTO = createDefaultWebServerDTO(warName, url);
|
||||
WebServerComponent webServerComponent = new WebServerComponent();
|
||||
webServerComponent.configure(webServerDTO, "./target", "./target");
|
||||
WebAppContext ctxt = WebServerComponentTestAccessor.createWebAppContext(webServerComponent, url, warName, Paths.get(".").resolve("target").toAbsolutePath(), null);
|
||||
testedComponents.add(webServerComponent);
|
||||
|
||||
Assert.assertFalse(webServerComponent.isStarted());
|
||||
webServerComponent.start();
|
||||
|
||||
File tmpDir = ctxt.getTempDirectory();
|
||||
Assert.assertTrue(tmpDir.getParentFile().listFiles().length == 1);
|
||||
Assert.assertEquals(tmpDir.getName(), warName);
|
||||
Assert.assertTrue(webServerComponent.isStarted());
|
||||
|
||||
webServerComponent.stop(true);
|
||||
Assert.assertFalse(webServerComponent.isStarted());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultRootRedirect() throws Exception {
|
||||
testRootRedirect(null, 404, null);
|
||||
|
@ -642,6 +659,20 @@ public class WebServerComponentTest extends Assert {
|
|||
}
|
||||
}
|
||||
|
||||
private static WebServerDTO createDefaultWebServerDTO(String warName, String url) {
|
||||
AppDTO app = new AppDTO();
|
||||
app.url = url;
|
||||
app.war = warName;
|
||||
BindingDTO bindingDTO = new BindingDTO();
|
||||
bindingDTO.uri = "http://localhost:0";
|
||||
bindingDTO.apps = new ArrayList<>();
|
||||
bindingDTO.apps.add(app);
|
||||
WebServerDTO webServerDTO = new WebServerDTO();
|
||||
webServerDTO.setBindings(Collections.singletonList(bindingDTO));
|
||||
webServerDTO.path = "";
|
||||
return webServerDTO;
|
||||
}
|
||||
|
||||
private void createTestWar(String warName) throws Exception {
|
||||
File warFile = new File("target", warName);
|
||||
File srcFile = new File("src/test/webapp");
|
||||
|
|
Loading…
Reference in New Issue