This repository has been archived by the owner on Oct 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Add CDI integration test #317
Open
ajm01
wants to merge
5
commits into
MicroShed:master
Choose a base branch
from
ajm01:cdiIT
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
10138d9
cdi IT test bucket
ajm01 ce9e26d
bom updates for cdi and jsonp
ajm01 f114966
rename test classes to allow tests to run
ajm01 c50abb7
switching jsonb providers on tomee
ajm01 4d8184b
try using resteasy as jax-rs jsonb provider
ajm01 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
196 changes: 196 additions & 0 deletions
196
boost-maven/boost-maven-plugin/src/it/test-cdi-2.0/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
<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/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>boost</groupId> | ||
<artifactId>test-cdi-2.0</artifactId> | ||
<packaging>war</packaging> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
</properties> | ||
|
||
<pluginRepositories> | ||
<!-- Configure Sonatype OSS Maven snapshots repository --> | ||
<pluginRepository> | ||
<id>sonatype-nexus-snapshots</id> | ||
<name>Sonatype Nexus Snapshots</name> | ||
<url>https://oss.sonatype.org/content/repositories/snapshots/</url> | ||
<snapshots> | ||
<enabled>true</enabled> | ||
</snapshots> | ||
<releases> | ||
<enabled>false</enabled> | ||
</releases> | ||
</pluginRepository> | ||
</pluginRepositories> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>boost.boosters</groupId> | ||
<artifactId>ee8-bom</artifactId> | ||
<version>@pom.version@</version> | ||
<scope>import</scope> | ||
<type>pom</type> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>boost.boosters</groupId> | ||
<artifactId>jaxrs</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>boost.boosters</groupId> | ||
<artifactId>jsonp</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>boost.boosters</groupId> | ||
<artifactId>cdi</artifactId> | ||
</dependency> | ||
<!-- For tests --> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.12</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.cxf</groupId> | ||
<artifactId>cxf-rt-rs-client</artifactId> | ||
<version>3.2.6</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.cxf</groupId> | ||
<artifactId>cxf-rt-rs-extension-providers</artifactId> | ||
<version>3.2.6</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.glassfish</groupId> | ||
<artifactId>javax.json</artifactId> | ||
<version>1.0.4</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<!-- Support for JDK 9 and above --> | ||
<dependency> | ||
<groupId>javax.xml.bind</groupId> | ||
<artifactId>jaxb-api</artifactId> | ||
<version>2.3.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.sun.xml.bind</groupId> | ||
<artifactId>jaxb-core</artifactId> | ||
<version>2.3.0.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.sun.xml.bind</groupId> | ||
<artifactId>jaxb-impl</artifactId> | ||
<version>2.3.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.activation</groupId> | ||
<artifactId>activation</artifactId> | ||
<version>1.1.1</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>boost</groupId> | ||
<artifactId>boost-maven-plugin</artifactId> | ||
<version>@pom.version@</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>package</goal> | ||
</goals> | ||
</execution> | ||
<execution> | ||
<id>test-start-server</id> | ||
<phase>pre-integration-test</phase> | ||
<goals> | ||
<goal>start</goal> | ||
</goals> | ||
</execution> | ||
<execution> | ||
<id>test-stop-server</id> | ||
<phase>post-integration-test</phase> | ||
<goals> | ||
<goal>stop</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<version>2.22.1</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>integration-test</goal> | ||
<goal>verify</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<profiles> | ||
<profile> | ||
<id>ol</id> | ||
<activation> | ||
<property> | ||
<name>boostRuntime</name> | ||
<value>ol</value> | ||
</property> | ||
</activation> | ||
<dependencies> | ||
<dependency> | ||
<groupId>boost.runtimes</groupId> | ||
<artifactId>openliberty</artifactId> | ||
</dependency> | ||
</dependencies> | ||
</profile> | ||
<profile> | ||
<id>wlp</id> | ||
<activation> | ||
<property> | ||
<name>boostRuntime</name> | ||
<value>wlp</value> | ||
</property> | ||
</activation> | ||
<dependencies> | ||
<dependency> | ||
<groupId>boost.runtimes</groupId> | ||
<artifactId>wlp</artifactId> | ||
</dependency> | ||
</dependencies> | ||
</profile> | ||
<profile> | ||
<id>tomee</id> | ||
<activation> | ||
<property> | ||
<name>boostRuntime</name> | ||
<value>tomee</value> | ||
</property> | ||
</activation> | ||
<dependencies> | ||
<dependency> | ||
<groupId>boost.runtimes</groupId> | ||
<artifactId>tomee</artifactId> | ||
</dependency> | ||
</dependencies> | ||
</profile> | ||
</profiles> | ||
</project> |
22 changes: 22 additions & 0 deletions
22
...c/it/test-cdi-2.0/src/main/java/io/openliberty/guides/inventory/InventoryApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// tag::copyright[] | ||
/******************************************************************************* | ||
* Copyright (c) 2017 IBM Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* IBM Corporation - Initial implementation | ||
*******************************************************************************/ | ||
// end::copyright[] | ||
package io.openliberty.guides.inventory; | ||
|
||
// JAX-RS | ||
import javax.ws.rs.ApplicationPath; | ||
import javax.ws.rs.core.Application; | ||
|
||
@ApplicationPath("inventory") | ||
public class InventoryApplication extends Application { | ||
|
||
} |
46 changes: 46 additions & 0 deletions
46
...n/src/it/test-cdi-2.0/src/main/java/io/openliberty/guides/inventory/InventoryManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// tag::copyright[] | ||
/******************************************************************************* | ||
* Copyright (c) 2017, 2019 IBM Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* IBM Corporation - Initial implementation | ||
*******************************************************************************/ | ||
// end::copyright[] | ||
package io.openliberty.guides.inventory; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Properties; | ||
import io.openliberty.guides.inventory.client.SystemClient; | ||
import io.openliberty.guides.inventory.model.InventoryList; | ||
import io.openliberty.guides.inventory.model.SystemData; | ||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.inject.Inject; | ||
|
||
// tag::ApplicationScoped[] | ||
@ApplicationScoped | ||
// end::ApplicationScoped[] | ||
public class InventoryManager { | ||
|
||
private List<SystemData> systems = Collections.synchronizedList(new ArrayList<>()); | ||
|
||
public void add(String hostname, Properties systemProps) { | ||
Properties props = new Properties(); | ||
props.setProperty("os.name", systemProps.getProperty("os.name")); | ||
props.setProperty("user.name", systemProps.getProperty("user.name")); | ||
|
||
SystemData system = new SystemData(hostname, props); | ||
if (!systems.contains(system)) { | ||
systems.add(system); | ||
} | ||
} | ||
|
||
public InventoryList list() { | ||
return new InventoryList(systems); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
.../src/it/test-cdi-2.0/src/main/java/io/openliberty/guides/inventory/InventoryResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// tag::copyright[] | ||
/******************************************************************************* | ||
* Copyright (c) 2017, 2019 IBM Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* IBM Corporation - Initial implementation | ||
*******************************************************************************/ | ||
// end::copyright[] | ||
package io.openliberty.guides.inventory; | ||
|
||
import java.util.Properties; | ||
import javax.enterprise.context.RequestScoped; | ||
import javax.inject.Inject; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.PathParam; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
import javax.ws.rs.core.Response; | ||
import io.openliberty.guides.inventory.model.InventoryList; | ||
import io.openliberty.guides.inventory.client.SystemClient; | ||
|
||
@RequestScoped | ||
@Path("/systems") | ||
public class InventoryResource { | ||
|
||
@Inject | ||
InventoryManager manager; | ||
|
||
@Inject | ||
SystemClient systemClient; | ||
|
||
@GET | ||
@Path("/{hostname}") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public Response getPropertiesForHost(@PathParam("hostname") String hostname) { | ||
// Get properties for host | ||
Properties props = systemClient.getProperties(hostname); | ||
if (props == null) { | ||
return Response.status(Response.Status.NOT_FOUND) | ||
.entity("ERROR: Unknown hostname or the system service may not be " + "running on " + hostname) | ||
.build(); | ||
} | ||
|
||
// Add to inventory | ||
manager.add(hostname, props); | ||
return Response.ok(props).build(); | ||
} | ||
|
||
@GET | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public InventoryList listContents() { | ||
return manager.list(); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'jsonp' dependency isn't really doing anything here, at least not in Liberty (probably not in TomEE either). Maybe slightly confusing to leave it in not a huge deal though.
We should start looking at using 'jsonp' together with a JSON provider dependency to use a non-default provider, as a totally separate issue though.