-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Description
The complete codes can be found here.
Java:
D:\jdk8\bin\java -version
openjdk version "1.8.0_242"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_242-b08)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.242-b08, mixed mode)Maven:
mvn -v
Apache Maven 3.6.2 (40f52333136460af0dc0d7232c0dc0bcf0d9e117; 2019-08-27T23:06:16+08:00)
Maven home: D:\build\maven\bin\..
Java version: 1.8.0_242, vendor: AdoptOpenJDK, runtime: D:\jdk8\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"Test class.
@RunWith(Arquillian.class)
public class GreetingResourceTest {
private final static Logger LOGGER = Logger.getLogger(GreetingResourceTest.class.getName());
@Deployment(testable = false)
public static WebArchive createDeployment() {
return ShrinkWrap.create(WebArchive.class)
.addClass(GreetingMessage.class)
.addClass(GreetingService.class)
.addClasses(GreetingResource.class, JaxrsActivator.class)
// Enable CDI
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
}
@ArquillianResource
private URL base;
private Client client;
@Before
public void setup() {
this.client = ClientBuilder.newClient();
try {
Class<?> clazz = Class.forName("com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider");
this.client.register(clazz);
} catch (ClassNotFoundException e) {
LOGGER.warning("Only use for OpenLiberty/CXF which does not register a json provider automatically.");
}
}
@After
public void teardown() {
if(this.client != null) {
this.client.close();
}
}
@Test
public void should_create_greeting() throws MalformedURLException {
final WebTarget greetingTarget = client.target(URI.create(new URL(base, "api/greeting/JakartaEE").toExternalForm()));
try (final Response greetingGetResponse = greetingTarget.request()
.accept(MediaType.APPLICATION_JSON)
.get()) {
assertEquals("response status is ok", 200, greetingGetResponse.getStatus());
assertTrue("message should start with \"Say Hello to JakartaEE at \"",
greetingGetResponse.readEntity(GreetingMessage.class).getMessage().startsWith("Say Hello to JakartaEE"));
}
}
}Manven profile for glassfish embedded.
<profile>
<!-- JAXRS testing failed with aruqillian glassfish embedded -->
<id>arq-glassfish-embedded</id>
<properties>
<skipTests>true</skipTests>
</properties>
<dependencies>
<!-- Jersey Client -->
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-sse</artifactId>
<version>${jersey.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-binding</artifactId>
<version>${jersey.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.0.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>${jersey.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>${jersey.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.main.extras</groupId>
<artifactId>glassfish-embedded-all</artifactId>
<version>${glassfish.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-glassfish-embedded-3.1</artifactId>
<version>${arquillian-glassfish.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels