Skip to content

Commit

Permalink
[RESTEASY-1651] Enhance UndertowTest and HeadersInViewResponseTest
Browse files Browse the repository at this point in the history
  • Loading branch information
kanovotn authored and asoldano committed May 15, 2017
1 parent 19e574e commit 39db3a5
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 42 deletions.
Expand Up @@ -4,6 +4,7 @@
import org.apache.logging.log4j.Logger;
import org.jboss.resteasy.api.validation.ResteasyViolationException;
import org.jboss.resteasy.api.validation.ViolationReport;
import org.jboss.resteasy.utils.maven.MavenUtil;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ArchivePath;
import org.jboss.shrinkwrap.api.ShrinkWrap;
Expand Down Expand Up @@ -339,4 +340,34 @@ public static void countViolations(ViolationReport e, int fieldCount, int proper
Assert.assertEquals(parameterCount, e.getParameterViolations().size());
Assert.assertEquals(returnValueCount, e.getReturnValueViolations().size());
}

/**
* Get specified single dependency
*
* @param dependency
* @return Dependency gav
*/
public static File resolveDependency(String dependency) {
MavenUtil mavenUtil;
mavenUtil = MavenUtil.create(true);
File mavenGav;

try {
mavenGav = mavenUtil.createMavenGavFile(dependency);
} catch (Exception e) {
throw new RuntimeException("Unable to get artifacts from maven via Aether library", e);
}

return mavenGav;
}

/**
* Adds additional dependency needed for the deployment tests. Specified by parameter in the format 'groupId:artifactId:version'
*
* @param archive
* @param dependency
*/
public static void addOtherLibrary(WebArchive archive, String dependency) {
archive.addAsLibrary(resolveDependency(dependency));
}
}
Expand Up @@ -64,26 +64,6 @@ private static File[] resolveSpringDependencies(String springVersion) {
return dependencies;
}

/**
* Get specified single dependency
*
* @param dependency
* @return Dependency gav
*/
private static File resolveDependency(String dependency) {
MavenUtil mavenUtil;
mavenUtil = MavenUtil.create(true);
File mavenGav;

try {
mavenGav = mavenUtil.createMavenGavFile(dependency);
} catch (Exception e) {
throw new RuntimeException("Unable to get artifacts from maven via Aether library", e);
}

return mavenGav;
}

/**
* Adds Spring libraries and its dependencies into webarchove
*
Expand All @@ -93,13 +73,4 @@ public static void addSpringLibraries(WebArchive archive) {
archive.addAsLibraries(resolveSpringDependencies(getSpringVersion()));
}

/**
* Adds additional dependency needed for Spring tests. Specified by parameter in the format 'groupId:artifactId:version'
*
* @param archive
* @param dependency
*/
public static void addOtherLibrary(WebArchive archive, String dependency) {
archive.addAsLibrary(resolveDependency(dependency));
}
}
Expand Up @@ -23,6 +23,7 @@
import org.jboss.resteasy.test.spring.deployment.resource.SpringBeanProcessorScannedResource;
import org.jboss.resteasy.util.HttpResponseCodes;
import org.jboss.resteasy.utils.PortProviderUtil;
import org.jboss.resteasy.utils.TestUtil;
import org.jboss.resteasy.utils.TestUtilSpring;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
Expand Down Expand Up @@ -87,7 +88,7 @@ private static Archive<?> deploy() {
archive.addClass(SpringBeanProcessorCustomerStringConverter.class);
archive.addClass(SpringBeanProcessorScannedResource.class);
TestUtilSpring.addSpringLibraries(archive);
TestUtilSpring.addOtherLibrary(archive, "aopalliance:aopalliance:" + System.getProperty("version.aopalliance", "1.0"));
TestUtil.addOtherLibrary(archive, "aopalliance:aopalliance:" + System.getProperty("version.aopalliance", "1.0"));
return archive;
}

Expand Down
Expand Up @@ -43,7 +43,7 @@ public static Archive<?> createTestArchive() {
new PropertyPermission("ipv6", "read"),
new RuntimePermission("getenv.RESTEASY_PORT"),
new PropertyPermission("org.jboss.resteasy.port", "read"),
new SocketPermission(PortProviderUtil.getHost(), "connect,resolve")), "permissions.xml");
new SocketPermission("[" + PortProviderUtil.getHost() + "]", "connect,resolve")), "permissions.xml");
return war;
}

Expand Down
Expand Up @@ -11,6 +11,7 @@
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.resteasy.category.NotForForwardCompatibility;
import org.jboss.resteasy.test.providers.file.resource.TempFileDeletionResource;
import org.jboss.resteasy.util.HttpResponseCodes;
import org.jboss.resteasy.utils.PortProviderUtil;
Expand All @@ -20,6 +21,7 @@
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.experimental.categories.Category;

/**
* @tpSubChapter File provider
Expand All @@ -37,9 +39,13 @@ public static Archive<?> deploy() {
}

/**
* @tpTestDetails Resource method contains parameter of the type File. This triggers File provider, which creates
* temporary file on the server side, which is automatically deleted in the end of the resource method invocation.
* @tpInfo Regression test for RESTEASY-1464
* @tpSince RESTEasy 3.0.23.Final
*/
@Test
@Category(NotForForwardCompatibility.class)
public void testDeleteOnServer() throws Exception {
Client client = ClientBuilder.newClient();
WebTarget base = client.target(PortProviderUtil.generateURL("/test/post", TempFileDeletionTest.class.getSimpleName()));
Expand Down
Expand Up @@ -12,6 +12,7 @@
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.resteasy.category.NotForForwardCompatibility;
import org.jboss.resteasy.client.jaxrs.ResteasyClient;
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
import org.jboss.resteasy.test.providers.html.resource.HeadersInViewResponseResource;
Expand All @@ -23,6 +24,7 @@
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;

/**
Expand Down Expand Up @@ -63,6 +65,7 @@ private String generateURL(String path) {
* @tpSince RESTEasy 3.1.3.Final
*/
@Test
@Category(NotForForwardCompatibility.class)
public void testView() throws Exception {

Invocation.Builder request = client.target(generateURL("/test/get")).request();
Expand All @@ -74,20 +77,23 @@ public void testView() throws Exception {
Assert.assertEquals("value2", map.get("name2").getValue());
}

private static File getResteasyHtmlJar()
{
private static File getResteasyHtmlJar() {

// Find resteasy-html jar in target
Path path = Paths.get("..", "..", "providers", "resteasy-html", "target");
String s = path.toAbsolutePath().toString();
System.out.println("s: " + s);
File dir = new File(s);
for (File file : dir.listFiles())
{
String name = file.getName();
if (name.startsWith("resteasy-html") && name.endsWith(".jar") && !name.contains("sources"))
{
return file;
}
if (dir.exists() && dir.isDirectory()) {
for (File file : dir.listFiles()) {
String name = file.getName();
if (name.startsWith("resteasy-html") && name.endsWith(".jar") && !name.contains("sources")) {
return file;
}
}
}
return null;

// If not found in target, try repository
String version = System.getProperty("project.version");
return TestUtil.resolveDependency("org.jboss.resteasy:resteasy-html:" + version);
}
}

0 comments on commit 39db3a5

Please sign in to comment.