This repository has been archived by the owner on Jun 7, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delegate all static resource handling to Undertow itself
For hot reloading of changes during development, we now write out a WEB-INF/undertow-external-mounts.conf. A side-effect of this is that static content is now always served out of the same context as your application. If static content needs to be served at a different context than your application then that static content needs to reside in a subdirectory of src/main/resources or src/main/webapp.
- Loading branch information
Showing
10 changed files
with
175 additions
and
665 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...test/java/org/wildfly/swarm/integration/staticcontent/war/StaticContentWarSubdirTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package org.wildfly.swarm.integration.staticcontent.war; | ||
|
||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.container.test.api.RunAsClient; | ||
import org.jboss.arquillian.drone.api.annotation.Drone; | ||
import org.jboss.arquillian.junit.Arquillian; | ||
import org.jboss.arquillian.test.api.ArquillianResource; | ||
import org.jboss.shrinkwrap.api.Archive; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.openqa.selenium.WebDriver; | ||
import org.wildfly.swarm.arquillian.adapter.ArtifactDependencies; | ||
import org.wildfly.swarm.undertow.WARArchive; | ||
|
||
import java.net.URL; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import static org.fest.assertions.Assertions.assertThat; | ||
|
||
@RunWith(Arquillian.class) | ||
public class StaticContentWarSubdirTest { | ||
@ArquillianResource | ||
URL contextRoot; | ||
|
||
@Drone | ||
WebDriver browser; | ||
|
||
@Deployment | ||
public static Archive createDeployment() throws Exception { | ||
WARArchive deployment = ShrinkWrap.create(WARArchive.class); | ||
deployment.staticContent("foo"); | ||
// Make sure we're testing from contents inside the jar only | ||
deployment.delete("WEB-INF/undertow-external-mounts.conf"); | ||
return deployment; | ||
} | ||
|
||
@ArtifactDependencies | ||
public static List<String> appDependencies() { | ||
return Arrays.asList( | ||
"org.wildfly.swarm:wildfly-swarm-undertow" | ||
); | ||
} | ||
|
||
@RunAsClient | ||
@Test | ||
public void testStaticContent() throws Exception { | ||
assertContains("", "This is foo/index.html."); | ||
assertContains("index.html", "This is foo/index.html."); | ||
} | ||
|
||
public void assertContains(String path, String content) throws Exception { | ||
browser.navigate().to(contextRoot + path); | ||
assertThat(browser.getPageSource()).contains(content); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
undertow/api/src/main/java/org/wildfly/swarm/undertow/UndertowExternalMountsAsset.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.wildfly.swarm.undertow; | ||
|
||
import org.jboss.shrinkwrap.api.asset.Asset; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.InputStream; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class UndertowExternalMountsAsset implements Asset { | ||
private List<String> externalMounts = new ArrayList<>(); | ||
|
||
public void externalMount(String path) { | ||
externalMounts.add(path); | ||
} | ||
|
||
@Override | ||
public InputStream openStream() { | ||
StringBuilder conf = new StringBuilder(); | ||
for (String each : this.externalMounts) { | ||
conf.append(each + "\n"); | ||
} | ||
return new ByteArrayInputStream(conf.toString().getBytes()); | ||
} | ||
} |
46 changes: 0 additions & 46 deletions
46
undertow/api/src/main/java/org/wildfly/swarm/undertow/UndertowHandlersAsset.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.