Skip to content

Commit 66fcd01

Browse files
committed
Merge pull request #143 from hasalex/cdi
Adding Arquillian tests to some cdi examples
2 parents 5c23c50 + b875ef1 commit 66fcd01

File tree

19 files changed

+186
-652
lines changed

19 files changed

+186
-652
lines changed

cdi/alternatives/pom.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,5 @@
88
<relativePath>../pom.xml</relativePath>
99
</parent>
1010

11-
<groupId>org.javaee7.cdi</groupId>
1211
<artifactId>alternatives</artifactId>
13-
<version>1.0-SNAPSHOT</version>
14-
<packaging>war</packaging>
1512
</project>

cdi/alternatives/src/main/java/org/javaee7/cdi/alternatives/TestServlet.java

Lines changed: 0 additions & 127 deletions
This file was deleted.

cdi/alternatives/src/main/webapp/index.jsp

Lines changed: 0 additions & 55 deletions
This file was deleted.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package org.javaee7.cdi.alternatives;
2+
3+
import org.jboss.arquillian.container.test.api.Deployment;
4+
import org.jboss.arquillian.junit.Arquillian;
5+
import org.jboss.shrinkwrap.api.Archive;
6+
import org.jboss.shrinkwrap.api.ShrinkWrap;
7+
import org.jboss.shrinkwrap.api.spec.JavaArchive;
8+
import org.junit.Test;
9+
import org.junit.runner.RunWith;
10+
11+
import javax.inject.Inject;
12+
13+
import static org.hamcrest.CoreMatchers.instanceOf;
14+
import static org.hamcrest.CoreMatchers.is;
15+
import static org.hamcrest.CoreMatchers.notNullValue;
16+
import static org.junit.Assert.assertThat;
17+
18+
/**
19+
* @author Alexis Hassler
20+
*/
21+
@RunWith(Arquillian.class)
22+
public class GreetingTest {
23+
@Deployment
24+
public static Archive<?> deploy() {
25+
return ShrinkWrap.create(JavaArchive.class)
26+
.addClasses(Greeting.class, SimpleGreeting.class, FancyGreeting.class)
27+
.addAsManifestResource("beans.xml");
28+
}
29+
30+
@Inject Greeting bean;
31+
32+
@Test
33+
public void should_bean_be_injected() throws Exception {
34+
assertThat(bean, is(notNullValue()));
35+
}
36+
37+
@Test
38+
public void should_bean_be_fancy() throws Exception {
39+
// because it is declared as the alternative in beans.xml
40+
assertThat(bean, instanceOf(FancyGreeting.class));
41+
}
42+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://jboss.org/schema/arquillian" xsi:schemaLocation="http://jboss.org/schema/arquillian
3+
http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
4+
5+
<defaultProtocol type="Servlet 3.0"/>
6+
7+
<container qualifier="test" default="true">
8+
<configuration>
9+
<property name="jbossHome">${serverRoot:target/wildfly-8.0.0.Beta1}</property>
10+
<property name="serverConfig">${serverProfile:standalone-full.xml}</property>
11+
</configuration>
12+
</container>
13+
14+
</arquillian>
File renamed without changes.

cdi/bean-discovery-annotated/src/main/java/org/javaee7/cdi/bean/discovery/annotated/TestServlet.java

Lines changed: 0 additions & 127 deletions
This file was deleted.

0 commit comments

Comments
 (0)