Skip to content

Commit db53e73

Browse files
committed
Adding Arquillian tests to cdi/bean-discovery-annotated example
1 parent cbf04ce commit db53e73

File tree

6 files changed

+60
-231
lines changed

6 files changed

+60
-231
lines changed

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.

cdi/bean-discovery-annotated/src/main/webapp/WEB-INF/beans.xml

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

cdi/bean-discovery-annotated/src/main/webapp/index.jsp

Lines changed: 0 additions & 55 deletions
This file was deleted.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package org.javaee7.cdi.bean.discovery.annotated;
2+
3+
import org.hamcrest.CoreMatchers;
4+
import org.jboss.arquillian.container.test.api.Deployment;
5+
import org.jboss.arquillian.junit.Arquillian;
6+
import org.jboss.shrinkwrap.api.Archive;
7+
import org.jboss.shrinkwrap.api.ShrinkWrap;
8+
import org.jboss.shrinkwrap.api.spec.JavaArchive;
9+
import org.junit.Test;
10+
import org.junit.runner.RunWith;
11+
12+
import javax.inject.Inject;
13+
14+
import static org.hamcrest.CoreMatchers.instanceOf;
15+
import static org.hamcrest.CoreMatchers.is;
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)
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(CoreMatchers.notNullValue()));
35+
}
36+
@Test
37+
public void should_bean_be_simple() throws Exception {
38+
// because SimpleGreeting is annotated (scope)
39+
assertThat(bean, instanceOf(SimpleGreeting.class));
40+
}
41+
}
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>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
4+
bean-discovery-mode="annotated">
5+
</beans>

0 commit comments

Comments
 (0)