Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Chameleon tests #59

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
sudo: required
dist: trusty
language: java
install: true
jdk:
- openjdk7
- oraclejdk8
- openjdk9
- oraclejdk11
env:
- RUNTIME=ol RUNTIME_VERSION=19.0.0.3
- RUNTIME=ol RUNTIME_VERSION=18.0.0.4
- RUNTIME=ol RUNTIME_VERSION=19.0.0.6
- RUNTIME=wlp RUNTIME_VERSION=19.0.0.3
- RUNTIME=wlp RUNTIME_VERSION=18.0.0.4
matrix:
exclude:
- jdk: oraclejdk11
env: RUNTIME=ol RUNTIME_VERSION=18.0.0.4
- jdk: oraclejdk11
env: RUNTIME=wlp RUNTIME_VERSION=18.0.0.4
- RUNTIME=wlp RUNTIME_VERSION=19.0.0.6
before_install:
- |
if [ "$TRAVIS_JDK_VERSION" = "oraclejdk8" ] || [ "$TRAVIS_JDK_VERSION" = "openjdk9" ]; then
echo 'Installing chameleon lib...'
git clone https://github.com/chyt/arquillian-container-chameleon.git ./chameleon
cd ./chameleon
git checkout liberty
mvn clean install -DskipTests > out.txt
cd ..
fi;
script:
- travis_wait mvn verify -Druntime=$RUNTIME -DruntimeVersion=$RUNTIME_VERSION
- mvn clean install -DskipTests -Dinvoker.skip=true
- |
if [ "$TRAVIS_JDK_VERSION" = "oraclejdk8" ] || [ "$TRAVIS_JDK_VERSION" = "openjdk9" ]; then
travis_wait mvn verify -Druntime=$RUNTIME -DruntimeVersion=$RUNTIME_VERSION -Plog-info
else
travis_wait mvn verify -Druntime=$RUNTIME -DruntimeVersion=$RUNTIME_VERSION -Plog-info -Dinvoker.skip=true
fi;
12 changes: 11 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,17 @@ install:
- cmd: mvn --version
- cmd: java -version

before_build:
- cmd: |
echo "Installing chameleon lib ...."
git clone https://github.com/chyt/arquillian-container-chameleon.git chameleon
cd chameleon
git checkout liberty
mvn clean install -DskipTests > out.txt
cd..

build_script:
- "mvn verify -Druntime=%RUNTIME% -DruntimeVersion=19.0.0.3 -Plog-info"
- "mvn clean install -DskipTests -Dinvoker.skip=true"
- "mvn verify -Druntime=%RUNTIME% -DruntimeVersion=19.0.0.6 -Plog-info -DskipTests"

test: off
26 changes: 25 additions & 1 deletion liberty-managed/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,26 @@
</systemPropertyVariables>
</configuration>
</execution>

</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<debug>false</debug>
<projectsDirectory>src/it</projectsDirectory>
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
<streamLogs>true</streamLogs>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<phase>verify</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
Expand Down Expand Up @@ -261,6 +280,11 @@
<version>4.5.6</version>
</dependency>

<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>

<!-- Java EE Spec APIs -->

Expand Down
11 changes: 11 additions & 0 deletions liberty-managed/src/it/chameleon/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.classpath
.project
.settings
.vscode
nb-configuration.xml
nbactions.xml
target
.factorypath
.tern-project
/.apt_generated/
/.apt_generated_tests/
1 change: 1 addition & 0 deletions liberty-managed/src/it/chameleon/invoker.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoker.goals.1 = clean install
3 changes: 3 additions & 0 deletions liberty-managed/src/it/chameleon/jaxrs/defaultValue/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# A @QueryParam example

This example demonstrates how to use @QueryParam.
25 changes: 25 additions & 0 deletions liberty-managed/src/it/chameleon/jaxrs/defaultValue/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>

