Skip to content

Commit

Permalink
RESTEASY-945: Added arquillian test.
Browse files Browse the repository at this point in the history
  • Loading branch information
ronsigal committed May 15, 2014
1 parent 5ce4ae0 commit f4e516d
Show file tree
Hide file tree
Showing 13 changed files with 740 additions and 0 deletions.
2 changes: 2 additions & 0 deletions jaxrs/arquillian/RESTEASY-945-WF8/.gitignore
@@ -0,0 +1,2 @@
/target
.DS_Store
201 changes: 201 additions & 0 deletions jaxrs/arquillian/RESTEASY-945-WF8/pom.xml
@@ -0,0 +1,201 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs-all</artifactId>
<version>3.0.8.Final</version>
<relativePath>../../pom.xml</relativePath>
</parent>

<artifactId>RESTEASY-945-WF8</artifactId>
<packaging>jar</packaging>
<name>RESTEASY-945-WF8</name>
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<as-version>8.0.0.Final</as-version>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>process-test-classes</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-dist</artifactId>
<version>${as-version}</version>
<type>zip</type>
<overWrite>false</overWrite>
<outputDirectory>target</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>unpack resteasy</id>
<phase>process-test-classes</phase>
<configuration>
<target>
<unzip src="../../jboss-modules/target/resteasy-jboss-modules-wf8-${project.version}.zip"
dest="${project.build.directory}/wildfly-${as-version}/modules/system/layers/base"
overwrite="false" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
<!--execution>
<id>unpack resteasy</id>
<phase>process-test-classes</phase>
<configuration>
<target>
<copydir src="/home/rsigal/git.wildfly/wildfly/build/target/wildfly-8.0.1.Final-SNAPSHOT"
dest="${project.build.directory}/wildfly-8.0.1.Final-SNAPSHOT"/>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution-->
</executions>
</plugin>
</plugins>
</build>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>1.0.3.Final</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<version>1.0.0.Final</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
<!--dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-arquillian-container-managed</artifactId>
<version>7.1.1.Final</version>
<scope>test</scope>
</dependency-->
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-arquillian-container-managed</artifactId>
<version>8.0.0.CR1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.protocol</groupId>
<artifactId>arquillian-protocol-servlet</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>jaxrs-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-validator-provider-11</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxb-provider</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.1.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,25 @@
package org.jboss.resteasy.resteasy945;

import java.util.HashSet;
import java.util.Set;

import javax.ws.rs.core.Application;
import javax.ws.rs.ext.Provider;

/**
*
* @author <a href="ron.sigal@jboss.com">Ron Sigal</a>
* @version $Revision: 1.1 $
*
* Copyright Mar 5, 2013
*/
@Provider
public class TestApplication extends Application
{
public Set<Class<?>> getClasses()
{
HashSet<Class<?>> classes = new HashSet<Class<?>>();
classes.add(TestResource.class);
return classes;
}
}
@@ -0,0 +1,23 @@
package org.jboss.resteasy.resteasy945;

import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import javax.validation.Constraint;
import javax.validation.Payload;

@Documented
@Constraint(validatedBy = TestClassValidator.class)
@Target({TYPE})
@Retention(RUNTIME)
public @interface TestClassConstraint
{
String message() default "Concatenation of s and t must have length > {value}";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
int value();
}
@@ -0,0 +1,27 @@
package org.jboss.resteasy.resteasy945;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
*
* @author <a href="ron.sigal@jboss.com">Ron Sigal</a>
* @version $Revision: 1.1 $
*
* Copyright May 14, 2014
*/
public class TestClassValidator implements ConstraintValidator<TestClassConstraint, TestResource>
{
int length;

public void initialize(TestClassConstraint constraintAnnotation)
{
length = constraintAnnotation.value();
}

public boolean isValid(TestResource value, ConstraintValidatorContext context)
{
boolean b = value.retrieveS().length() + value.getT().length() >= length;
return b;
}
}
@@ -0,0 +1,53 @@
package org.jboss.resteasy.resteasy945;

import javax.validation.constraints.Size;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

/**
* RESTEASY-945
*
* @author <a href="ron.sigal@jboss.com">Ron Sigal</a>
* @version $Revision: 1.1 $
*
* Copyright May 14, 2014
*/
@Path("all")
@TestClassConstraint(5)
public class TestResource
{
@Size(min=2, max=4)
@PathParam("s")
String s;

private String t;

@Size(min=3, max=5)
public String getT()
{
return t;
}

public String retrieveS()
{
return s;
}

@PathParam("t")
public void setT(String t)
{
this.t = t;
}

@GET
@Path("{s}/{t}/{u}")
@Size(max=3)
@Produces(MediaType.TEXT_PLAIN)
public String test(@Size(min=4, max=6) @PathParam("u") String u)
{
return s + t + u;
}
}

0 comments on commit f4e516d

Please sign in to comment.