use of org.wildfly.swarm.undertow.WARArchive in project wildfly-swarm by wildfly-swarm.
the class ContextPathArchivePreparerTest method testContextPathProperty.
@Test
public void testContextPathProperty() throws Exception {
WARArchive archive = DefaultWarDeploymentFactory.archiveFromCurrentApp();
assertThat(archive.getContextRoot()).isNull();
ContextPathArchivePreparer preparer = new ContextPathArchivePreparer(archive);
preparer.contextPath.set("/another-root");
preparer.process();
assertThat(archive.getContextRoot()).isNotNull();
assertThat(archive.getContextRoot()).isEqualTo("/another-root");
}
use of org.wildfly.swarm.undertow.WARArchive in project wildfly-swarm by wildfly-swarm.
the class ContextPathArchivePreparerTest method testDefaultContextRootWontOverride.
@Test
public void testDefaultContextRootWontOverride() throws Exception {
WARArchive archive = DefaultWarDeploymentFactory.archiveFromCurrentApp();
assertThat(archive.getContextRoot()).isNull();
archive.setContextRoot("myRoot");
assertThat(archive.getContextRoot()).isNotNull();
assertThat(archive.getContextRoot()).isEqualTo("myRoot");
new ContextPathArchivePreparer(archive).process();
assertThat(archive.getContextRoot()).isNotNull();
assertThat(archive.getContextRoot()).isEqualTo("myRoot");
}
use of org.wildfly.swarm.undertow.WARArchive in project wildfly-swarm by wildfly-swarm.
the class ContextPathArchivePreparerTest method testDefaultContextRoot.
@Test
public void testDefaultContextRoot() throws Exception {
WARArchive archive = DefaultWarDeploymentFactory.archiveFromCurrentApp();
assertThat(archive.getContextRoot()).isNull();
ContextPathArchivePreparer processor = new ContextPathArchivePreparer(archive);
processor.process();
assertThat(archive.getContextRoot()).isNotNull();
assertThat(archive.getContextRoot()).isEqualTo("/");
}
use of org.wildfly.swarm.undertow.WARArchive in project wildfly-swarm by wildfly-swarm.
the class ContextPathArchivePreparerTest method testExternalMount.
@SuppressWarnings("unchecked")
@Test
public void testExternalMount() throws Exception {
WARArchive archive = DefaultWarDeploymentFactory.archiveFromCurrentApp();
assertThat(archive.getContextRoot()).isNull();
URL url = getClass().getClassLoader().getResource("mounts.yml");
ConfigViewFactory factory = new ConfigViewFactory(new Properties());
factory.load("test", url);
factory.withProfile("test");
ConfigViewImpl view = factory.get(true);
List<String> mounts = view.resolve("swarm.context.mounts").as(List.class).getValue();
ContextPathArchivePreparer preparer = new ContextPathArchivePreparer(archive);
preparer.mounts = mounts;
preparer.process();
Node externalMount = archive.get(WARArchive.EXTERNAL_MOUNT_PATH);
assertThat(externalMount).isNotNull();
assertThat(externalMount.getAsset()).isInstanceOf(UndertowExternalMountsAsset.class);
UndertowExternalMountsAsset externalMountAsset = (UndertowExternalMountsAsset) externalMount.getAsset();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(externalMountAsset.openStream()))) {
assertThat(reader.readLine()).endsWith("external1");
assertThat(reader.readLine()).endsWith("external2");
}
}
use of org.wildfly.swarm.undertow.WARArchive in project wildfly-swarm by wildfly-swarm.
the class SecuredTest method testExistingWebXml.
@Test
public void testExistingWebXml() {
WARArchive archive = ShrinkWrap.create(WARArchive.class);
ClassLoaderAsset asset = new ClassLoaderAsset("test-web.xml");
archive.addAsWebInfResource(asset, "web.xml");
archive.as(Secured.class).protect("/cheddar");
Node webXml = archive.get("WEB-INF/web.xml");
Asset newAsset = webXml.getAsset();
InputStream in = newAsset.openStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
List<String> lines = reader.lines().map(String::trim).collect(Collectors.toList());
assertThat(lines).contains("<servlet-name>comingsoon</servlet-name>");
assertThat(lines).contains("<url-pattern>/cheddar</url-pattern>");
}
Aggregations