<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.openliberty.arquillian</groupId>
<artifactId>chameleon-jaxrs-tests</artifactId>
<version>0.1-SNAPSHOT</version>
</parent>
<artifactId>jaxrsDefaultValue</artifactId>
<packaging>war</packaging>
<name>A JAX-RS @DefaultValue example</name>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR(S) DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
package jakartaee.examples.jaxrs.defaultvalue;

import java.util.HashSet;
import java.util.Set;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;

/**
* The application for the JAX-RS @DefaultValue example.
*
* @author Manfred Riem ([email protected])
*/
@ApplicationPath("rest")
public class DefaultValueApplication extends Application {

/**
* Get the classes.
*
* @return the classes.
*/
@Override
public Set<Class<?>> getClasses() {
HashSet classes = new HashSet();
classes.add(DefaultValueResource.class);
return classes;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR(S) DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
package jakartaee.examples.jaxrs.defaultvalue;

import javax.ws.rs.Consumes;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

/**
* The resource for the JAX-RS @DefaultValue example.
*
* @author Manfred Riem ([email protected])
*/
@Path("defaultValue")
public class DefaultValueResource {

/**
* defaultValue method.
*
* @param queryParam the query parameter.
* @return the value of the query parameter.
*/
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.TEXT_PLAIN)
public String defaultValue(@DefaultValue("defaultValue") @QueryParam("myparam") String queryParam) {
return queryParam;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version='1.0' encoding='UTF-8' ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>A JAX-RS @DefaultValue example</title>
</head>
<body>
<p>
Lets post directly to the REST endpoint with no query parameter,
relying on the default value.
</p>
<form action="rest/defaultValue" enctype="application/x-www-form-urlencoded" method="post">
<input id="form:submitButton" name="form:submitButton" type="submit" value="Submit"/>
</form>
<br/>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR(S) DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
package jakartaee.examples.jaxrs.defaultvalue;

import com.gargoylesoftware.htmlunit.TextPage;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import java.io.File;
import java.net.URL;
import org.arquillian.container.chameleon.runner.ArquillianChameleon;
import jakartaee.examples.utils.JakartaEEServer;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.test.api.ArquillianResource;
import static org.jboss.shrinkwrap.api.ShrinkWrap.create;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.After;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

/**
* The JUnit tests for the DefaultValueResource class.
*
* @author Manfred Riem ([email protected])
*/
@RunWith(ArquillianChameleon.class)
@JakartaEEServer
public class DefaultValueTest {

/**
* Stores the base URL.
*/
@ArquillianResource
private URL baseUrl;

/**
* Stores the web client.
*/
private WebClient webClient;

/**
* Setup before testing.
*/
@Before
public void before() {
webClient = new WebClient();
}

/**
* Create the deployment web archive.
*
* @return the deployment web archive.
*/
@Deployment
public static WebArchive createDeployment() {
return create(WebArchive.class).
addClasses(DefaultValueApplication.class, DefaultValueResource.class).
addAsWebResource(new File("src/main/webapp/index.html"));
}

/**
* Tear down after testing.
*/
@After
public void after() {
webClient.close();
}

/**
* Test @DefaultValue.
*
* @throws Exception when a serious error occurs.
*/
@RunAsClient
@Test
public void testDefaultValue() throws Exception {
HtmlPage page = webClient.getPage(baseUrl + "index.html");
String content = page.asXml();
assertTrue(content.contains("relying on the default value"));
TextPage textPage = page.getElementByName("form:submitButton").click();
assertTrue(textPage.getContent().contains("defaultValue"));
}
}
3 changes: 3 additions & 0 deletions liberty-managed/src/it/chameleon/jaxrs/formParam/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# A @FormParam example

This example demonstrates how to use @FormParam.
25 changes: 25 additions & 0 deletions liberty-managed/src/it/chameleon/jaxrs/formParam/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>

<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.openliberty.arquillian</groupId>
<artifactId>chameleon-jaxrs-tests</artifactId>
<version>0.1-SNAPSHOT</version>
</parent>
<artifactId>jaxrsFormParam</artifactId>
<packaging>war</packaging>
<name>A JAX-RS @FormParam example</name>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
Loading