Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

WELD-1110 Add test case

  • Loading branch information...
commit c95c6d053099ae4976aeab3198c40071a03b34cf 1 parent 1e01999
@aslakknutsen aslakknutsen authored
View
7 pom.xml
@@ -59,6 +59,7 @@
<jboss.shrinkwrap.descriptors.version>1.1.0-beta-1</jboss.shrinkwrap.descriptors.version>
<jboss.spec.ejb.version>1.0.0.CR2</jboss.spec.ejb.version>
<jboss.spec.servlet.version>1.0.0.Beta2</jboss.spec.servlet.version>
+ <jboss.spec.jaxrs.version>1.0.0.Final</jboss.spec.jaxrs.version>
<jboss.test.harness.version>1.1.0-CR9</jboss.test.harness.version>
<jboss.vfs.version>2.1.3.SP1</jboss.vfs.version>
<jnp-client.version>4.0.2</jnp-client.version>
@@ -350,6 +351,12 @@
</dependency>
<dependency>
+ <groupId>org.jboss.spec.javax.ws.rs</groupId>
+ <artifactId>jboss-jaxrs-api_1.1_spec</artifactId>
+ <version>${jboss.spec.jaxrs.version}</version>
+ </dependency>
+
+ <dependency>
<groupId>org.jboss.test-harness</groupId>
<artifactId>jboss-test-harness</artifactId>
<version>${jboss.test.harness.version}</version>
View
5 tests-arquillian/pom.xml
@@ -117,6 +117,11 @@
</dependency>
<dependency>
+ <groupId>org.jboss.spec.javax.ws.rs</groupId>
+ <artifactId>jboss-jaxrs-api_1.1_spec</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
View
4 tests-arquillian/src/main/java/org/jboss/shrinkwrap/impl/BeansXml.java
@@ -8,13 +8,13 @@
import java.util.Arrays;
import java.util.List;
-class BeansXml implements Asset {
+public class BeansXml implements Asset {
private List<Class<?>> alternatives = new ArrayList<Class<?>>();
private List<Class<?>> interceptors = new ArrayList<Class<?>>();
private List<Class<?>> decorators = new ArrayList<Class<?>>();
private List<Class<?>> stereotypes = new ArrayList<Class<?>>();
- BeansXml() {
+ public BeansXml() {
}
View
14 tests-arquillian/src/test/java/org/jboss/weld/tests/decorators/weld1110/Message.java
@@ -0,0 +1,14 @@
+package org.jboss.weld.tests.decorators.weld1110;
+
+public class Message {
+
+ private String content;
+
+ public Message(String content) {
+ this.content = content;
+ }
+
+ public String getContent() {
+ return content;
+ }
+}
View
20 tests-arquillian/src/test/java/org/jboss/weld/tests/decorators/weld1110/MessageDecorator.java
@@ -0,0 +1,20 @@
+package org.jboss.weld.tests.decorators.weld1110;
+
+import java.io.Serializable;
+
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.inject.Inject;
+
+
+@Decorator
+public abstract class MessageDecorator extends MessageSender implements Serializable {
+
+ @Inject @Delegate
+ private MessageSender sender;
+
+ public Message send(Message message) {
+ Message msg = new Message("Decorated " + message.getContent());
+ return sender.send(msg);
+ }
+}
View
16 tests-arquillian/src/test/java/org/jboss/weld/tests/decorators/weld1110/MessageSender.java
@@ -0,0 +1,16 @@
+package org.jboss.weld.tests.decorators.weld1110;
+
+import javax.ejb.Stateful;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+
+@Stateful
+@Path("message")
+public class MessageSender {
+
+ @GET
+ public Message send(Message message) {
+ return message;
+ }
+
+}
View
46 tests-arquillian/src/test/java/org/jboss/weld/tests/decorators/weld1110/MessageSenderTest.java
@@ -0,0 +1,46 @@
+package org.jboss.weld.tests.decorators.weld1110;
+
+import java.net.URL;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.shrinkwrap.impl.BeansXml;
+import org.jboss.weld.tests.category.Integration;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+
+@RunWith(Arquillian.class)
+@Category(Integration.class)
+public class MessageSenderTest {
+
+ @Deployment(testable = false)
+ public static WebArchive create() {
+ return ShrinkWrap.create(WebArchive.class)
+ .addPackage(Message.class.getPackage())
+ .setWebXML(new StringAsset(
+ "<web-app>" +
+ "<display-name>jax</display-name>" +
+ "<servlet-mapping>" +
+ "<servlet-name>javax.ws.rs.core.Application</servlet-name>" +
+ "<url-pattern>/rest/*</url-pattern>" +
+ "</servlet-mapping>" +
+ "</web-app>"))
+ .addAsWebInfResource(
+ new BeansXml().decorators(MessageDecorator.class), "beans.xml");
+ }
+
+ @ArquillianResource
+ private URL base;
+
+ @Test
+ public void shouldBeAbleToDecorateEJB() throws Exception {
+ // should probably assert on 'osomething'
+ new URL(base, "rest/message").openStream();
+ }
+}
View
4 tests-arquillian/src/test/resources/arquillian.xml
@@ -4,6 +4,10 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
+ <engine>
+ <property name="deploymentExportPath">target/</property>
+ </engine>
+
<container qualifier="weld" default="true">
<configuration>
<property name="enableConversationScope">true</property>
Please sign in to comment.
Something went wrong with that request. Please try again.