├── .gitignore
├── README.md
├── cdiunit
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── airhacks
│ │ │ └── JAXRSConfiguration.java
│ └── webapp
│ │ └── WEB-INF
│ │ └── beans.xml
│ └── test
│ └── java
│ └── com
│ └── airhacks
│ └── cdiunit
│ ├── Boundary.java
│ ├── Control.java
│ └── InjectEmAllIT.java
├── cdivsejb-stress
├── pom.xml
└── src
│ └── main
│ └── java
│ └── com
│ └── airhacks
│ └── cdivsejb
│ └── stress
│ └── CDIvsEJBBenchmark.java
├── cdivsejb
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── airhacks
│ │ ├── JAXRSApplication.java
│ │ ├── cdi
│ │ ├── CdiBoundary.java
│ │ ├── CdiControl.java
│ │ └── CdiResource.java
│ │ └── ejb
│ │ ├── EJBBoundary.java
│ │ ├── EJBControl.java
│ │ └── EJBResource.java
│ └── webapp
│ └── WEB-INF
│ └── beans.xml
├── deltaspike-with-system-properties
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── airhacks
│ │ │ └── delta
│ │ │ └── SystemPropertyExposer.java
│ └── resources
│ │ └── META-INF
│ │ └── beans.xml
│ └── test
│ └── java
│ └── com
│ └── airhacks
│ └── delta
│ ├── PropertiesLoaderTestRunner.java
│ └── SystemPropertyExposerIT.java
├── deltaspike
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── airhacks
│ │ │ └── JAXRSConfiguration.java
│ └── webapp
│ │ └── WEB-INF
│ │ └── beans.xml
│ └── test
│ ├── java
│ └── com
│ │ └── airhacks
│ │ └── delta
│ │ ├── Boundary.java
│ │ ├── Control.java
│ │ └── InjectEmAllIT.java
│ └── resources
│ └── META-INF
│ └── beans.xml
├── echosocks-st
├── pom.xml
└── src
│ └── test
│ └── java
│ └── com
│ └── airhacks
│ └── echo
│ └── boundary
│ ├── EchoEndpointIT.java
│ └── MessageHandler.java
├── echosocks
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── airhacks
│ │ └── echo
│ │ └── boundary
│ │ └── EchoEndpoint.java
│ └── webapp
│ └── WEB-INF
│ └── beans.xml
├── embedded
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── airhacks
│ │ │ ├── Boundary.java
│ │ │ ├── Control.java
│ │ │ ├── FriendlyMessenger.java
│ │ │ ├── JAXRSConfiguration.java
│ │ │ └── LoggerProducer.java
│ └── webapp
│ │ └── WEB-INF
│ │ └── beans.xml
│ └── test
│ └── java
│ └── com
│ └── airhacks
│ ├── BoundaryIT.java
│ ├── BoundarySinglePluginIT.java
│ ├── InjectEmAllIT.java
│ └── LoggerTestSupport.java
├── fit
├── calculator-fit
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── com
│ │ └── airhacks
│ │ └── calculator
│ │ └── fit
│ │ └── Multiplication.java
└── calculator
│ ├── nb-configuration.xml
│ ├── pom.xml
│ └── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── airhacks
│ │ │ ├── JAXRSConfiguration.java
│ │ │ └── calculator
│ │ │ └── boundary
│ │ │ ├── CalculationsResource.java
│ │ │ └── Calculator.java
│ └── webapp
│ │ ├── WEB-INF
│ │ └── beans.xml
│ │ └── index.html
│ └── test
│ └── java
│ └── com
│ └── airhacks
│ └── calculator
│ └── boundary
│ └── CalculatorTest.java
├── graphene
├── nbactions.xml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── airhacks
│ │ │ └── JAXRSConfiguration.java
│ └── webapp
│ │ └── WEB-INF
│ │ └── beans.xml
│ └── test
│ ├── java
│ └── com
│ │ └── airhacks
│ │ └── graphene
│ │ └── ArquillianIT.java
│ └── resources
│ └── arquillian.xml
├── hello
├── nb-configuration.xml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── airhacks
│ │ │ ├── JAXRSConfiguration.java
│ │ │ └── hello
│ │ │ └── business
│ │ │ └── order
│ │ │ ├── boundary
│ │ │ ├── OrderProcessor.java
│ │ │ └── OrdersResource.java
│ │ │ ├── control
│ │ │ ├── LegacyAuthenticator.java
│ │ │ ├── OrderHistory.java
│ │ │ └── PaymentProcessor.java
│ │ │ └── entity
│ │ │ └── Order.java
│ ├── resources
│ │ └── META-INF
│ │ │ └── persistence.xml
│ └── webapp
│ │ └── WEB-INF
│ │ └── beans.xml
│ └── test
│ ├── filters
│ └── env.properties
│ ├── java
│ └── com
│ │ └── airhacks
│ │ └── hello
│ │ └── business
│ │ └── order
│ │ ├── boundary
│ │ └── OrderProcessorTest.java
│ │ └── entity
│ │ └── OrderIT.java
│ └── resources
│ └── META-INF
│ └── persistence.xml
├── jersey-testframework
├── nb-configuration.xml
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── airhacks
│ │ └── jersey
│ │ └── HelloResource.java
│ └── test
│ └── java
│ └── com
│ └── airhacks
│ └── jersey
│ └── HelloResourceIT.java
├── junit-hello
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── airhacks
│ │ └── junit
│ │ └── hello
│ │ └── Thrower.java
│ └── test
│ └── java
│ └── com
│ └── airhacks
│ ├── AssertionsShowTest.java
│ ├── AssumeTest.java
│ ├── HelloTest.java
│ └── junit
│ └── hello
│ ├── SystemOutRule.java
│ └── ThrowerTest.java
├── loggerbenchmark
├── pom.xml
└── src
│ └── main
│ └── java
│ └── com
│ └── airhacks
│ └── logging
│ └── LoggerBenchmark.java
├── monitoring-st
├── dependency-reduced-pom.xml
├── pom.xml
└── src
│ └── test
│ └── java
│ └── com
│ └── airhacks
│ └── mon
│ └── reporting
│ └── boundary
│ └── SnapshotsResourceIT.java
├── monitoring
├── nb-configuration.xml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── airhacks
│ │ │ ├── JAXRSConfiguration.java
│ │ │ └── mon
│ │ │ └── business
│ │ │ └── reporting
│ │ │ └── boundary
│ │ │ └── SnapshotsResource.java
│ └── webapp
│ │ └── WEB-INF
│ │ └── beans.xml
│ └── test
│ └── java
│ └── com
│ └── airhacks
│ └── mon
│ └── business
│ └── reporting
│ └── boundary
│ └── SnapshotsResourceIT.java
├── pageobject
├── nb-configuration.xml
├── nbactions.xml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── airhacks
│ │ │ ├── Index.java
│ │ │ └── JAXRSConfiguration.java
│ └── webapp
│ │ ├── WEB-INF
│ │ ├── beans.xml
│ │ └── web.xml
│ │ └── index.xhtml
│ └── test
│ ├── java
│ └── com
│ │ └── airhacks
│ │ ├── IndexIT.java
│ │ └── IndexPage.java
│ └── resources
│ └── arquillian.xml
├── stress
├── nb-configuration.xml
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── airhacks
│ │ ├── JAXRSConfiguration.java
│ │ └── stress
│ │ ├── StressManager.java
│ │ └── StressResource.java
│ └── webapp
│ └── WEB-INF
│ └── beans.xml
├── weather-stress
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── airhacks
│ │ ├── JAXRSConfiguration.java
│ │ └── testdriver
│ │ └── TestDriver.java
│ └── webapp
│ ├── WEB-INF
│ └── beans.xml
│ └── index.jsp
└── weather
├── nb-configuration.xml
├── pom.xml
└── src
└── main
├── java
└── com
│ └── airhacks
│ ├── JAXRSConfiguration.java
│ └── weather
│ ├── business
│ └── forecast
│ │ └── boundary
│ │ └── WeatherService.java
│ └── presentation
│ └── Index.java
└── webapp
├── WEB-INF
├── beans.xml
└── web.xml
└── index.xhtml
/.gitignore:
--------------------------------------------------------------------------------
1 | target
2 | nb-configuration.xml
3 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # javaeetesting
2 | Samples For The [javaeetesting.com](http://javaeetesting.com) Online Workshop
3 |
--------------------------------------------------------------------------------
/cdiunit/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 | com.airhacks
5 | cdiunit
6 | 1.0-SNAPSHOT
7 | war
8 |
9 |
10 | junit
11 | junit
12 | 4.12
13 | test
14 |
15 |
16 | org.hamcrest
17 | hamcrest-core
18 | 1.3
19 | test
20 |
21 |
22 | javax
23 | javaee-api
24 | 7.0
25 | provided
26 |
27 |
28 | org.jglue.cdi-unit
29 | cdi-unit
30 | 3.1.3
31 | test
32 |
33 |
34 |
35 | cdiunit
36 |
37 |
38 | 1.8
39 | 1.8
40 | false
41 |
42 |
--------------------------------------------------------------------------------
/cdiunit/src/main/java/com/airhacks/JAXRSConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.airhacks;
2 |
3 | import javax.ws.rs.ApplicationPath;
4 | import javax.ws.rs.core.Application;
5 |
6 | /**
7 | * Configures a JAX-RS endpoint. Delete this class, if you are not exposing
8 | * JAX-RS resources in your application.
9 | *
10 | * @author airhacks.com
11 | */
12 | @ApplicationPath("resources")
13 | public class JAXRSConfiguration extends Application {
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/cdiunit/src/main/webapp/WEB-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/cdiunit/src/test/java/com/airhacks/cdiunit/Boundary.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.cdiunit;
2 |
3 | import javax.inject.Inject;
4 |
5 | /**
6 | *
7 | * @author airhacks.com
8 | */
9 | public class Boundary {
10 |
11 | @Inject
12 | Control control;
13 |
14 | public String greeting() {
15 | return this.control.message() + " day";
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/cdiunit/src/test/java/com/airhacks/cdiunit/Control.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.cdiunit;
2 |
3 | /**
4 | *
5 | * @author airhacks.com
6 | */
7 | public class Control {
8 |
9 | public String message() {
10 | return "perfect";
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/cdiunit/src/test/java/com/airhacks/cdiunit/InjectEmAllIT.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.cdiunit;
2 |
3 | import javax.inject.Inject;
4 | import static junit.framework.Assert.assertNotNull;
5 | import static org.hamcrest.CoreMatchers.is;
6 | import static org.hamcrest.MatcherAssert.assertThat;
7 | import org.jglue.cdiunit.CdiRunner;
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 |
11 | /**
12 | *
13 | * @author airhacks.com
14 | */
15 | @RunWith(CdiRunner.class)
16 | public class InjectEmAllIT {
17 |
18 | @Inject
19 | Boundary boundary;
20 |
21 | @Test
22 | public void injection() {
23 | assertNotNull(boundary);
24 | String expected = "perfect day";
25 | String greeting = boundary.greeting();
26 | assertThat(greeting, is(expected));
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/cdivsejb-stress/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 | com.airhacks
5 | cdivsejb-stress
6 | 1.0-SNAPSHOT
7 | jar
8 |
9 |
10 | org.glassfish.jersey.core
11 | jersey-client
12 | 2.21
13 |
14 |
15 | org.glassfish
16 | javax.json
17 | 1.0.4
18 |
19 |
20 | org.glassfish.jersey.media
21 | jersey-media-json-processing
22 | 2.21
23 |
24 |
25 | org.openjdk.jmh
26 | jmh-core
27 | 1.11.2
28 |
29 |
30 | org.openjdk.jmh
31 | jmh-generator-annprocess
32 | 1.11.2
33 | provided
34 |
35 |
36 |
37 |
38 |
39 | org.apache.maven.plugins
40 | maven-shade-plugin
41 | 2.4.2
42 |
43 |
44 | package
45 |
46 | shade
47 |
48 |
49 | stress
50 |
51 |
52 | org.openjdk.jmh.Main
53 |
54 |
55 |
56 |
57 |
58 | META-INF/*.SF
59 | META-INF/*.DSA
60 | META-INF/*.RSA
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 | UTF-8
72 | 1.8
73 | 1.8
74 |
75 |
--------------------------------------------------------------------------------
/cdivsejb-stress/src/main/java/com/airhacks/cdivsejb/stress/CDIvsEJBBenchmark.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.cdivsejb.stress;
2 |
3 | import java.util.concurrent.TimeUnit;
4 | import javax.ws.rs.client.Client;
5 | import javax.ws.rs.client.ClientBuilder;
6 | import javax.ws.rs.client.WebTarget;
7 | import org.openjdk.jmh.annotations.Benchmark;
8 | import org.openjdk.jmh.annotations.BenchmarkMode;
9 | import org.openjdk.jmh.annotations.Level;
10 | import org.openjdk.jmh.annotations.Measurement;
11 | import org.openjdk.jmh.annotations.Mode;
12 | import org.openjdk.jmh.annotations.OutputTimeUnit;
13 | import org.openjdk.jmh.annotations.Param;
14 | import org.openjdk.jmh.annotations.Scope;
15 | import org.openjdk.jmh.annotations.Setup;
16 | import org.openjdk.jmh.annotations.State;
17 | import org.openjdk.jmh.annotations.Warmup;
18 |
19 | /**
20 | *
21 | * @author airhacks.com
22 | */
23 | @Warmup(iterations = 2, time = 1, timeUnit = TimeUnit.SECONDS)
24 | @Measurement(iterations = 2, time = 1, timeUnit = TimeUnit.SECONDS)
25 | @OutputTimeUnit(TimeUnit.SECONDS)
26 | @BenchmarkMode(Mode.Throughput)
27 | public class CDIvsEJBBenchmark {
28 |
29 | @State(Scope.Benchmark)
30 | public static class ClientContext {
31 |
32 | @Param({"cdi", "ejb"})
33 | String tech;
34 | WebTarget tut;
35 |
36 | @Setup(Level.Trial)
37 | public void init() {
38 | Client client = ClientBuilder.newClient();
39 | this.tut = client.target("http://localhost:8080/cdivsejb/resources/{tech}");
40 | }
41 | }
42 |
43 | @Benchmark
44 | public void request(ClientContext context) {
45 | context.tut.resolveTemplate("tech", context.tech).
46 | request().get(String.class);
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/cdivsejb/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 | com.airhacks
6 | cdivsejb
7 | 1.0-SNAPSHOT
8 | war
9 |
10 |
11 | javax
12 | javaee-web-api
13 | 7.0
14 | provided
15 |
16 |
17 |
18 | transactions
19 |
20 |
21 | 1.8
22 | 1.8
23 | false
24 |
25 | cdivsejb
26 |
27 |
--------------------------------------------------------------------------------
/cdivsejb/src/main/java/com/airhacks/JAXRSApplication.java:
--------------------------------------------------------------------------------
1 | package com.airhacks;
2 |
3 | import javax.ws.rs.ApplicationPath;
4 | import javax.ws.rs.core.Application;
5 |
6 | /**
7 | *
8 | * @author airhacks.com
9 | */
10 | @ApplicationPath("resources")
11 | public class JAXRSApplication extends Application {
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/cdivsejb/src/main/java/com/airhacks/cdi/CdiBoundary.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.cdi;
2 |
3 | import javax.enterprise.context.RequestScoped;
4 | import javax.inject.Inject;
5 |
6 | /**
7 | *
8 | * @author airhacks.com
9 | */
10 | @RequestScoped
11 | public class CdiBoundary {
12 |
13 | @Inject
14 | CdiControl control;
15 |
16 | public String message() {
17 | return this.control.message();
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/cdivsejb/src/main/java/com/airhacks/cdi/CdiControl.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.cdi;
2 |
3 | /**
4 | *
5 | * @author airhacks.com
6 | */
7 | public class CdiControl {
8 |
9 | public String message() {
10 | return "cdi " + System.currentTimeMillis();
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/cdivsejb/src/main/java/com/airhacks/cdi/CdiResource.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.cdi;
2 |
3 | import javax.enterprise.context.RequestScoped;
4 | import javax.inject.Inject;
5 | import javax.ws.rs.GET;
6 | import javax.ws.rs.Path;
7 |
8 | /**
9 | *
10 | * @author airhacks.com
11 | */
12 | @RequestScoped
13 | @Path("cdi")
14 | public class CdiResource {
15 |
16 | @Inject
17 | CdiBoundary boundary;
18 |
19 | @GET
20 | public String cdi() {
21 | return boundary.message();
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/cdivsejb/src/main/java/com/airhacks/ejb/EJBBoundary.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.ejb;
2 |
3 | import javax.ejb.Stateless;
4 | import javax.inject.Inject;
5 |
6 | /**
7 | *
8 | * @author airhacks.com
9 | */
10 | @Stateless
11 | public class EJBBoundary {
12 |
13 | @Inject
14 | EJBControl control;
15 |
16 | public String message() {
17 | return this.control.message();
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/cdivsejb/src/main/java/com/airhacks/ejb/EJBControl.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.ejb;
2 |
3 | /**
4 | *
5 | * @author airhacks.com
6 | */
7 | public class EJBControl {
8 |
9 | public String message() {
10 | return "ejb " + System.currentTimeMillis();
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/cdivsejb/src/main/java/com/airhacks/ejb/EJBResource.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.ejb;
2 |
3 | import javax.ejb.Stateless;
4 | import javax.inject.Inject;
5 | import javax.ws.rs.GET;
6 | import javax.ws.rs.Path;
7 |
8 | /**
9 | *
10 | * @author airhacks.com
11 | */
12 | @Stateless
13 | @Path("ejb")
14 | public class EJBResource {
15 |
16 | @Inject
17 | EJBBoundary boundary;
18 |
19 | @GET
20 | public String cdi() {
21 | return boundary.message();
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/cdivsejb/src/main/webapp/WEB-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/deltaspike-with-system-properties/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 | com.airhacks.deltaspike
5 | deltaspike-with-system-properties
6 | 1.0-SNAPSHOT
7 | jar
8 |
9 |
10 | junit
11 | junit
12 | 4.12
13 | test
14 |
15 |
16 | javax
17 | javaee-api
18 | 7.0
19 | provided
20 |
21 |
22 | org.apache.deltaspike.modules
23 | deltaspike-test-control-module-impl
24 | 1.5.0
25 | test
26 |
27 |
28 | org.apache.deltaspike.cdictrl
29 | deltaspike-cdictrl-weld
30 | 1.5.0
31 | test
32 |
33 |
34 | org.jboss.weld.se
35 | weld-se-core
36 | 2.3.0.Final
37 | test
38 |
39 |
40 |
41 | UTF-8
42 | 1.8
43 | 1.8
44 |
45 |
--------------------------------------------------------------------------------
/deltaspike-with-system-properties/src/main/java/com/airhacks/delta/SystemPropertyExposer.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.delta;
2 |
3 | import javax.enterprise.inject.Produces;
4 |
5 | /**
6 | *
7 | * @author airhacks.com
8 | */
9 | public class SystemPropertyExposer {
10 |
11 | @Produces
12 | public String expose() {
13 | return System.getProperty("dev");
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/deltaspike-with-system-properties/src/main/resources/META-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/deltaspike-with-system-properties/src/test/java/com/airhacks/delta/PropertiesLoaderTestRunner.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.delta;
2 |
3 | import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
4 | import org.junit.runners.model.InitializationError;
5 |
6 | /**
7 | *
8 | * @author airhacks.com
9 | */
10 | public class PropertiesLoaderTestRunner extends CdiTestRunner {
11 |
12 | static {
13 | System.setProperty("dev", "duke");
14 | }
15 |
16 | public PropertiesLoaderTestRunner(Class> testClass) throws InitializationError {
17 | super(testClass);
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/deltaspike-with-system-properties/src/test/java/com/airhacks/delta/SystemPropertyExposerIT.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.delta;
2 |
3 | import javax.inject.Inject;
4 | import static org.hamcrest.CoreMatchers.is;
5 | import static org.junit.Assert.assertThat;
6 | import org.junit.Test;
7 | import org.junit.runner.RunWith;
8 |
9 | /**
10 | *
11 | * @author airhacks.com
12 | */
13 | @RunWith(PropertiesLoaderTestRunner.class)
14 | public class SystemPropertyExposerIT {
15 |
16 | @Inject
17 | String developer;
18 |
19 | @Test
20 | public void developerInjection() {
21 | assertThat(developer, is("duke"));
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/deltaspike/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 | com.airhacks
5 | deltaspike
6 | 1.0-SNAPSHOT
7 | war
8 |
9 |
10 | junit
11 | junit
12 | 4.12
13 | test
14 |
15 |
16 | org.hamcrest
17 | hamcrest-core
18 | 1.3
19 | test
20 |
21 |
22 | javax
23 | javaee-api
24 | 7.0
25 | provided
26 |
27 |
28 | org.apache.deltaspike.modules
29 | deltaspike-test-control-module-impl
30 | 1.5.0
31 | test
32 |
33 |
34 | org.apache.deltaspike.cdictrl
35 | deltaspike-cdictrl-weld
36 | 1.5.0
37 | test
38 |
39 |
40 | org.jboss.weld.se
41 | weld-se-core
42 | 2.3.0.Final
43 | test
44 |
45 |
46 |
47 | deltaspike
48 |
49 |
50 | 1.8
51 | 1.8
52 | false
53 |
54 |
--------------------------------------------------------------------------------
/deltaspike/src/main/java/com/airhacks/JAXRSConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.airhacks;
2 |
3 | import javax.ws.rs.ApplicationPath;
4 | import javax.ws.rs.core.Application;
5 |
6 | /**
7 | * Configures a JAX-RS endpoint. Delete this class, if you are not exposing
8 | * JAX-RS resources in your application.
9 | *
10 | * @author airhacks.com
11 | */
12 | @ApplicationPath("resources")
13 | public class JAXRSConfiguration extends Application {
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/deltaspike/src/main/webapp/WEB-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/deltaspike/src/test/java/com/airhacks/delta/Boundary.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.delta;
2 |
3 | import javax.inject.Inject;
4 |
5 | /**
6 | *
7 | * @author airhacks.com
8 | */
9 | public class Boundary {
10 |
11 | @Inject
12 | Control control;
13 |
14 | public String greeting() {
15 | return this.control.message() + " day";
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/deltaspike/src/test/java/com/airhacks/delta/Control.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.delta;
2 |
3 | /**
4 | *
5 | * @author airhacks.com
6 | */
7 | public class Control {
8 |
9 | public String message() {
10 | return "perfect";
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/deltaspike/src/test/java/com/airhacks/delta/InjectEmAllIT.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.delta;
2 |
3 | import javax.inject.Inject;
4 | import static junit.framework.Assert.assertNotNull;
5 | import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
6 | import static org.hamcrest.CoreMatchers.is;
7 | import static org.hamcrest.MatcherAssert.assertThat;
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 |
11 | /**
12 | *
13 | * @author airhacks.com
14 | */
15 | @RunWith(CdiTestRunner.class)
16 | public class InjectEmAllIT {
17 |
18 | @Inject
19 | Boundary boundary;
20 |
21 | @Test
22 | public void injection() {
23 | assertNotNull(boundary);
24 | String expected = "perfect day";
25 | String greeting = boundary.greeting();
26 | assertThat(greeting, is(expected));
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/deltaspike/src/test/resources/META-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/echosocks-st/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 | com.airhacks
5 | echosocks-st
6 | 1.0-SNAPSHOT
7 | jar
8 |
9 |
10 | org.glassfish.tyrus
11 | tyrus-server
12 | 1.12
13 |
14 |
15 | junit
16 | junit
17 | 4.12
18 | test
19 |
20 |
21 | org.hamcrest
22 | hamcrest-core
23 | 1.3
24 | test
25 |
26 |
27 |
28 | UTF-8
29 | 1.8
30 | 1.8
31 |
32 |
--------------------------------------------------------------------------------
/echosocks-st/src/test/java/com/airhacks/echo/boundary/EchoEndpointIT.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.echo.boundary;
2 |
3 | import java.io.IOException;
4 | import java.net.URI;
5 | import java.net.URISyntaxException;
6 | import javax.websocket.ContainerProvider;
7 | import javax.websocket.DeploymentException;
8 | import javax.websocket.Endpoint;
9 | import javax.websocket.EndpointConfig;
10 | import javax.websocket.Session;
11 | import javax.websocket.WebSocketContainer;
12 | import static org.hamcrest.CoreMatchers.is;
13 | import static org.junit.Assert.assertThat;
14 | import org.junit.Before;
15 | import org.junit.Test;
16 |
17 | /**
18 | *
19 | * @author airhacks.com
20 | */
21 | public class EchoEndpointIT {
22 |
23 | private Session session;
24 | private MessageHandler messageHandler;
25 |
26 | @Before
27 | public void init() throws URISyntaxException, DeploymentException, IOException {
28 | WebSocketContainer container = ContainerProvider.getWebSocketContainer();
29 | URI uri = new URI("ws://localhost:8080/echosocks/echo");
30 | this.session = container.connectToServer(new Endpoint() {
31 | @Override
32 | public void onOpen(Session session, EndpointConfig config) {
33 | }
34 | }, uri);
35 |
36 | this.messageHandler = new MessageHandler();
37 | this.session.addMessageHandler(String.class, this.messageHandler);
38 | }
39 |
40 | @Test
41 | public void echo() {
42 | String expected = "duke";
43 | this.session.getAsyncRemote().sendText(expected);
44 | String actual = this.messageHandler.getMessage();
45 | assertThat(actual, is("+" + expected));
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/echosocks-st/src/test/java/com/airhacks/echo/boundary/MessageHandler.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.echo.boundary;
2 |
3 | import java.util.concurrent.CountDownLatch;
4 | import java.util.concurrent.TimeUnit;
5 |
6 | /**
7 | *
8 | * @author airhacks.com
9 | */
10 | public class MessageHandler implements javax.websocket.MessageHandler.Whole {
11 |
12 | private final CountDownLatch messageLatch;
13 |
14 | private String message;
15 |
16 | public MessageHandler() {
17 | this.messageLatch = new CountDownLatch(1);
18 | }
19 |
20 | @Override
21 | public void onMessage(String message) {
22 | this.message = message;
23 | this.messageLatch.countDown();
24 | }
25 |
26 | public String getMessage() {
27 | try {
28 | messageLatch.await(2, TimeUnit.SECONDS);
29 | } catch (InterruptedException ex) {
30 | throw new IllegalStateException(ex);
31 | }
32 | return message;
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/echosocks/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 | com.airhacks
5 | echosocks
6 | 1.0-SNAPSHOT
7 | war
8 |
9 |
10 | javax
11 | javaee-api
12 | 7.0
13 | provided
14 |
15 |
16 |
17 | echosocks
18 |
19 |
20 | 1.8
21 | 1.8
22 | false
23 |
24 |
--------------------------------------------------------------------------------
/echosocks/src/main/java/com/airhacks/echo/boundary/EchoEndpoint.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.echo.boundary;
2 |
3 | import javax.websocket.OnMessage;
4 | import javax.websocket.OnOpen;
5 | import javax.websocket.Session;
6 | import javax.websocket.server.ServerEndpoint;
7 |
8 | /**
9 | *
10 | * @author airhacks.com
11 | */
12 | @ServerEndpoint("/echo")
13 | public class EchoEndpoint {
14 |
15 | private Session session;
16 |
17 | @OnOpen
18 | public void open(Session session) {
19 | this.session = session;
20 | }
21 |
22 | @OnMessage
23 | public void onMessage(String message) {
24 | this.session.getAsyncRemote().sendText("+" + message);
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/echosocks/src/main/webapp/WEB-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/embedded/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 | com.airhacks
5 | embedded
6 | 1.0-SNAPSHOT
7 | war
8 |
9 |
10 |
11 | org.jboss.arquillian
12 | arquillian-bom
13 | 1.1.9.Final
14 | import
15 | pom
16 |
17 |
18 |
19 |
20 |
21 | org.jboss.arquillian.junit
22 | arquillian-junit-container
23 | test
24 |
25 |
26 | org.jboss.weld
27 | weld-core
28 | 2.3.0.Final
29 | test
30 |
31 |
32 | org.jboss.arquillian.container
33 | arquillian-weld-ee-embedded-1.1
34 | 1.0.0.CR9
35 | test
36 |
37 |
38 | junit
39 | junit
40 | 4.12
41 | test
42 |
43 |
44 | javax
45 | javaee-api
46 | 7.0
47 | provided
48 |
49 |
50 |
51 | embedded
52 |
53 |
54 | 1.8
55 | 1.8
56 | false
57 |
58 |
--------------------------------------------------------------------------------
/embedded/src/main/java/com/airhacks/Boundary.java:
--------------------------------------------------------------------------------
1 | package com.airhacks;
2 |
3 | import java.util.logging.Logger;
4 | import javax.enterprise.inject.Instance;
5 | import javax.inject.Inject;
6 |
7 | /**
8 | *
9 | * @author airhacks.com
10 | */
11 | public class Boundary {
12 |
13 | @Inject
14 | Instance control;
15 |
16 | @Inject
17 | Logger LOG;
18 |
19 | public String greeting() {
20 | LOG.info("about to greet");
21 | String prefix = "perfect";
22 | if (!control.isAmbiguous() && !control.isUnsatisfied()) {
23 | prefix = this.control.get().message();
24 | }
25 | return prefix + " day";
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/embedded/src/main/java/com/airhacks/Control.java:
--------------------------------------------------------------------------------
1 | package com.airhacks;
2 |
3 | /**
4 | *
5 | * @author airhacks.com
6 | */
7 | public interface Control {
8 |
9 | String message();
10 | }
11 |
--------------------------------------------------------------------------------
/embedded/src/main/java/com/airhacks/FriendlyMessenger.java:
--------------------------------------------------------------------------------
1 | package com.airhacks;
2 |
3 | /**
4 | *
5 | * @author airhacks.com
6 | */
7 | public class FriendlyMessenger implements Control {
8 |
9 | @Override
10 | public String message() {
11 | return ":-)";
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/embedded/src/main/java/com/airhacks/JAXRSConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.airhacks;
2 |
3 | import javax.ws.rs.ApplicationPath;
4 | import javax.ws.rs.core.Application;
5 |
6 | /**
7 | * Configures a JAX-RS endpoint. Delete this class, if you are not exposing
8 | * JAX-RS resources in your application.
9 | *
10 | * @author airhacks.com
11 | */
12 | @ApplicationPath("resources")
13 | public class JAXRSConfiguration extends Application {
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/embedded/src/main/java/com/airhacks/LoggerProducer.java:
--------------------------------------------------------------------------------
1 | package com.airhacks;
2 |
3 | import java.util.logging.Logger;
4 | import javax.enterprise.inject.Produces;
5 | import javax.enterprise.inject.spi.InjectionPoint;
6 |
7 | /**
8 | *
9 | * @author airhacks.com
10 | */
11 | public class LoggerProducer {
12 |
13 | @Produces
14 | public Logger expose(InjectionPoint ip) {
15 | Class> clazz = ip.getMember().getDeclaringClass();
16 | return Logger.getLogger(clazz.getName());
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/embedded/src/main/webapp/WEB-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/embedded/src/test/java/com/airhacks/BoundaryIT.java:
--------------------------------------------------------------------------------
1 | package com.airhacks;
2 |
3 | import java.util.logging.Logger;
4 | import javax.inject.Inject;
5 | import static org.hamcrest.CoreMatchers.is;
6 | import static org.hamcrest.MatcherAssert.assertThat;
7 | import org.jboss.arquillian.container.test.api.Deployment;
8 | import org.jboss.arquillian.junit.Arquillian;
9 | import org.jboss.shrinkwrap.api.ShrinkWrap;
10 | import org.jboss.shrinkwrap.api.asset.EmptyAsset;
11 | import org.jboss.shrinkwrap.api.spec.WebArchive;
12 | import org.junit.Test;
13 | import org.junit.runner.RunWith;
14 |
15 | /**
16 | *
17 | * @author airhacks.com
18 | */
19 | @RunWith(Arquillian.class)
20 | public class BoundaryIT {
21 |
22 | @Inject
23 | Boundary boundary;
24 |
25 | @Deployment
26 | public static WebArchive create() {
27 | return ShrinkWrap.create(WebArchive.class).
28 | addClasses(LoggerProducer.class,
29 | Boundary.class,
30 | Control.class,
31 | Logger.class).
32 | addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
33 | }
34 |
35 | @Test
36 | public void boundaryWithoutPlugins() {
37 | String expected = "perfect day";
38 | String actual = boundary.greeting();
39 | assertThat(actual, is(expected));
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/embedded/src/test/java/com/airhacks/BoundarySinglePluginIT.java:
--------------------------------------------------------------------------------
1 | package com.airhacks;
2 |
3 | import java.util.logging.Logger;
4 | import javax.inject.Inject;
5 | import static org.hamcrest.CoreMatchers.is;
6 | import static org.hamcrest.MatcherAssert.assertThat;
7 | import org.jboss.arquillian.container.test.api.Deployment;
8 | import org.jboss.arquillian.junit.Arquillian;
9 | import org.jboss.shrinkwrap.api.ShrinkWrap;
10 | import org.jboss.shrinkwrap.api.asset.EmptyAsset;
11 | import org.jboss.shrinkwrap.api.spec.WebArchive;
12 | import org.junit.Test;
13 | import org.junit.runner.RunWith;
14 |
15 | /**
16 | *
17 | * @author airhacks.com
18 | */
19 | @RunWith(Arquillian.class)
20 | public class BoundarySinglePluginIT {
21 |
22 | @Inject
23 | Boundary boundary;
24 |
25 | @Deployment
26 | public static WebArchive create() {
27 | return ShrinkWrap.create(WebArchive.class).
28 | addClasses(LoggerProducer.class,
29 | Boundary.class,
30 | Control.class,
31 | FriendlyMessenger.class,
32 | Logger.class).
33 | addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
34 | }
35 |
36 | @Test
37 | public void boundaryWithoutPlugins() {
38 | String expected = ":-) day";
39 | String actual = boundary.greeting();
40 | assertThat(actual, is(expected));
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/embedded/src/test/java/com/airhacks/InjectEmAllIT.java:
--------------------------------------------------------------------------------
1 | package com.airhacks;
2 |
3 | import java.util.logging.Logger;
4 | import javax.inject.Inject;
5 | import static org.hamcrest.CoreMatchers.is;
6 | import static org.hamcrest.MatcherAssert.assertThat;
7 | import org.jboss.arquillian.container.test.api.Deployment;
8 | import org.jboss.arquillian.junit.Arquillian;
9 | import org.jboss.shrinkwrap.api.ShrinkWrap;
10 | import org.jboss.shrinkwrap.api.asset.EmptyAsset;
11 | import org.jboss.shrinkwrap.api.spec.WebArchive;
12 | import org.junit.Test;
13 | import org.junit.runner.RunWith;
14 |
15 | /**
16 | *
17 | * @author airhacks.com
18 | */
19 | @RunWith(Arquillian.class)
20 | public class InjectEmAllIT {
21 |
22 | @Inject
23 | LoggerTestSupport support;
24 |
25 | @Deployment
26 | public static WebArchive create() {
27 | return ShrinkWrap.create(WebArchive.class).
28 | addClasses(LoggerProducer.class, LoggerTestSupport.class, Logger.class).
29 | addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
30 | }
31 |
32 | @Test
33 | public void loggerConfiguredProperly() {
34 | String expected = support.getClass().getName();
35 | String actual = support.getLog().getName();
36 | assertThat(actual, is(expected));
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/embedded/src/test/java/com/airhacks/LoggerTestSupport.java:
--------------------------------------------------------------------------------
1 | package com.airhacks;
2 |
3 | import java.util.logging.Logger;
4 | import javax.inject.Inject;
5 |
6 | /**
7 | *
8 | * @author airhacks.com
9 | */
10 | public class LoggerTestSupport {
11 |
12 | @Inject
13 | Logger LOG;
14 |
15 | public Logger getLog() {
16 | return LOG;
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/fit/calculator-fit/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 | com.airhacks
5 | calculator-fit
6 | 1.0-SNAPSHOT
7 | jar
8 |
9 |
10 | org.fitnesse
11 | fitnesse
12 | 20150814
13 | provided
14 |
15 |
16 | org.glassfish.jersey.core
17 | jersey-client
18 | 2.21
19 |
20 |
21 | org.glassfish
22 | javax.json
23 | 1.0.4
24 |
25 |
26 | org.glassfish.jersey.media
27 | jersey-media-json-processing
28 | 2.21
29 |
30 |
31 |
32 |
33 |
34 | org.apache.maven.plugins
35 | maven-shade-plugin
36 | 2.4.2
37 |
38 |
39 | package
40 |
41 | shade
42 |
43 |
44 |
45 |
46 |
47 | calculator-fit
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | UTF-8
56 | 1.8
57 | 1.8
58 |
59 |
--------------------------------------------------------------------------------
/fit/calculator-fit/src/main/java/com/airhacks/calculator/fit/Multiplication.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.calculator.fit;
2 |
3 | import fit.ColumnFixture;
4 | import javax.ws.rs.client.Client;
5 | import javax.ws.rs.client.ClientBuilder;
6 | import javax.ws.rs.client.WebTarget;
7 |
8 | /**
9 | *
10 | * @author airhacks.com
11 | */
12 | public class Multiplication extends ColumnFixture {
13 |
14 | public int a;
15 | public int b;
16 |
17 | private WebTarget tut;
18 |
19 | public Multiplication() {
20 | Client client = ClientBuilder.newClient();
21 | this.tut = client.target("http://localhost:8080/calculator/resources/calculations/multiplication/{a}mult{b}");
22 | }
23 |
24 | public int multiplication() {
25 | String result = this.tut.resolveTemplate("a", a).
26 | resolveTemplate("b", b).
27 | request().
28 | get(String.class);
29 | return Integer.parseInt(result);
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/fit/calculator/nb-configuration.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
16 | ide
17 |
18 |
19 |
--------------------------------------------------------------------------------
/fit/calculator/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 | com.airhacks
5 | calculator
6 | 1.0-SNAPSHOT
7 | war
8 |
9 |
10 | junit
11 | junit
12 | 4.12
13 | test
14 |
15 |
16 | javax
17 | javaee-api
18 | 7.0
19 | provided
20 |
21 |
22 |
23 |
24 |
25 | org.jacoco
26 | jacoco-maven-plugin
27 | 0.7.5.201505241946
28 |
29 |
30 |
31 | prepare-agent
32 |
33 |
34 |
35 | report
36 | prepare-package
37 |
38 | report
39 |
40 |
41 |
42 | prepare-integration-test-agent
43 |
44 | prepare-agent-integration
45 |
46 |
47 |
48 | generate-integration-test-report
49 |
50 | report-integration
51 |
52 |
53 |
54 |
55 |
56 | org.pitest
57 | pitest-maven
58 | 1.1.7
59 |
60 |
61 | report
62 | prepare-package
63 |
64 | mutationCoverage
65 |
66 |
67 |
68 |
69 |
70 | calculator
71 |
72 |
73 | 1.8
74 | 1.8
75 | false
76 |
77 |
--------------------------------------------------------------------------------
/fit/calculator/src/main/java/com/airhacks/JAXRSConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.airhacks;
2 |
3 | import javax.ws.rs.ApplicationPath;
4 | import javax.ws.rs.core.Application;
5 |
6 | /**
7 | * Configures a JAX-RS endpoint. Delete this class, if you are not exposing
8 | * JAX-RS resources in your application.
9 | *
10 | * @author airhacks.com
11 | */
12 | @ApplicationPath("resources")
13 | public class JAXRSConfiguration extends Application {
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/fit/calculator/src/main/java/com/airhacks/calculator/boundary/CalculationsResource.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.calculator.boundary;
2 |
3 | import javax.inject.Inject;
4 | import javax.ws.rs.GET;
5 | import javax.ws.rs.Path;
6 | import javax.ws.rs.PathParam;
7 |
8 | /**
9 | *
10 | * @author airhacks.com
11 | */
12 | @Path("calculations")
13 | public class CalculationsResource {
14 |
15 | @Inject
16 | Calculator calculator;
17 |
18 | @GET
19 | @Path("/multiplication/{a}mult{b}")
20 | public String multiplication(@PathParam("a") int a, @PathParam("b") int b) {
21 | return String.valueOf(calculator.multiply(a, b));
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/fit/calculator/src/main/java/com/airhacks/calculator/boundary/Calculator.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.calculator.boundary;
2 |
3 | import javax.ejb.Stateless;
4 |
5 | /**
6 | *
7 | * @author airhacks.com
8 | */
9 | @Stateless
10 | public class Calculator {
11 |
12 | public int multiply(int a, int b) {
13 | return a * b;
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/fit/calculator/src/main/webapp/WEB-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/fit/calculator/src/main/webapp/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | TODO supply a title
5 |
6 |
7 |
8 |
9 | FIT Sample Wiki
10 |
11 | !path /Users/abien/work/projects/airhacks/samples/testing/fit/calculator-fit/target/calculator-fit.jar
12 | |com.airhacks.calculator.fit.Multiplication|
13 | |a |b |multiplication? |
14 | |2 |21 |42 |
15 | |2 |11 |22 |
16 | |3 |6 |10 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/fit/calculator/src/test/java/com/airhacks/calculator/boundary/CalculatorTest.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.calculator.boundary;
2 |
3 | import static org.hamcrest.CoreMatchers.is;
4 | import static org.junit.Assert.assertThat;
5 | import org.junit.Before;
6 | import org.junit.Test;
7 |
8 | /**
9 | *
10 | * @author airhacks.com
11 | */
12 | public class CalculatorTest {
13 |
14 | Calculator cut;
15 |
16 | @Before
17 | public void init() {
18 | this.cut = new Calculator();
19 | }
20 |
21 | @Test
22 | public void multiply() {
23 | final int a = 2;
24 | final int b = 21;
25 | int result = this.cut.multiply(a, b);
26 | System.out.println("multiply = " + result);
27 | assertThat(result, is(a * b));
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/graphene/nbactions.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | test.single
5 |
6 | *
7 |
8 |
9 | test-compile
10 | surefire:test
11 |
12 |
13 | ${packageClassName}
14 | /Users/abien/work/devprogs/tools/chromedriver/chromedriver
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/graphene/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 | com.airhacks
5 | graphene
6 | 1.0-SNAPSHOT
7 | war
8 |
9 |
10 |
11 | org.jboss.arquillian
12 | arquillian-bom
13 | 1.1.9.Final
14 | import
15 | pom
16 |
17 |
18 |
19 |
20 |
21 | org.jboss.arquillian.junit
22 | arquillian-junit-container
23 | test
24 |
25 |
26 | org.jboss.arquillian.graphene
27 | arquillian-graphene
28 | pom
29 | 2.0.3.Final
30 | test
31 |
32 |
33 | junit
34 | junit
35 | 4.12
36 | test
37 |
38 |
39 | javax
40 | javaee-api
41 | 7.0
42 | provided
43 |
44 |
45 |
46 | Graphene
47 |
48 |
49 | 1.8
50 | 1.8
51 | false
52 |
53 |
--------------------------------------------------------------------------------
/graphene/src/main/java/com/airhacks/JAXRSConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.airhacks;
2 |
3 | import javax.ws.rs.ApplicationPath;
4 | import javax.ws.rs.core.Application;
5 |
6 | /**
7 | * Configures a JAX-RS endpoint. Delete this class, if you are not exposing
8 | * JAX-RS resources in your application.
9 | *
10 | * @author airhacks.com
11 | */
12 | @ApplicationPath("resources")
13 | public class JAXRSConfiguration extends Application {
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/graphene/src/main/webapp/WEB-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/graphene/src/test/java/com/airhacks/graphene/ArquillianIT.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.graphene;
2 |
3 | import static org.hamcrest.CoreMatchers.containsString;
4 | import org.jboss.arquillian.drone.api.annotation.Drone;
5 | import org.jboss.arquillian.junit.Arquillian;
6 | import static org.junit.Assert.assertThat;
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 | import org.openqa.selenium.WebDriver;
10 |
11 | /**
12 | *
13 | * @author airhacks.com
14 | */
15 | @RunWith(Arquillian.class)
16 | public class ArquillianIT {
17 |
18 | @Drone
19 | WebDriver browser;
20 |
21 | @Test
22 | public void validateAirhacksPage() {
23 | browser.get("http://airhacks.com");
24 | String title = browser.getTitle();
25 | assertThat(title, containsString("EE"));
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/graphene/src/test/resources/arquillian.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 | chrome
9 |
10 |
--------------------------------------------------------------------------------
/hello/nb-configuration.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
16 | ide
17 | gfv3ee6
18 |
19 |
20 |
--------------------------------------------------------------------------------
/hello/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 | com.airhacks
5 | hello
6 | 1.0-SNAPSHOT
7 | war
8 |
9 |
10 | junit
11 | junit
12 | 4.12
13 | test
14 |
15 |
16 | com.airhacks.rulz
17 | em
18 | 0.0.2
19 | test
20 |
21 |
22 | org.mockito
23 | mockito-all
24 | 1.10.19
25 | test
26 |
27 |
28 | org.eclipse.persistence
29 | eclipselink
30 | 2.6.0
31 | test
32 |
33 |
34 | org.apache.derby
35 | derby
36 | 10.11.1.1
37 | test
38 |
39 |
40 | javax
41 | javaee-api
42 | 7.0
43 | provided
44 |
45 |
46 |
47 |
48 |
49 |
50 | org.jacoco
51 | jacoco-maven-plugin
52 | 0.7.2.201409121644
53 |
54 |
55 |
56 | prepare-agent
57 |
58 |
59 |
60 | report
61 | prepare-package
62 |
63 | report
64 |
65 |
66 |
67 | prepare-integration-test-agent
68 |
69 | prepare-agent-integration
70 |
71 |
72 |
73 | generate-integration-test-report
74 |
75 | report-integration
76 |
77 |
78 |
79 |
80 |
81 | hello
82 |
83 |
84 | src/test/resources
85 | true
86 |
87 |
88 |
89 | src/test/filters/env.properties
90 |
91 |
92 |
93 | 1.8
94 | 1.8
95 | false
96 |
97 |
--------------------------------------------------------------------------------
/hello/src/main/java/com/airhacks/JAXRSConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.airhacks;
2 |
3 | import javax.ws.rs.ApplicationPath;
4 | import javax.ws.rs.core.Application;
5 |
6 | /**
7 | * Configures a JAX-RS endpoint. Delete this class, if you are not exposing
8 | * JAX-RS resources in your application.
9 | *
10 | * @author airhacks.com
11 | */
12 | @ApplicationPath("resources")
13 | public class JAXRSConfiguration extends Application {
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/hello/src/main/java/com/airhacks/hello/business/order/boundary/OrderProcessor.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.hello.business.order.boundary;
2 |
3 | import com.airhacks.hello.business.order.control.LegacyAuthenticator;
4 | import com.airhacks.hello.business.order.control.OrderHistory;
5 | import com.airhacks.hello.business.order.control.PaymentProcessor;
6 | import com.airhacks.hello.business.order.entity.Order;
7 | import javax.ejb.Stateless;
8 | import javax.inject.Inject;
9 |
10 | /**
11 | *
12 | * @author airhacks.com
13 | */
14 | @Stateless
15 | public class OrderProcessor {
16 |
17 | @Inject
18 | LegacyAuthenticator authenticator;
19 | @Inject
20 | PaymentProcessor paymentProcessor;
21 |
22 | @Inject
23 | OrderHistory history;
24 |
25 | public void order(String orderid) {
26 | if (!this.authenticator.authenticate()) {
27 | throw new IllegalStateException("Not authenticated");
28 | }
29 | Order order = new Order(orderid);
30 | this.paymentProcessor.pay();
31 | this.history.save(order);
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/hello/src/main/java/com/airhacks/hello/business/order/boundary/OrdersResource.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.hello.business.order.boundary;
2 |
3 | import javax.ejb.Stateless;
4 | import javax.inject.Inject;
5 | import javax.json.JsonObject;
6 | import javax.ws.rs.POST;
7 | import javax.ws.rs.Path;
8 |
9 | /**
10 | *
11 | * @author airhacks.com
12 | */
13 | @Stateless
14 | @Path("orders")
15 | public class OrdersResource {
16 |
17 | @Inject
18 | OrderProcessor processor;
19 |
20 | @POST
21 | public void order(JsonObject order) {
22 | String trackingNumber = order.getString("tracking-number");
23 | processor.order(trackingNumber);
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/hello/src/main/java/com/airhacks/hello/business/order/control/LegacyAuthenticator.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.hello.business.order.control;
2 |
3 | /**
4 | *
5 | * @author airhacks.com
6 | */
7 | public class LegacyAuthenticator {
8 |
9 | public boolean authenticate() {
10 | return true;
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/hello/src/main/java/com/airhacks/hello/business/order/control/OrderHistory.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.hello.business.order.control;
2 |
3 | import com.airhacks.hello.business.order.entity.Order;
4 | import javax.persistence.EntityManager;
5 | import javax.persistence.PersistenceContext;
6 |
7 | /**
8 | *
9 | * @author airhacks.com
10 | */
11 | public class OrderHistory {
12 |
13 | @PersistenceContext
14 | EntityManager em;
15 |
16 | public void save(Order order) {
17 | this.em.merge(order);
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/hello/src/main/java/com/airhacks/hello/business/order/control/PaymentProcessor.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.hello.business.order.control;
2 |
3 | /**
4 | *
5 | * @author airhacks.com
6 | */
7 | public class PaymentProcessor {
8 |
9 | public void pay() {
10 | System.out.println("Paid!");
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/hello/src/main/java/com/airhacks/hello/business/order/entity/Order.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.hello.business.order.entity;
2 |
3 | import javax.persistence.Entity;
4 | import javax.persistence.GeneratedValue;
5 | import javax.persistence.Id;
6 | import javax.persistence.Table;
7 |
8 | /**
9 | *
10 | * @author airhacks.com
11 | */
12 | @Table(name = "T_ORDER")
13 | @Entity
14 | public class Order {
15 |
16 | @Id
17 | @GeneratedValue
18 | private long id;
19 | private String trackingNumber;
20 |
21 | public Order(String trackingNumber) {
22 | this.trackingNumber = trackingNumber;
23 | }
24 |
25 | public Order() {
26 | }
27 |
28 | public String getTrackingNumber() {
29 | return trackingNumber;
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/hello/src/main/resources/META-INF/persistence.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/hello/src/main/webapp/WEB-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/hello/src/test/filters/env.properties:
--------------------------------------------------------------------------------
1 | db=defaultDB
2 |
--------------------------------------------------------------------------------
/hello/src/test/java/com/airhacks/hello/business/order/boundary/OrderProcessorTest.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.hello.business.order.boundary;
2 |
3 | import com.airhacks.hello.business.order.control.LegacyAuthenticator;
4 | import com.airhacks.hello.business.order.control.OrderHistory;
5 | import com.airhacks.hello.business.order.control.PaymentProcessor;
6 | import com.airhacks.hello.business.order.entity.Order;
7 | import org.hamcrest.BaseMatcher;
8 | import org.hamcrest.Description;
9 | import org.junit.Before;
10 | import org.junit.Test;
11 | import static org.mockito.Matchers.argThat;
12 | import static org.mockito.Mockito.mock;
13 | import static org.mockito.Mockito.verify;
14 | import static org.mockito.Mockito.when;
15 |
16 | /**
17 | *
18 | * @author airhacks.com
19 | */
20 | public class OrderProcessorTest {
21 |
22 | OrderProcessor cut;
23 |
24 | @Before
25 | public void init() {
26 | this.cut = new OrderProcessor();
27 | this.cut.paymentProcessor = mock(PaymentProcessor.class);
28 | this.cut.authenticator = mock(LegacyAuthenticator.class);
29 | this.cut.history = mock(OrderHistory.class);
30 | }
31 |
32 | @Test
33 | public void successfulOrder() {
34 | when(this.cut.authenticator.authenticate()).thenReturn(true);
35 | final String expected = "42";
36 | this.cut.order(expected);
37 | verify(this.cut.paymentProcessor).pay();
38 | verify(this.cut.history).save(argThat(new BaseMatcher() {
39 |
40 | @Override
41 | public boolean matches(Object item) {
42 | if (!(item instanceof Order)) {
43 | return false;
44 | }
45 | Order order = (Order) item;
46 | return expected.equalsIgnoreCase(order.getTrackingNumber());
47 | }
48 |
49 | @Override
50 | public void describeTo(Description description) {
51 | description.appendText("Should be: " + expected);
52 | }
53 | }));
54 | }
55 |
56 | @Test(expected = IllegalStateException.class)
57 | public void invaliduser() {
58 | when(this.cut.authenticator.authenticate()).thenReturn(false);
59 | this.cut.order("42");
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/hello/src/test/java/com/airhacks/hello/business/order/entity/OrderIT.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.hello.business.order.entity;
2 |
3 | import com.airhacks.rulz.em.EntityManagerProvider;
4 | import org.junit.Rule;
5 | import org.junit.Test;
6 |
7 | /**
8 | *
9 | * @author airhacks.com
10 | */
11 | public class OrderIT {
12 |
13 | @Rule
14 | public EntityManagerProvider provider = EntityManagerProvider.persistenceUnit("it");
15 |
16 | @Test
17 | public void verifyMappings() {
18 | this.provider.tx().begin();
19 | this.provider.em().merge(new Order("42"));
20 | this.provider.tx().commit();
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/hello/src/test/resources/META-INF/persistence.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | com.airhacks.hello.business.order.entity.Order
5 | true
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/jersey-testframework/nb-configuration.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
16 | ide
17 |
18 |
19 |
--------------------------------------------------------------------------------
/jersey-testframework/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 | com.airhacks
5 | jersey-testframework
6 | 1.0-SNAPSHOT
7 | war
8 |
9 |
10 | javax
11 | javaee-api
12 | 7.0
13 | provided
14 |
15 |
16 | org.glassfish.jersey.test-framework.providers
17 | jersey-test-framework-provider-grizzly2
18 | 2.22
19 |
20 |
27 |
28 | org.glassfish.jersey.test-framework.providers
29 | jersey-test-framework-provider-jdk-http
30 | 2.22
31 |
32 |
33 | org.glassfish
34 | javax.json
35 | 1.0.4
36 |
37 |
38 | org.glassfish.jersey.media
39 | jersey-media-json-processing
40 | 2.21
41 |
42 |
43 |
44 | jersey-testframework
45 |
46 |
47 | 1.8
48 | 1.8
49 | false
50 |
51 |
--------------------------------------------------------------------------------
/jersey-testframework/src/main/java/com/airhacks/jersey/HelloResource.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.jersey;
2 |
3 | import javax.inject.Singleton;
4 | import javax.json.Json;
5 | import javax.json.JsonObject;
6 | import javax.ws.rs.GET;
7 | import javax.ws.rs.Path;
8 |
9 | /**
10 | *
11 | * @author airhacks.com
12 | */
13 | @Singleton
14 | @Path("hello")
15 | public class HelloResource {
16 |
17 | @GET
18 | public JsonObject ms() {
19 | return Json.createObjectBuilder().
20 | add("time", System.currentTimeMillis()).
21 | build();
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/jersey-testframework/src/test/java/com/airhacks/jersey/HelloResourceIT.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.jersey;
2 |
3 | import javax.json.JsonObject;
4 | import javax.ws.rs.core.Application;
5 | import javax.ws.rs.core.Response;
6 | import org.glassfish.jersey.server.ResourceConfig;
7 | import org.glassfish.jersey.test.JerseyTest;
8 | import static org.hamcrest.CoreMatchers.is;
9 | import static org.junit.Assert.assertNotNull;
10 | import static org.junit.Assert.assertThat;
11 | import org.junit.Test;
12 |
13 | /**
14 | *
15 | * @author airhacks.com
16 | */
17 | public class HelloResourceIT extends JerseyTest {
18 |
19 | @Override
20 | protected Application configure() {
21 | return new ResourceConfig(HelloResource.class);
22 | }
23 |
24 | @Test
25 | public void second() throws Exception {
26 | Response response = target("hello").request().get();
27 | assertThat(response.getStatus(), is(200));
28 | JsonObject result = response.readEntity(JsonObject.class);
29 | assertNotNull(result);
30 | System.out.println("result = " + result);
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/junit-hello/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 | com.airhacks
5 | junit-hello
6 | 1.0-SNAPSHOT
7 | jar
8 |
9 |
10 | junit
11 | junit
12 | 4.12
13 | test
14 |
15 |
16 |
17 | UTF-8
18 | 1.8
19 | 1.8
20 |
21 |
--------------------------------------------------------------------------------
/junit-hello/src/main/java/com/airhacks/junit/hello/Thrower.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.junit.hello;
2 |
3 | /**
4 | *
5 | * @author airhacks.com
6 | */
7 | public class Thrower {
8 |
9 | public void throwException() {
10 | throw new IllegalStateException("illegal");
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/junit-hello/src/test/java/com/airhacks/AssertionsShowTest.java:
--------------------------------------------------------------------------------
1 | package com.airhacks;
2 |
3 | import java.util.Arrays;
4 | import java.util.List;
5 | import static org.hamcrest.CoreMatchers.allOf;
6 | import static org.hamcrest.CoreMatchers.anyOf;
7 | import static org.hamcrest.CoreMatchers.both;
8 | import static org.hamcrest.CoreMatchers.containsString;
9 | import static org.hamcrest.CoreMatchers.either;
10 | import static org.hamcrest.CoreMatchers.everyItem;
11 | import static org.hamcrest.CoreMatchers.hasItem;
12 | import static org.hamcrest.CoreMatchers.hasItems;
13 | import static org.hamcrest.CoreMatchers.not;
14 | import org.hamcrest.CustomMatcher;
15 | import org.hamcrest.Matcher;
16 | import static org.junit.Assert.assertThat;
17 | import org.junit.Before;
18 | import org.junit.Test;
19 |
20 | /**
21 | *
22 | * @author airhacks.com
23 | */
24 | public class AssertionsShowTest {
25 |
26 | private List stringList;
27 |
28 | @Before
29 | public void init() {
30 | this.stringList = Arrays.asList("java", "javaee", "joker");
31 |
32 | }
33 |
34 | @Test
35 | public void lists() {
36 | assertThat(stringList, hasItem("java"));
37 | assertThat(stringList, hasItem("javaee"));
38 | assertThat(stringList, hasItems("javaee", "joker"));
39 | assertThat(stringList, everyItem(containsString("j")));
40 | }
41 |
42 | @Test
43 | public void combinableMathers() {
44 | assertThat(stringList, both(hasItem("java")).and(hasItem("javaee")));
45 | assertThat(stringList, either(hasItem("java")).or(hasItem("javascript")));
46 | assertThat(stringList, anyOf(hasItem("javascript"), hasItem("javaee")));
47 | assertThat(stringList, allOf(hasItem("java"), not(hasItem("erlang"))));
48 | }
49 |
50 | @Test
51 | public void customMatcher() {
52 | Matcher containsJ = new CustomMatcher("contains j") {
53 |
54 | @Override
55 | public boolean matches(Object item) {
56 | if (!(item instanceof String)) {
57 | return false;
58 | }
59 | String content = (String) item;
60 | return content.contains("j");
61 | }
62 | };
63 |
64 | assertThat("java", containsJ);
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/junit-hello/src/test/java/com/airhacks/AssumeTest.java:
--------------------------------------------------------------------------------
1 | package com.airhacks;
2 |
3 | import static org.junit.Assert.fail;
4 | import static org.junit.Assume.assumeNoException;
5 | import org.junit.Test;
6 |
7 | /**
8 | *
9 | * @author airhacks.com
10 | */
11 | public class AssumeTest {
12 |
13 | @Test
14 | public void assumeNoExceptionDemonstration() {
15 | try {
16 | throw new IllegalStateException("internet not available today");
17 | } catch (Exception ex) {
18 | assumeNoException(ex);
19 | }
20 |
21 | fail("should not arrive here");
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/junit-hello/src/test/java/com/airhacks/HelloTest.java:
--------------------------------------------------------------------------------
1 | package com.airhacks;
2 |
3 | import com.airhacks.junit.hello.SystemOutRule;
4 | import static org.hamcrest.CoreMatchers.is;
5 | import org.junit.After;
6 | import static org.junit.Assert.assertNotNull;
7 | import static org.junit.Assert.assertThat;
8 | import org.junit.Before;
9 | import org.junit.Rule;
10 | import org.junit.Test;
11 | import org.junit.rules.Timeout;
12 |
13 | /**
14 | *
15 | * @author airhacks.com
16 | */
17 | public class HelloTest {
18 |
19 | @Rule
20 | public SystemOutRule rule = new SystemOutRule();
21 |
22 | @Rule
23 | public Timeout timeout = Timeout.seconds(1);
24 |
25 | @Before
26 | public void init() {
27 | System.out.println("Before each test");
28 | }
29 |
30 | @Test
31 | public void hello() {
32 | String result = "hello";
33 | assertNotNull(result);
34 | assertThat(result, is("hello"));
35 | }
36 |
37 | @Test
38 | public void another() {
39 | System.out.println("inside another");
40 | }
41 |
42 | @Test(timeout = 2000)
43 | public void tooSlow() {
44 | while (true) {
45 | }
46 | }
47 |
48 | @After
49 | public void destroy() {
50 | System.out.println("After the test");
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/junit-hello/src/test/java/com/airhacks/junit/hello/SystemOutRule.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.junit.hello;
2 |
3 | import org.junit.rules.TestRule;
4 | import org.junit.runner.Description;
5 | import org.junit.runners.model.Statement;
6 |
7 | /**
8 | *
9 | * @author airhacks.com
10 | */
11 | public class SystemOutRule implements TestRule {
12 |
13 | @Override
14 | public Statement apply(Statement base, Description description) {
15 | return new Statement() {
16 |
17 | @Override
18 | public void evaluate() throws Throwable {
19 | System.out.println("before----");
20 | base.evaluate();
21 | System.out.println("after---" + description.getClassName() + "-" + description.getMethodName() + " tested !");
22 | }
23 | };
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/junit-hello/src/test/java/com/airhacks/junit/hello/ThrowerTest.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.junit.hello;
2 |
3 | import static org.hamcrest.CoreMatchers.containsString;
4 | import static org.junit.Assert.assertThat;
5 | import static org.junit.Assert.fail;
6 | import org.junit.Before;
7 | import org.junit.Rule;
8 | import org.junit.Test;
9 | import org.junit.rules.ExpectedException;
10 |
11 | /**
12 | *
13 | * @author airhacks.com
14 | */
15 | public class ThrowerTest {
16 |
17 | private Thrower cut;
18 |
19 | @Rule
20 | public ExpectedException thrown = ExpectedException.none();
21 |
22 | @Before
23 | public void initialize() {
24 | this.cut = new Thrower();
25 | }
26 |
27 | @Test(expected = IllegalStateException.class)
28 | public void exception() {
29 | this.cut.throwException();
30 | }
31 |
32 | @Test
33 | public void detailedException() {
34 | try {
35 | this.cut.throwException();
36 | fail("Expecting IllegalStateException here");
37 | } catch (IllegalStateException ex) {
38 | String message = ex.getMessage();
39 | assertThat(message, containsString("illegal"));
40 | }
41 | }
42 |
43 | @Test
44 | public void exceptionWithRule() {
45 | this.thrown.expect(IllegalStateException.class);
46 | this.thrown.expectMessage(containsString("illegal"));
47 | this.cut.throwException();
48 |
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/loggerbenchmark/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 | com.airhacks
5 | loggerbenchmark
6 | 1.0-SNAPSHOT
7 | jar
8 |
9 |
10 | org.openjdk.jmh
11 | jmh-core
12 | 1.11.2
13 |
14 |
15 | org.openjdk.jmh
16 | jmh-generator-annprocess
17 | 1.11.2
18 | provided
19 |
20 |
21 |
22 |
23 |
24 | org.apache.maven.plugins
25 | maven-shade-plugin
26 | 2.4.2
27 |
28 |
29 | package
30 |
31 | shade
32 |
33 |
34 | jmh
35 |
36 |
37 | org.openjdk.jmh.Main
38 |
39 |
40 |
41 |
42 |
46 | *:*
47 |
48 | META-INF/*.SF
49 | META-INF/*.DSA
50 | META-INF/*.RSA
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | UTF-8
62 | 1.8
63 | 1.8
64 |
65 |
--------------------------------------------------------------------------------
/loggerbenchmark/src/main/java/com/airhacks/logging/LoggerBenchmark.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.logging;
2 |
3 | import java.util.logging.Logger;
4 | import org.openjdk.jmh.annotations.Benchmark;
5 | import org.openjdk.jmh.annotations.BenchmarkMode;
6 | import org.openjdk.jmh.annotations.Level;
7 | import org.openjdk.jmh.annotations.Mode;
8 | import org.openjdk.jmh.annotations.Scope;
9 | import org.openjdk.jmh.annotations.Setup;
10 | import org.openjdk.jmh.annotations.State;
11 |
12 | /**
13 | *
14 | * @author airhacks.com
15 | */
16 | @BenchmarkMode(Mode.Throughput)
17 | public class LoggerBenchmark {
18 |
19 | @State(Scope.Benchmark)
20 | public static class BenchmarkContext {
21 |
22 | Logger LOG;
23 |
24 | @Setup(Level.Trial)
25 | public void initialize() {
26 | this.LOG = Logger.getLogger(LoggerBenchmark.class.getName());
27 | }
28 |
29 | }
30 |
31 | @Benchmark
32 | public void info(BenchmarkContext ctx) {
33 | ctx.LOG.info("+");
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/monitoring-st/dependency-reduced-pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 | com.airhacks
5 | monitoring-st
6 | 1.0-SNAPSHOT
7 |
8 |
9 |
10 | maven-shade-plugin
11 | 2.4.2
12 |
13 |
14 | package
15 |
16 | shade
17 |
18 |
19 |
20 |
21 |
22 |
23 | true
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 | junit
34 | junit
35 | 4.12
36 | test
37 |
38 |
39 | hamcrest-core
40 | org.hamcrest
41 |
42 |
43 |
44 |
45 | com.airhacks.rulz
46 | jaxrsclient
47 | 0.0.3
48 | test
49 |
50 |
51 |
52 | 1.8
53 | UTF-8
54 | 1.8
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/monitoring-st/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 | com.airhacks
5 | monitoring-st
6 | 1.0-SNAPSHOT
7 | jar
8 |
9 |
10 | junit
11 | junit
12 | 4.12
13 | test
14 |
15 |
16 | org.glassfish.jersey.core
17 | jersey-client
18 | 2.21
19 |
20 |
21 | org.glassfish
22 | javax.json
23 | 1.0.4
24 |
25 |
26 | org.glassfish.jersey.media
27 | jersey-media-json-processing
28 | 2.21
29 |
30 |
31 | com.airhacks.rulz
32 | jaxrsclient
33 | 0.0.3
34 | test
35 |
36 |
37 |
38 |
39 |
40 | org.apache.maven.plugins
41 | maven-dependency-plugin
42 | 2.10
43 |
44 |
45 | get-dependencies
46 | prepare-package
47 |
48 | unpack-dependencies
49 |
50 |
51 | target/test-classes/
52 |
53 |
54 |
55 |
56 |
57 | org.apache.maven.plugins
58 | maven-jar-plugin
59 | 2.6
60 |
61 |
62 | package
63 |
64 | test-jar
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 | UTF-8
74 | 1.8
75 | 1.8
76 |
77 |
--------------------------------------------------------------------------------
/monitoring-st/src/test/java/com/airhacks/mon/reporting/boundary/SnapshotsResourceIT.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.mon.reporting.boundary;
2 |
3 | import com.airhacks.rulz.jaxrsclient.JAXRSClientProvider;
4 | import java.util.UUID;
5 | import javax.json.Json;
6 | import javax.json.JsonObject;
7 | import javax.ws.rs.client.Entity;
8 | import javax.ws.rs.core.MediaType;
9 | import javax.ws.rs.core.Response;
10 | import static junit.framework.Assert.assertNotNull;
11 | import static org.hamcrest.CoreMatchers.is;
12 | import static org.hamcrest.MatcherAssert.assertThat;
13 | import org.junit.Test;
14 |
15 | /**
16 | *
17 | * @author airhacks.com
18 | */
19 | public class SnapshotsResourceIT {
20 |
21 | public JAXRSClientProvider provider = JAXRSClientProvider.buildWithURI("http://localhost:8080/monitoring/resources/snapshots");
22 |
23 | @Test
24 | public void crud() {
25 | final String key = "java";
26 | final String value = "rocks";
27 | JsonObject payload = Json.createObjectBuilder().
28 | add(key, value).
29 | build();
30 |
31 | Response response = provider.target().
32 | request().
33 | post(Entity.json(payload));
34 | assertThat(response.getStatus(), is(201));
35 | String uri = response.getHeaderString("Location");
36 | assertNotNull(uri);
37 |
38 | JsonObject result = provider.
39 | target(uri).
40 | request(MediaType.APPLICATION_JSON).
41 | get(JsonObject.class);
42 | assertNotNull(result);
43 | assertThat(result.getString(key), is(value));
44 | }
45 |
46 | @Test
47 | public void findNotExisting() {
48 | String key = UUID.randomUUID().toString();
49 | Response response = provider.
50 | target().
51 | path(key).
52 | request(MediaType.APPLICATION_JSON).
53 | get();
54 | assertThat(response.getStatus(), is(204));
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/monitoring/nb-configuration.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
16 | ide
17 |
18 |
19 |
--------------------------------------------------------------------------------
/monitoring/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 | com.airhacks
5 | monitoring
6 | 1.0-SNAPSHOT
7 | war
8 |
9 |
10 | javax
11 | javaee-api
12 | 7.0
13 | provided
14 |
15 |
16 | org.glassfish.jersey.test-framework.providers
17 | jersey-test-framework-provider-grizzly2
18 | 2.22
19 | test
20 |
21 |
28 |
29 | org.glassfish.jersey.test-framework.providers
30 | jersey-test-framework-provider-jdk-http
31 | 2.22
32 | test
33 |
34 |
35 | org.glassfish
36 | javax.json
37 | 1.0.4
38 |
39 |
40 | org.glassfish.jersey.media
41 | jersey-media-json-processing
42 | 2.21
43 |
44 |
45 |
46 | monitoring
47 |
48 |
49 | 1.8
50 | 1.8
51 | false
52 |
53 |
--------------------------------------------------------------------------------
/monitoring/src/main/java/com/airhacks/JAXRSConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.airhacks;
2 |
3 | import javax.ws.rs.ApplicationPath;
4 | import javax.ws.rs.core.Application;
5 |
6 | /**
7 | * Configures a JAX-RS endpoint. Delete this class, if you are not exposing
8 | * JAX-RS resources in your application.
9 | *
10 | * @author airhacks.com
11 | */
12 | @ApplicationPath("resources")
13 | public class JAXRSConfiguration extends Application {
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/monitoring/src/main/java/com/airhacks/mon/business/reporting/boundary/SnapshotsResource.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.mon.business.reporting.boundary;
2 |
3 | import java.net.URI;
4 | import java.util.UUID;
5 | import java.util.concurrent.ConcurrentHashMap;
6 | import javax.annotation.PostConstruct;
7 | import javax.inject.Singleton;
8 | import javax.json.JsonObject;
9 | import javax.ws.rs.GET;
10 | import javax.ws.rs.POST;
11 | import javax.ws.rs.Path;
12 | import javax.ws.rs.PathParam;
13 | import javax.ws.rs.core.Context;
14 | import javax.ws.rs.core.Response;
15 | import javax.ws.rs.core.UriInfo;
16 |
17 | /**
18 | *
19 | * @author airhacks.com
20 | */
21 | @Singleton
22 | @Path("snapshots")
23 | public class SnapshotsResource {
24 |
25 | ConcurrentHashMap noSQLDB;
26 |
27 | @PostConstruct
28 | public void initialize() {
29 | this.noSQLDB = new ConcurrentHashMap<>();
30 | }
31 |
32 | @GET
33 | @Path("{id}")
34 | public JsonObject find(@PathParam("id") String id) {
35 | return noSQLDB.get(id);
36 | }
37 |
38 | @POST
39 | public Response save(JsonObject payload, @Context UriInfo info) {
40 | String key = UUID.randomUUID().toString();
41 | this.noSQLDB.put(key, payload);
42 | URI uri = info.getAbsolutePathBuilder().
43 | path("/" + key).
44 | build();
45 | return Response.created(uri).build();
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/monitoring/src/main/webapp/WEB-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/monitoring/src/test/java/com/airhacks/mon/business/reporting/boundary/SnapshotsResourceIT.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.mon.business.reporting.boundary;
2 |
3 | import javax.json.JsonObject;
4 | import javax.ws.rs.core.Application;
5 | import javax.ws.rs.core.Response;
6 | import org.glassfish.jersey.server.ResourceConfig;
7 | import org.glassfish.jersey.test.JerseyTest;
8 | import static org.hamcrest.CoreMatchers.is;
9 | import static org.junit.Assert.assertThat;
10 | import org.junit.Test;
11 |
12 | /**
13 | *
14 | * @author airhacks.com
15 | */
16 | public class SnapshotsResourceIT extends JerseyTest {
17 |
18 | @Override
19 | protected Application configure() {
20 | return new ResourceConfig(SnapshotsResource.class);
21 | }
22 |
23 | @Test
24 | public void snapshots() {
25 | Response response = target("snapshots").request().get();
26 | assertThat(response.getStatus(), is(200));
27 | JsonObject result = response.readEntity(JsonObject.class);
28 | System.out.println("result = " + result);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/pageobject/nb-configuration.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
16 | Facelets
17 |
18 |
19 |
--------------------------------------------------------------------------------
/pageobject/nbactions.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | test.single
5 |
6 | *
7 |
8 |
9 | test-compile
10 | surefire:test
11 |
12 |
13 | ${packageClassName}
14 | /usr/local/webdriver/chromedriver
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/pageobject/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 | com.airhacks
5 | pageobject
6 | 1.0-SNAPSHOT
7 | war
8 |
9 |
10 |
11 | org.jboss.arquillian
12 | arquillian-bom
13 | 1.1.10.Final
14 | import
15 | pom
16 |
17 |
18 |
19 |
20 |
21 | org.jboss.arquillian.junit
22 | arquillian-junit-container
23 | test
24 |
25 |
26 | org.jboss.arquillian.graphene
27 | arquillian-graphene
28 | pom
29 | 2.1.0.Alpha3
30 | test
31 |
32 |
33 | junit
34 | junit
35 | 4.12
36 | test
37 |
38 |
39 | javax
40 | javaee-api
41 | 7.0
42 | provided
43 |
44 |
45 |
46 | pageobject
47 |
48 |
49 | 1.8
50 | 1.8
51 | false
52 |
53 |
--------------------------------------------------------------------------------
/pageobject/src/main/java/com/airhacks/Index.java:
--------------------------------------------------------------------------------
1 | package com.airhacks;
2 |
3 | import javax.enterprise.inject.Model;
4 |
5 | /**
6 | *
7 | * @author airhacks.com
8 | */
9 | @Model
10 | public class Index {
11 |
12 | private String input;
13 | private String output;
14 |
15 | public String getInput() {
16 | return input;
17 | }
18 |
19 | public void setInput(String input) {
20 | this.input = input;
21 | }
22 |
23 | public String getOutput() {
24 | return output;
25 | }
26 |
27 | public void setOutput(String output) {
28 | this.output = output;
29 | }
30 |
31 | public Object ok() {
32 | this.output = this.input;
33 | System.out.println("this.output = " + this.output);
34 | return null;
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/pageobject/src/main/java/com/airhacks/JAXRSConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.airhacks;
2 |
3 | import javax.ws.rs.ApplicationPath;
4 | import javax.ws.rs.core.Application;
5 |
6 | /**
7 | * Configures a JAX-RS endpoint. Delete this class, if you are not exposing
8 | * JAX-RS resources in your application.
9 | *
10 | * @author airhacks.com
11 | */
12 | @ApplicationPath("resources")
13 | public class JAXRSConfiguration extends Application {
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/pageobject/src/main/webapp/WEB-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/pageobject/src/main/webapp/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | javax.faces.PROJECT_STAGE
5 | Development
6 |
7 |
8 | javax.faces.PROJECT_STAGE
9 | Development
10 |
11 |
12 | Faces Servlet
13 | javax.faces.webapp.FacesServlet
14 | 1
15 |
16 |
17 | Faces Servlet
18 | /faces/*
19 |
20 |
21 |
22 | 30
23 |
24 |
25 |
26 | faces/index.xhtml
27 |
28 |
29 |
--------------------------------------------------------------------------------
/pageobject/src/main/webapp/index.xhtml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 | Facelet Title
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/pageobject/src/test/java/com/airhacks/IndexIT.java:
--------------------------------------------------------------------------------
1 | package com.airhacks;
2 |
3 | import static org.hamcrest.CoreMatchers.is;
4 | import org.jboss.arquillian.container.test.api.RunAsClient;
5 | import org.jboss.arquillian.drone.api.annotation.Drone;
6 | import org.jboss.arquillian.graphene.page.InitialPage;
7 | import org.jboss.arquillian.junit.Arquillian;
8 | import static org.junit.Assert.assertThat;
9 | import org.junit.Test;
10 | import org.junit.runner.RunWith;
11 | import org.openqa.selenium.WebDriver;
12 |
13 | /**
14 | *
15 | * @author airhacks.com
16 | */
17 | @RunAsClient
18 | @RunWith(Arquillian.class)
19 | public class IndexIT {
20 |
21 | @Drone
22 | WebDriver browser;
23 |
24 | @Test
25 | public void copy(@InitialPage IndexPage page) {
26 | String expected = "duke";
27 | String actual = page.copy(expected);
28 | assertThat(actual, is(expected));
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/pageobject/src/test/java/com/airhacks/IndexPage.java:
--------------------------------------------------------------------------------
1 | package com.airhacks;
2 |
3 | import org.jboss.arquillian.graphene.Graphene;
4 | import org.jboss.arquillian.graphene.page.Location;
5 | import org.openqa.selenium.WebElement;
6 | import org.openqa.selenium.support.FindBy;
7 |
8 | /**
9 | *
10 | * @author airhacks.com
11 | */
12 | @Location("http://localhost:8080/pageobject/faces/index.xhtml")
13 | public class IndexPage {
14 |
15 | @FindBy
16 | WebElement input;
17 |
18 | @FindBy
19 | WebElement output;
20 |
21 | @FindBy
22 | WebElement ok;
23 |
24 | public String copy(String inputText) {
25 | input.sendKeys(inputText);
26 | Graphene.guardHttp(ok).click();
27 | return output.getAttribute("value");
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/pageobject/src/test/resources/arquillian.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 | chrome
9 |
10 |
11 | http://localhost:8080/pageobject/
12 |
13 |
--------------------------------------------------------------------------------
/stress/nb-configuration.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
16 | ide
17 |
18 |
19 |
--------------------------------------------------------------------------------
/stress/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 | com.airhacks
5 | stress
6 | 1.0-SNAPSHOT
7 | war
8 |
9 |
10 | javax
11 | javaee-api
12 | 7.0
13 | provided
14 |
15 |
16 |
17 | stress
18 |
19 |
20 | 1.8
21 | 1.8
22 | false
23 |
24 |
--------------------------------------------------------------------------------
/stress/src/main/java/com/airhacks/JAXRSConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.airhacks;
2 |
3 | import javax.ws.rs.ApplicationPath;
4 | import javax.ws.rs.core.Application;
5 |
6 | /**
7 | * Configures a JAX-RS endpoint. Delete this class, if you are not exposing
8 | * JAX-RS resources in your application.
9 | *
10 | * @author airhacks.com
11 | */
12 | @ApplicationPath("resources")
13 | public class JAXRSConfiguration extends Application {
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/stress/src/main/java/com/airhacks/stress/StressManager.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.stress;
2 |
3 | import java.util.concurrent.atomic.AtomicInteger;
4 | import javax.annotation.PostConstruct;
5 | import javax.ejb.Stateless;
6 |
7 | /**
8 | *
9 | * @author airhacks.com
10 | */
11 | @Stateless
12 | public class StressManager {
13 |
14 | private static final AtomicInteger COUNTER = new AtomicInteger(0);
15 |
16 | @PostConstruct
17 | public void construction() {
18 | int count = COUNTER.incrementAndGet();
19 | System.out.println("Instances: " + count);
20 | }
21 |
22 | public String stress() {
23 | return "heavy " + System.currentTimeMillis();
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/stress/src/main/java/com/airhacks/stress/StressResource.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.stress;
2 |
3 | import javax.ejb.Stateless;
4 | import javax.inject.Inject;
5 | import javax.ws.rs.GET;
6 | import javax.ws.rs.Path;
7 |
8 | /**
9 | *
10 | * @author airhacks.com
11 | */
12 | @Path("stress")
13 | @Stateless
14 | public class StressResource {
15 |
16 | @Inject
17 | StressManager sm;
18 |
19 | @GET
20 | public String stress() {
21 | return sm.stress();
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/stress/src/main/webapp/WEB-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/weather-stress/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 | com.airhacks
5 | weather-stress
6 | 1.0-SNAPSHOT
7 | war
8 |
9 |
10 | ${project.groupId}
11 | weather
12 | ${project.version}
13 | classes
14 |
15 |
16 | javax
17 | javaee-api
18 | 7.0
19 | provided
20 |
21 |
22 |
23 |
24 | weather-stress
25 |
26 |
27 | 1.8
28 | 1.8
29 | false
30 |
31 |
--------------------------------------------------------------------------------
/weather-stress/src/main/java/com/airhacks/JAXRSConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.airhacks;
2 |
3 | import javax.ws.rs.ApplicationPath;
4 | import javax.ws.rs.core.Application;
5 |
6 | /**
7 | * Configures a JAX-RS endpoint. Delete this class, if you are not exposing
8 | * JAX-RS resources in your application.
9 | *
10 | * @author airhacks.com
11 | */
12 | @ApplicationPath("resources")
13 | public class JAXRSConfiguration extends Application {
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/weather-stress/src/main/java/com/airhacks/testdriver/TestDriver.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.testdriver;
2 |
3 | import com.airhacks.weather.business.forecast.boundary.WeatherService;
4 | import java.io.IOException;
5 | import java.io.PrintWriter;
6 | import javax.inject.Inject;
7 | import javax.servlet.ServletException;
8 | import javax.servlet.annotation.WebServlet;
9 | import javax.servlet.http.HttpServlet;
10 | import javax.servlet.http.HttpServletRequest;
11 | import javax.servlet.http.HttpServletResponse;
12 |
13 | /**
14 | *
15 | * @author airhacks.com
16 | */
17 | @WebServlet(name = "TestDriver", urlPatterns = {"/stress"})
18 | public class TestDriver extends HttpServlet {
19 |
20 | @Inject
21 | WeatherService service;
22 |
23 | /**
24 | * Processes requests for both HTTP GET
and POST
25 | * methods.
26 | *
27 | * @param request servlet request
28 | * @param response servlet response
29 | * @throws ServletException if a servlet-specific error occurs
30 | * @throws IOException if an I/O error occurs
31 | */
32 | protected void processRequest(HttpServletRequest request, HttpServletResponse response)
33 | throws ServletException, IOException {
34 | response.setContentType("text/html;charset=UTF-8");
35 | try (PrintWriter out = response.getWriter()) {
36 | /* TODO output your page here. You may use following sample code. */
37 | out.println("From test driver: " + service.forecast());
38 | }
39 | }
40 |
41 | //
42 | /**
43 | * Handles the HTTP GET
method.
44 | *
45 | * @param request servlet request
46 | * @param response servlet response
47 | * @throws ServletException if a servlet-specific error occurs
48 | * @throws IOException if an I/O error occurs
49 | */
50 | @Override
51 | protected void doGet(HttpServletRequest request, HttpServletResponse response)
52 | throws ServletException, IOException {
53 | processRequest(request, response);
54 | }
55 |
56 | /**
57 | * Handles the HTTP POST
method.
58 | *
59 | * @param request servlet request
60 | * @param response servlet response
61 | * @throws ServletException if a servlet-specific error occurs
62 | * @throws IOException if an I/O error occurs
63 | */
64 | @Override
65 | protected void doPost(HttpServletRequest request, HttpServletResponse response)
66 | throws ServletException, IOException {
67 | processRequest(request, response);
68 | }
69 |
70 | /**
71 | * Returns a short description of the servlet.
72 | *
73 | * @return a String containing servlet description
74 | */
75 | @Override
76 | public String getServletInfo() {
77 | return "Short description";
78 | }//
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/weather-stress/src/main/webapp/WEB-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/weather-stress/src/main/webapp/index.jsp:
--------------------------------------------------------------------------------
1 | <%--
2 | Document : index
3 | Created on : Nov 15, 2015, 11:56:58 AM
4 | Author : airhacks.com
5 | --%>
6 |
7 | <%@page contentType="text/html" pageEncoding="UTF-8"%>
8 |
9 |
10 |
11 |
12 | JSP Page
13 |
14 |
15 | Stress test: ${index.forecast}
16 |
17 |
18 |
--------------------------------------------------------------------------------
/weather/nb-configuration.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
16 | ide
17 | Facelets
18 |
19 |
20 |
--------------------------------------------------------------------------------
/weather/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 | com.airhacks
5 | weather
6 | 1.0-SNAPSHOT
7 | war
8 |
9 |
10 | javax
11 | javaee-api
12 | 7.0
13 | provided
14 |
15 |
16 |
17 |
18 |
19 | org.apache.maven.plugins
20 | maven-war-plugin
21 | 2.6
22 |
23 | true
24 |
25 |
26 |
27 | weather
28 |
29 |
30 | 1.8
31 | 1.8
32 | false
33 |
34 |
--------------------------------------------------------------------------------
/weather/src/main/java/com/airhacks/JAXRSConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.airhacks;
2 |
3 | import javax.ws.rs.ApplicationPath;
4 | import javax.ws.rs.core.Application;
5 |
6 | /**
7 | * Configures a JAX-RS endpoint. Delete this class, if you are not exposing
8 | * JAX-RS resources in your application.
9 | *
10 | * @author airhacks.com
11 | */
12 | @ApplicationPath("resources")
13 | public class JAXRSConfiguration extends Application {
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/weather/src/main/java/com/airhacks/weather/business/forecast/boundary/WeatherService.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.weather.business.forecast.boundary;
2 |
3 | import javax.ejb.Stateless;
4 | import javax.ws.rs.GET;
5 |
6 | /**
7 | *
8 | * @author airhacks.com
9 | */
10 | @Stateless
11 | public class WeatherService {
12 |
13 | @GET
14 | public String forecast() {
15 | return "sunny";
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/weather/src/main/java/com/airhacks/weather/presentation/Index.java:
--------------------------------------------------------------------------------
1 | package com.airhacks.weather.presentation;
2 |
3 | import com.airhacks.weather.business.forecast.boundary.WeatherService;
4 | import javax.enterprise.inject.Model;
5 | import javax.inject.Inject;
6 |
7 | /**
8 | *
9 | * @author airhacks.com
10 | */
11 | @Model
12 | public class Index {
13 |
14 | @Inject
15 | WeatherService service;
16 |
17 | public String getForecast() {
18 | return this.service.forecast();
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/weather/src/main/webapp/WEB-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/weather/src/main/webapp/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | javax.faces.PROJECT_STAGE
5 | Development
6 |
7 |
8 | Faces Servlet
9 | javax.faces.webapp.FacesServlet
10 | 1
11 |
12 |
13 | Faces Servlet
14 | /faces/*
15 |
16 |
17 |
18 | 30
19 |
20 |
21 |
22 | faces/index.xhtml
23 |
24 |
25 |
--------------------------------------------------------------------------------
/weather/src/main/webapp/index.xhtml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 | Facelet Title
7 |
8 |
9 | #{index.forecast}
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------