Skip to content

Commit f0c7930

Browse files
committed
Resteasy/CDI/EJB/AS 7 test suite.
1 parent 47ede5e commit f0c7930

File tree

158 files changed

+11087
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+11087
-0
lines changed

.project

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>Resteasy</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.m2e.core.maven2Builder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
16+
</natures>
17+
</projectDescription>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/target
2+
.DS_Store
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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">
3+
<modelVersion>4.0.0</modelVersion>
4+
<parent>
5+
<groupId>org.jboss.resteasy</groupId>
6+
<artifactId>resteasy-jaxrs-all</artifactId>
7+
<version>3.0-alpha-1-SNAPSHOT</version>
8+
<relativePath>../../pom.xml</relativePath>
9+
</parent>
10+
<artifactId>resteasy-cdi-ejb-test</artifactId>
11+
<packaging>jar</packaging>
12+
<name>Resteasy AS7 Integration Testsuite</name>
13+
14+
<properties>
15+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
16+
</properties>
17+
18+
<dependencyManagement>
19+
<dependencies>
20+
<dependency>
21+
<groupId>org.jboss.arquillian</groupId>
22+
<artifactId>arquillian-bom</artifactId>
23+
<version>1.0.0.Final</version>
24+
<scope>import</scope>
25+
<type>pom</type>
26+
</dependency>
27+
</dependencies>
28+
</dependencyManagement>
29+
30+
<build>
31+
<plugins>
32+
<plugin>
33+
<groupId>org.apache.maven.plugins</groupId>
34+
<artifactId>maven-compiler-plugin</artifactId>
35+
<version>2.3.2</version>
36+
<configuration>
37+
<source>1.6</source>
38+
<target>1.6</target>
39+
</configuration>
40+
</plugin>
41+
<plugin>
42+
<groupId>org.apache.maven.plugins</groupId>
43+
<artifactId>maven-surefire-plugin</artifactId>
44+
<version>2.12</version>
45+
</plugin>
46+
<plugin>
47+
<artifactId>maven-dependency-plugin</artifactId>
48+
<executions>
49+
<execution>
50+
<id>unpack</id>
51+
<phase>process-test-classes</phase>
52+
<goals>
53+
<goal>unpack</goal>
54+
</goals>
55+
<configuration>
56+
<artifactItems>
57+
<artifactItem>
58+
<groupId>org.jboss.as</groupId>
59+
<artifactId>jboss-as-dist</artifactId>
60+
<version>7.1.1.Final</version>
61+
<type>zip</type>
62+
<overWrite>false</overWrite>
63+
<outputDirectory>target</outputDirectory>
64+
</artifactItem>
65+
</artifactItems>
66+
</configuration>
67+
</execution>
68+
</executions>
69+
</plugin>
70+
</plugins>
71+
<testResources>
72+
<testResource>
73+
<directory>src/test/resources</directory>
74+
</testResource>
75+
</testResources>
76+
</build>
77+
78+
<dependencies>
79+
<dependency>
80+
<groupId>org.hornetq</groupId>
81+
<artifactId>hornetq-jms-client</artifactId>
82+
<version>2.2.13.Final</version>
83+
</dependency>
84+
<dependency>
85+
<groupId>org.jboss.weld</groupId>
86+
<artifactId>weld-core</artifactId>
87+
<version>1.1.5.AS71.Final</version>
88+
</dependency>
89+
<dependency>
90+
<groupId>org.jboss.spec</groupId>
91+
<artifactId>jboss-javaee-6.0</artifactId>
92+
<version>1.0.0.Final</version>
93+
<type>pom</type>
94+
<scope>provided</scope>
95+
</dependency>
96+
<dependency>
97+
<groupId>org.jboss.spec.javax.ejb</groupId>
98+
<artifactId>jboss-ejb-api_3.1_spec</artifactId>
99+
<version>1.0.1.Final</version>
100+
<scope>provided</scope>
101+
</dependency>
102+
<dependency>
103+
<groupId>org.jboss.as</groupId>
104+
<artifactId>jboss-as-arquillian-container-managed</artifactId>
105+
<version>7.1.1.Final</version>
106+
<scope>test</scope>
107+
</dependency>
108+
<dependency>
109+
<groupId>org.jboss.arquillian.protocol</groupId>
110+
<artifactId>arquillian-protocol-servlet</artifactId>
111+
<scope>test</scope>
112+
</dependency>
113+
<dependency>
114+
<groupId>org.jboss.resteasy</groupId>
115+
<artifactId>jaxrs-api</artifactId>
116+
<version>${project.version}</version>
117+
</dependency>
118+
<dependency>
119+
<groupId>org.jboss.resteasy</groupId>
120+
<artifactId>resteasy-jaxrs</artifactId>
121+
<version>${project.version}</version>
122+
</dependency>
123+
<dependency>
124+
<groupId>org.jboss.resteasy</groupId>
125+
<artifactId>resteasy-jaxb-provider</artifactId>
126+
<version>${project.version}</version>
127+
</dependency>
128+
<dependency>
129+
<groupId>junit</groupId>
130+
<artifactId>junit</artifactId>
131+
<version>4.8.1</version>
132+
<!--scope>test</scope-->
133+
</dependency>
134+
<dependency>
135+
<groupId>org.jboss.arquillian.junit</groupId>
136+
<artifactId>arquillian-junit-container</artifactId>
137+
<scope>test</scope>
138+
</dependency>
139+
<!--dependency>
140+
<groupId>org.jboss.arquillian.container</groupId>
141+
<artifactId>arquillian-weld-ee-embedded-1.1</artifactId>
142+
<version>1.0.0.CR3</version>
143+
<scope>test</scope>
144+
</dependency>
145+
<dependency>
146+
<groupId>org.jboss.weld</groupId>
147+
<artifactId>weld-core</artifactId>
148+
<version>1.1.5.Final</version>
149+
<scope>test</scope>
150+
</dependency-->
151+
<dependency>
152+
<groupId>org.slf4j</groupId>
153+
<artifactId>slf4j-simple</artifactId>
154+
<version>1.6.4</version>
155+
<scope>test</scope>
156+
</dependency>
157+
<dependency>
158+
<groupId>org.jboss.resteasy</groupId>
159+
<artifactId>resteasy-cdi</artifactId>
160+
<version>${project.version}</version>
161+
</dependency>
162+
</dependencies>
163+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package org.jboss.resteasy.cdi.decorators;
2+
3+
import javax.persistence.Entity;
4+
import javax.persistence.Id;
5+
import javax.validation.constraints.NotNull;
6+
import javax.validation.constraints.Size;
7+
import javax.xml.bind.annotation.XmlAccessType;
8+
import javax.xml.bind.annotation.XmlAccessorType;
9+
import javax.xml.bind.annotation.XmlElement;
10+
import javax.xml.bind.annotation.XmlRootElement;
11+
12+
/**
13+
* Book is
14+
*
15+
* 1) a JAXB class, suitable for transport over the network, and
16+
* 2) an @Entity class, suitable for JPA storage
17+
*
18+
* @author <a href="[email protected]">Ron Sigal</a>
19+
* @version $Revision: 1 $
20+
*/
21+
@Entity
22+
@XmlRootElement(name = "book")
23+
@XmlAccessorType(XmlAccessType.FIELD)
24+
public class Book
25+
{
26+
@XmlElement
27+
private int id;
28+
29+
@XmlElement
30+
@NotNull
31+
@Size(min = 1, max = 25)
32+
private String name;
33+
34+
public Book()
35+
{
36+
}
37+
public Book(String name)
38+
{
39+
this.name = name;
40+
}
41+
public Book(int id, String name)
42+
{
43+
this.id = id;
44+
this.name = name;
45+
}
46+
47+
@Id
48+
public int getId()
49+
{
50+
return id;
51+
}
52+
public void setId(int id)
53+
{
54+
this.id = id;
55+
}
56+
57+
58+
public String getName()
59+
{
60+
return name;
61+
}
62+
public void setName(String name)
63+
{
64+
this.name = name;
65+
}
66+
67+
public String toString()
68+
{
69+
return "Book[" + id + "," + name + "]";
70+
}
71+
72+
public boolean equals(Object o)
73+
{
74+
if (o == null || ! (o instanceof Book))
75+
{
76+
return false;
77+
}
78+
return name.equals(((Book) o).name);
79+
}
80+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package org.jboss.resteasy.cdi.decorators;
2+
3+
import java.io.IOException;
4+
import java.io.InputStream;
5+
import java.lang.annotation.Annotation;
6+
import java.lang.reflect.Type;
7+
import java.util.logging.Logger;
8+
9+
import javax.inject.Inject;
10+
import javax.ws.rs.Consumes;
11+
import javax.ws.rs.WebApplicationException;
12+
import javax.ws.rs.core.MediaType;
13+
import javax.ws.rs.core.MultivaluedMap;
14+
import javax.ws.rs.ext.MessageBodyReader;
15+
import javax.ws.rs.ext.Provider;
16+
17+
import org.jboss.resteasy.cdi.util.Constants;
18+
import org.jboss.resteasy.spi.ResteasyProviderFactory;
19+
20+
/**
21+
*
22+
* @author <a href="[email protected]">Ron Sigal</a>
23+
* @version $Revision: 1.1 $
24+
*
25+
* Copyright Nov 14, 2012
26+
*/
27+
@Provider
28+
@Consumes(Constants.MEDIA_TYPE_TEST_XML)
29+
public class BookReader implements MessageBodyReader<Book>
30+
{
31+
static private MessageBodyReader<Book> delegate;
32+
33+
@Inject private Logger log;
34+
35+
static
36+
{
37+
System.out.println("In BookReader static {}");
38+
ResteasyProviderFactory factory = ResteasyProviderFactory.getInstance();
39+
delegate = factory.getMessageBodyReader(Book.class, null, null, Constants.MEDIA_TYPE_TEST_XML_TYPE);
40+
System.out.println("In BookReader static {}");
41+
}
42+
43+
public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType)
44+
{
45+
System.out.println("entering BookReader.isReadable()");
46+
boolean b = Book.class.equals(type);
47+
System.out.println("leaving BookReader.isReadable()");
48+
return b;
49+
}
50+
51+
public Book readFrom(Class<Book> type, Type genericType,
52+
Annotation[] annotations, MediaType mediaType,
53+
MultivaluedMap<String, String> httpHeaders, InputStream entityStream)
54+
throws IOException, WebApplicationException
55+
{
56+
log.info("entering BookReader.readFrom()");
57+
Book book = Book.class.cast(delegate.readFrom(Book.class, genericType, annotations, mediaType, httpHeaders, entityStream));
58+
log.info("BookReader.readFrom() read " + book);
59+
log.info("leaving BookReader.readFrom()");
60+
return book;
61+
}
62+
}
63+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package org.jboss.resteasy.cdi.decorators;
2+
3+
import java.io.IOException;
4+
import java.io.InputStream;
5+
import java.lang.annotation.Annotation;
6+
import java.lang.reflect.Type;
7+
import java.util.logging.Logger;
8+
9+
import javax.decorator.Decorator;
10+
import javax.decorator.Delegate;
11+
import javax.inject.Inject;
12+
import javax.ws.rs.WebApplicationException;
13+
import javax.ws.rs.core.MediaType;
14+
import javax.ws.rs.core.MultivaluedMap;
15+
import javax.ws.rs.ext.MessageBodyReader;
16+
17+
/**
18+
*
19+
* @author <a href="[email protected]">Ron Sigal</a>
20+
* @version $Revision: 1.1 $
21+
*
22+
* Copyright Nov 13, 2012
23+
*/
24+
@Decorator
25+
public abstract class BookReaderDecorator implements MessageBodyReader<Book>
26+
{
27+
@Inject private Logger log;
28+
@Inject private @Delegate MessageBodyReader<Book> reader;
29+
30+
@Override
31+
public Book readFrom(Class<Book> type, Type genericType,
32+
Annotation[] annotations, MediaType mediaType,
33+
MultivaluedMap<String, String> httpHeaders, InputStream entityStream)
34+
throws IOException, WebApplicationException
35+
{
36+
log.info("entering BookReaderDecorator.readFrom()");
37+
VisitList.add(VisitList.READER_DECORATOR_ENTER);
38+
Book b = reader.readFrom(type, genericType, annotations, mediaType, httpHeaders, entityStream);
39+
VisitList.add(VisitList.READER_DECORATOR_LEAVE);
40+
log.info("leaving BookReaderDecorator.readFrom()");
41+
return b;
42+
}
43+
}

0 commit comments

Comments
 (0)