Skip to content
This repository was archived by the owner on Oct 14, 2020. It is now read-only.

Commit 5488ef4

Browse files
committed
cdi IT test bucket
1 parent 9a93537 commit 5488ef4

File tree

13 files changed

+894
-0
lines changed

13 files changed

+894
-0
lines changed
Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
<?xml version='1.0' encoding='utf-8'?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>boost</groupId>
7+
<artifactId>test-cdi-2.0</artifactId>
8+
<packaging>war</packaging>
9+
<version>1.0-SNAPSHOT</version>
10+
11+
<properties>
12+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
13+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
14+
<maven.compiler.source>1.8</maven.compiler.source>
15+
<maven.compiler.target>1.8</maven.compiler.target>
16+
</properties>
17+
18+
<pluginRepositories>
19+
<!-- Configure Sonatype OSS Maven snapshots repository -->
20+
<pluginRepository>
21+
<id>sonatype-nexus-snapshots</id>
22+
<name>Sonatype Nexus Snapshots</name>
23+
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
24+
<snapshots>
25+
<enabled>true</enabled>
26+
</snapshots>
27+
<releases>
28+
<enabled>false</enabled>
29+
</releases>
30+
</pluginRepository>
31+
</pluginRepositories>
32+
33+
<dependencyManagement>
34+
<dependencies>
35+
<dependency>
36+
<groupId>boost.boosters</groupId>
37+
<artifactId>ee8-bom</artifactId>
38+
<version>@pom.version@</version>
39+
<scope>import</scope>
40+
<type>pom</type>
41+
</dependency>
42+
</dependencies>
43+
</dependencyManagement>
44+
45+
<dependencies>
46+
<dependency>
47+
<groupId>boost.boosters</groupId>
48+
<artifactId>jaxrs</artifactId>
49+
</dependency>
50+
<dependency>
51+
<groupId>boost.boosters</groupId>
52+
<artifactId>jsonp</artifactId>
53+
</dependency>
54+
<dependency>
55+
<groupId>boost.boosters</groupId>
56+
<artifactId>cdi</artifactId>
57+
</dependency>
58+
<!-- For tests -->
59+
<dependency>
60+
<groupId>junit</groupId>
61+
<artifactId>junit</artifactId>
62+
<version>4.12</version>
63+
<scope>test</scope>
64+
</dependency>
65+
<dependency>
66+
<groupId>org.apache.cxf</groupId>
67+
<artifactId>cxf-rt-rs-client</artifactId>
68+
<version>3.2.6</version>
69+
<scope>test</scope>
70+
</dependency>
71+
<dependency>
72+
<groupId>org.apache.cxf</groupId>
73+
<artifactId>cxf-rt-rs-extension-providers</artifactId>
74+
<version>3.2.6</version>
75+
<scope>test</scope>
76+
</dependency>
77+
<dependency>
78+
<groupId>org.glassfish</groupId>
79+
<artifactId>javax.json</artifactId>
80+
<version>1.0.4</version>
81+
<scope>test</scope>
82+
</dependency>
83+
<!-- Support for JDK 9 and above -->
84+
<!--
85+
<dependency>
86+
<groupId>javax.xml.bind</groupId>
87+
<artifactId>jaxb-api</artifactId>
88+
<version>2.3.1</version>
89+
</dependency>
90+
<dependency>
91+
<groupId>com.sun.xml.bind</groupId>
92+
<artifactId>jaxb-core</artifactId>
93+
<version>2.3.0.1</version>
94+
</dependency>
95+
<dependency>
96+
<groupId>com.sun.xml.bind</groupId>
97+
<artifactId>jaxb-impl</artifactId>
98+
<version>2.3.2</version>
99+
</dependency>
100+
-->
101+
<dependency>
102+
<groupId>javax.activation</groupId>
103+
<artifactId>activation</artifactId>
104+
<version>1.1.1</version>
105+
</dependency>
106+
</dependencies>
107+
108+
<build>
109+
<plugins>
110+
<plugin>
111+
<groupId>boost</groupId>
112+
<artifactId>boost-maven-plugin</artifactId>
113+
<version>@pom.version@</version>
114+
<executions>
115+
<execution>
116+
<goals>
117+
<goal>package</goal>
118+
</goals>
119+
</execution>
120+
<execution>
121+
<id>test-start-server</id>
122+
<phase>pre-integration-test</phase>
123+
<goals>
124+
<goal>start</goal>
125+
</goals>
126+
</execution>
127+
<execution>
128+
<id>test-stop-server</id>
129+
<phase>post-integration-test</phase>
130+
<goals>
131+
<goal>stop</goal>
132+
</goals>
133+
</execution>
134+
</executions>
135+
</plugin>
136+
<plugin>
137+
<groupId>org.apache.maven.plugins</groupId>
138+
<artifactId>maven-failsafe-plugin</artifactId>
139+
<version>2.22.1</version>
140+
<executions>
141+
<execution>
142+
<goals>
143+
<goal>integration-test</goal>
144+
<goal>verify</goal>
145+
</goals>
146+
</execution>
147+
</executions>
148+
</plugin>
149+
</plugins>
150+
</build>
151+
152+
<profiles>
153+
<profile>
154+
<id>ol</id>
155+
<activation>
156+
<property>
157+
<name>boostRuntime</name>
158+
<value>ol</value>
159+
</property>
160+
</activation>
161+
<dependencies>
162+
<dependency>
163+
<groupId>boost.runtimes</groupId>
164+
<artifactId>openliberty</artifactId>
165+
</dependency>
166+
</dependencies>
167+
</profile>
168+
<profile>
169+
<id>wlp</id>
170+
<activation>
171+
<property>
172+
<name>boostRuntime</name>
173+
<value>wlp</value>
174+
</property>
175+
</activation>
176+
<dependencies>
177+
<dependency>
178+
<groupId>boost.runtimes</groupId>
179+
<artifactId>wlp</artifactId>
180+
</dependency>
181+
</dependencies>
182+
</profile>
183+
<profile>
184+
<id>tomee</id>
185+
<activation>
186+
<property>
187+
<name>boostRuntime</name>
188+
<value>tomee</value>
189+
</property>
190+
</activation>
191+
<dependencies>
192+
<dependency>
193+
<groupId>boost.runtimes</groupId>
194+
<artifactId>tomee</artifactId>
195+
</dependency>
196+
</dependencies>
197+
</profile>
198+
</profiles>
199+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// tag::copyright[]
2+
/*******************************************************************************
3+
* Copyright (c) 2017 IBM Corporation and others.
4+
* All rights reserved. This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License v1.0
6+
* which accompanies this distribution, and is available at
7+
* http://www.eclipse.org/legal/epl-v10.html
8+
*
9+
* Contributors:
10+
* IBM Corporation - Initial implementation
11+
*******************************************************************************/
12+
// end::copyright[]
13+
package io.openliberty.guides.inventory;
14+
15+
// JAX-RS
16+
import javax.ws.rs.ApplicationPath;
17+
import javax.ws.rs.core.Application;
18+
19+
@ApplicationPath("inventory")
20+
public class InventoryApplication extends Application {
21+
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// tag::copyright[]
2+
/*******************************************************************************
3+
* Copyright (c) 2017, 2019 IBM Corporation and others.
4+
* All rights reserved. This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License v1.0
6+
* which accompanies this distribution, and is available at
7+
* http://www.eclipse.org/legal/epl-v10.html
8+
*
9+
* Contributors:
10+
* IBM Corporation - Initial implementation
11+
*******************************************************************************/
12+
// end::copyright[]
13+
package io.openliberty.guides.inventory;
14+
15+
import java.util.ArrayList;
16+
import java.util.Collections;
17+
import java.util.List;
18+
import java.util.Properties;
19+
import io.openliberty.guides.inventory.client.SystemClient;
20+
import io.openliberty.guides.inventory.model.InventoryList;
21+
import io.openliberty.guides.inventory.model.SystemData;
22+
import javax.enterprise.context.ApplicationScoped;
23+
import javax.inject.Inject;
24+
25+
// tag::ApplicationScoped[]
26+
@ApplicationScoped
27+
// end::ApplicationScoped[]
28+
public class InventoryManager {
29+
30+
private List<SystemData> systems = Collections.synchronizedList(new ArrayList<>());
31+
32+
public void add(String hostname, Properties systemProps) {
33+
Properties props = new Properties();
34+
props.setProperty("os.name", systemProps.getProperty("os.name"));
35+
props.setProperty("user.name", systemProps.getProperty("user.name"));
36+
37+
SystemData system = new SystemData(hostname, props);
38+
if (!systems.contains(system)) {
39+
systems.add(system);
40+
}
41+
}
42+
43+
public InventoryList list() {
44+
return new InventoryList(systems);
45+
}
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// tag::copyright[]
2+
/*******************************************************************************
3+
* Copyright (c) 2017, 2019 IBM Corporation and others.
4+
* All rights reserved. This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License v1.0
6+
* which accompanies this distribution, and is available at
7+
* http://www.eclipse.org/legal/epl-v10.html
8+
*
9+
* Contributors:
10+
* IBM Corporation - Initial implementation
11+
*******************************************************************************/
12+
// end::copyright[]
13+
package io.openliberty.guides.inventory;
14+
15+
import java.util.Properties;
16+
import javax.enterprise.context.RequestScoped;
17+
import javax.inject.Inject;
18+
import javax.ws.rs.GET;
19+
import javax.ws.rs.Path;
20+
import javax.ws.rs.PathParam;
21+
import javax.ws.rs.Produces;
22+
import javax.ws.rs.core.MediaType;
23+
import javax.ws.rs.core.Response;
24+
import io.openliberty.guides.inventory.model.InventoryList;
25+
import io.openliberty.guides.inventory.client.SystemClient;
26+
27+
@RequestScoped
28+
@Path("/systems")
29+
public class InventoryResource {
30+
31+
@Inject
32+
InventoryManager manager;
33+
34+
@Inject
35+
SystemClient systemClient;
36+
37+
@GET
38+
@Path("/{hostname}")
39+
@Produces(MediaType.APPLICATION_JSON)
40+
public Response getPropertiesForHost(@PathParam("hostname") String hostname) {
41+
// Get properties for host
42+
Properties props = systemClient.getProperties(hostname);
43+
if (props == null) {
44+
return Response.status(Response.Status.NOT_FOUND)
45+
.entity("ERROR: Unknown hostname or the system service may not be " + "running on " + hostname)
46+
.build();
47+
}
48+
49+
// Add to inventory
50+
manager.add(hostname, props);
51+
return Response.ok(props).build();
52+
}
53+
54+
@GET
55+
@Produces(MediaType.APPLICATION_JSON)
56+
public InventoryList listContents() {
57+
return manager.list();
58+
}
59+
}

0 commit comments

Comments
 (0)