|
| 1 | +package org.javaee7.servlet.resource.packaging; |
| 2 | + |
| 3 | +import org.jboss.arquillian.container.test.api.Deployment; |
| 4 | +import org.jboss.arquillian.junit.Arquillian; |
| 5 | +import org.jboss.arquillian.test.api.ArquillianResource; |
| 6 | +import org.jboss.shrinkwrap.api.ShrinkWrap; |
| 7 | +import org.jboss.shrinkwrap.api.spec.WebArchive; |
| 8 | +import org.junit.Test; |
| 9 | +import org.junit.runner.RunWith; |
| 10 | + |
| 11 | +import javax.ws.rs.client.Client; |
| 12 | +import javax.ws.rs.client.ClientBuilder; |
| 13 | +import javax.ws.rs.client.WebTarget; |
| 14 | +import javax.ws.rs.core.Response; |
| 15 | +import java.io.File; |
| 16 | +import java.net.MalformedURLException; |
| 17 | +import java.net.URISyntaxException; |
| 18 | +import java.net.URL; |
| 19 | + |
| 20 | +import static org.hamcrest.CoreMatchers.equalTo; |
| 21 | +import static org.hamcrest.CoreMatchers.is; |
| 22 | +import static org.hamcrest.CoreMatchers.startsWith; |
| 23 | +import static org.junit.Assert.assertThat; |
| 24 | + |
| 25 | +/** |
| 26 | + * @author Jakub Marchwicki |
| 27 | + */ |
| 28 | +@RunWith(Arquillian.class) |
| 29 | +public class ResourcePackagingTest { |
| 30 | + |
| 31 | + @Deployment(testable = false) |
| 32 | + public static WebArchive deploy() throws URISyntaxException { |
| 33 | + return ShrinkWrap.create(WebArchive.class) |
| 34 | + .addAsLibrary(new File("src/main/webapp/WEB-INF/lib/myResources.jar"), "myResources.jar"); |
| 35 | + } |
| 36 | + |
| 37 | + @ArquillianResource |
| 38 | + private URL base; |
| 39 | + |
| 40 | + @Test |
| 41 | + public void getMyResourceJarStyles() throws MalformedURLException { |
| 42 | + Client client = ClientBuilder.newClient(); |
| 43 | + WebTarget target = client.target(new URL(base, "styles.css").toExternalForm()); |
| 44 | + Response response = target.request().get(); |
| 45 | + |
| 46 | + assertThat(response.getStatus(), is(equalTo(200))); |
| 47 | + |
| 48 | + String style = response.readEntity(String.class); |
| 49 | + assertThat(style, startsWith("body {")); |
| 50 | + } |
| 51 | + |
| 52 | +} |
0 commit comments