diff --git a/README.md b/README.md index 905d4b7..fe45d62 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ For more details about each component of this testsuite, please verify their doc - KIE SERVER: - [6.2](https://github.com/jboss-openshift/ce-testsuite/blob/master/kieserver/62/README.md) - [6.3](https://github.com/jboss-openshift/ce-testsuite/blob/master/kieserver/63/README.md) + - [6.4](https://github.com/jboss-openshift/ce-testsuite/blob/master/kieserver/64/README.md) - [SPARK](https://github.com/jboss-openshift/ce-testsuite/blob/master/spark/README.md) - [SSO](https://github.com/jboss-openshift/ce-testsuite/blob/master/sso/README.md) - [WEBSERVER](https://github.com/jboss-openshift/ce-testsuite/blob/master/webserver/README.md) diff --git a/kieserver/62/pom.xml b/kieserver/62/pom.xml index fad5bce..b2aaa80 100644 --- a/kieserver/62/pom.xml +++ b/kieserver/62/pom.xml @@ -16,12 +16,94 @@ kieserver62-ce-testsuite jar KIE Server v6.2 CE Testsuite - Decision Server Cloud Enablement Testsuite + KIE Server Cloud Enablement Testsuite includes tests for decision server and process server - + + 5.8.0.redhat-60083 + 1.0.1.Final-SNAPSHOT + 1.0.1.Final + 3.19.0-GA + + 6.2.0.GA-redhat-1 + 6.3.0.Final-redhat-5 + + + + + + + org.jboss.bom.brms + jboss-brms-bpmsuite-bom + ${version.jboss.bom.brms} + pom + import + + + + org.kie + kie-bom + ${version.org.kie} + pom + import + + + + org.apache.activemq + activemq-all + ${version.activemq} + + + + org.hibernate.javax.persistence + hibernate-jpa-2.0-api + ${version.javax.jpa} + + + + org.javassist + javassist + ${version.javassist} + - + + org.jboss.arquillian.container + arquillian-ce-api + ${version.arquillian.ce} + + + org.jboss.arquillian.container + arquillian-ce-cube + ${version.arquillian.ce} + + + + org.jboss.arquillian.container + arquillian-ce-fabric8 + ${version.arquillian.ce} + + + + org.jboss.arquillian.container + arquillian-ce-httpclient + ${version.arquillian.ce} + + + + org.jboss.arquillian.container + arquillian-ce-shrinkwrap + ${version.arquillian.ce} + + + + org.jboss.arquillian.container + arquillian-ce-utils + ${version.arquillian.ce} + + + + + @@ -29,16 +111,15 @@ jboss-logging - - org.slf4j - slf4j-log4j12 - - org.apache.httpcomponents httpclient + + org.slf4j + slf4j-log4j12 + @@ -54,6 +135,24 @@ test + + org.jboss.arquillian.container + arquillian-ce-api + test + + + + org.jboss.arquillian.container + arquillian-ce-cube + test + + + + org.jboss.arquillian.container + arquillian-ce-fabric8 + test + + org.jboss.arquillian.container arquillian-ce-httpclient @@ -67,7 +166,7 @@ org.jboss.arquillian.container - arquillian-ce-cube + arquillian-ce-utils test @@ -87,13 +186,23 @@ org.kie.server - kie-server-client + kie-server-api + - org.kie + org.kie.server kie-server-client + + org.kie.remote + kie-remote-jaxb + + + + org.kie.remote + kie-remote-client + @@ -102,6 +211,11 @@ activemq-all + + org.hibernate.javax.persistence + hibernate-jpa-2.0-api + provided + @@ -152,4 +266,5 @@ + diff --git a/kieserver/62/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerBasicMulltiContainerTest.java b/kieserver/62/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerBasicMultiContainerTest.java similarity index 97% rename from kieserver/62/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerBasicMulltiContainerTest.java rename to kieserver/62/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerBasicMultiContainerTest.java index 30a4880..b6d830a 100644 --- a/kieserver/62/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerBasicMulltiContainerTest.java +++ b/kieserver/62/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerBasicMultiContainerTest.java @@ -52,7 +52,7 @@ @OpenShiftResources({ @OpenShiftResource("https://raw.githubusercontent.com/${template.repository:jboss-openshift}/application-templates/${template.branch:master}/secrets/decisionserver-app-secret.json") }) -public class DecisionServerBasicMulltiContainerTest extends DecisionServerTestBase { +public class DecisionServerBasicMultiContainerTest extends DecisionServerTestBase { @RouteURL("kie-app") private URL routeURL; diff --git a/kieserver/63/README.md b/kieserver/63/README.md index ca719f3..534a337 100644 --- a/kieserver/63/README.md +++ b/kieserver/63/README.md @@ -2,9 +2,18 @@ This testsuite will test all KIE Server 6.3 S2I application templates which are: - - [decisionserver63-amq-s2i.json](https://github.com/jboss-openshift/application-templates/blob/master/decisionserver/decisionserver62-amq-s2i.json) - - [decisionserver63-basic-s2i.json](https://github.com/jboss-openshift/application-templates/blob/master/decisionserver/decisionserver62-basic-s2i.json) - - [decisionserver63-https-s2i.json](https://github.com/jboss-openshift/application-templates/blob/master/decisionserver/decisionserver62-https-s2i.json) + - [decisionserver63-amq-s2i.json](https://github.com/jboss-openshift/application-templates/blob/master/decisionserver/decisionserver63-amq-s2i.json) + - [decisionserver63-basic-s2i.json](https://github.com/jboss-openshift/application-templates/blob/master/decisionserver/decisionserver63-basic-s2i.json) + - [decisionserver63-https-s2i.json](https://github.com/jboss-openshift/application-templates/blob/master/decisionserver/decisionserver63-https-s2i.json) + - [processserver63-amq-mysql-persistent-s2i.json](https://github.com/jboss-openshift/application-templates/blob/master/processserver/processserver63-amq-mysql-persistent-s2i.json) + - [processserver63-amq-mysql-s2i.json](https://github.com/jboss-openshift/application-templates/blob/master/processserver/processserver63-amq-mysql-s2i.json) + - [processserver63-amq-postgresql-persistent-s2i.json](https://github.com/jboss-openshift/application-templates/blob/master/processserver/processserver63-amq-postgresql-persistent-s2i.json) + - [processserver63-amq-postgresql-s2i.json](https://github.com/jboss-openshift/application-templates/blob/master/processserver/processserver63-amq-postgresql-s2i.json) + - [processserver63-basic-s2i.json](https://github.com/jboss-openshift/application-templates/blob/master/processserver/processserver63-basic-s2i.json) + - [processserver63-mysql-persistent-s2i.json](https://github.com/jboss-openshift/application-templates/blob/master/processserver/processserver63-mysql-persistent-s2i.json) + - [processserver63-mysql-s2i.json](https://github.com/jboss-openshift/application-templates/blob/master/processserver/processserver63-mysql-s2i.json) + - [processserver63-postgresql-persistent-s2i.json](https://github.com/jboss-openshift/application-templates/blob/master/processserver/processserver63-postgresql-persistent-s2i.json) + - [processserver63-postgresql-s2i.json](https://github.com/jboss-openshift/application-templates/blob/master/processserver/processserver63-postgresql-s2i.json) For all tests, on this case we are using the following quickstart application: diff --git a/kieserver/63/pom.xml b/kieserver/63/pom.xml index 81e5e31..5ccf8eb 100644 --- a/kieserver/63/pom.xml +++ b/kieserver/63/pom.xml @@ -19,15 +19,91 @@ KIE Server Cloud Enablement Testsuite includes tests for decision server and process server - - 6.3.0.GA-redhat-3 - 6.4.0.Final-redhat-3 + 5.8.0.redhat-60083 + 1.0.1.Final-SNAPSHOT + 1.0.1.Final + 3.19.0-GA + + 6.3.4.GA-redhat-3 + 6.4.0.Final-redhat-13 - - - + + + + + org.jboss.bom.brms + jboss-brms-bpmsuite-bom + ${version.jboss.bom.brms} + pom + import + + + + org.kie + kie-bom + ${version.org.kie} + pom + import + + + + org.apache.activemq + activemq-all + ${version.activemq} + + + + org.hibernate.javax.persistence + hibernate-jpa-2.0-api + ${version.javax.jpa} + + + + org.javassist + javassist + ${version.javassist} + + + + org.jboss.arquillian.container + arquillian-ce-api + ${version.arquillian.ce} + + + + org.jboss.arquillian.container + arquillian-ce-cube + ${version.arquillian.ce} + + + + org.jboss.arquillian.container + arquillian-ce-fabric8 + ${version.arquillian.ce} + + + + org.jboss.arquillian.container + arquillian-ce-httpclient + ${version.arquillian.ce} + + + + org.jboss.arquillian.container + arquillian-ce-shrinkwrap + ${version.arquillian.ce} + + + + org.jboss.arquillian.container + arquillian-ce-utils + ${version.arquillian.ce} + + + + @@ -59,6 +135,24 @@ test + + org.jboss.arquillian.container + arquillian-ce-api + test + + + + org.jboss.arquillian.container + arquillian-ce-cube + test + + + + org.jboss.arquillian.container + arquillian-ce-fabric8 + test + + org.jboss.arquillian.container arquillian-ce-httpclient @@ -72,7 +166,7 @@ org.jboss.arquillian.container - arquillian-ce-cube + arquillian-ce-utils test @@ -100,28 +194,21 @@ kie-server-client - org.kie.remote kie-remote-jaxb + org.kie.remote kie-remote-client - - org.openshift.kieserver - openshift-kieserver-common - - - org.apache.activemq activemq-all - @@ -129,8 +216,6 @@ hibernate-jpa-2.0-api provided - - @@ -167,6 +252,11 @@ org/jboss/**/*Test.java + dns,CEArquillianNameService @@ -181,4 +271,5 @@ + diff --git a/kieserver/63/src/test/java/org/jboss/test/arquillian/ce/common/KieServerTestBase.java b/kieserver/63/src/test/java/org/jboss/test/arquillian/ce/common/KieServerTestBase.java index ab3f5b5..23c849b 100644 --- a/kieserver/63/src/test/java/org/jboss/test/arquillian/ce/common/KieServerTestBase.java +++ b/kieserver/63/src/test/java/org/jboss/test/arquillian/ce/common/KieServerTestBase.java @@ -23,6 +23,25 @@ package org.jboss.test.arquillian.ce.common; +import java.io.UnsupportedEncodingException; +import java.net.MalformedURLException; +import java.net.URL; +import java.security.InvalidParameterException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Properties; +import java.util.logging.Logger; +import java.util.regex.Pattern; + +import javax.jms.ConnectionFactory; +import javax.jms.Queue; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.xml.bind.DatatypeConverter; + import org.jboss.arquillian.ce.shrinkwrap.Files; import org.jboss.arquillian.ce.shrinkwrap.Libraries; import org.jboss.shrinkwrap.api.ShrinkWrap; @@ -37,24 +56,6 @@ import org.kie.server.client.KieServicesFactory; import org.openshift.quickstarts.decisionserver.hellorules.Person; -import javax.jms.ConnectionFactory; -import javax.jms.Queue; -import javax.naming.Context; -import javax.naming.InitialContext; -import javax.xml.bind.DatatypeConverter; -import java.io.UnsupportedEncodingException; -import java.net.MalformedURLException; -import java.net.URL; -import java.security.InvalidParameterException; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Properties; -import java.util.logging.Logger; -import java.util.regex.Pattern; - /** * @author Filippe Spolti *

@@ -95,7 +96,6 @@ protected static WebArchive getDeploymentInternal() throws Exception { war.addPackage(Person.class.getPackage()); war.addAsLibraries(Libraries.transitive("org.kie.server", "kie-server-client")); war.addAsLibraries(Libraries.transitive("org.jboss.arquillian.container", "arquillian-ce-httpclient")); - war.addAsLibraries(Libraries.transitive("org.openshift.kieserver","openshift-kieserver-common")); Files.PropertiesHandle handle = Files.createPropertiesHandle(FILENAME); handle.addProperty("kie.username", KIE_USERNAME); handle.addProperty("kie.password", KIE_PASSWORD); @@ -221,21 +221,29 @@ public void checkKieServerContainer(String containerId) throws Exception { * @returns the MD5 hash of the given container. * @throws Exception for any kind of error. */ - public String convertKieContainerId(String kieContainer) throws NoSuchAlgorithmException, UnsupportedEncodingException { + public String convertKieContainerId(String kieContainer) { //validate the container name received: final Pattern PATTERN = Pattern.compile("(^\\w*=*)(\\w:*)(\\w*:*)"); - if (!PATTERN.matcher(kieContainer).find()) { throw new InvalidParameterException("Please use the following format: ContainerName=G:A:V"); } + return md5sum(kieContainer); + } + + /* + * Convert the provided string into a md5 hash. + * @param s + * @return the MD5 hash of the given string + */ + protected String md5sum(String s) { try { MessageDigest md5 = MessageDigest.getInstance("MD5"); - byte[] digest = md5.digest(kieContainer.getBytes("UTF-8")); + byte[] digest = md5.digest(s.getBytes("UTF-8")); return DatatypeConverter.printHexBinary(digest).toLowerCase(); } catch (NoSuchAlgorithmException e) { - throw new NoSuchAlgorithmException("Failed to generate the MD5 hash of " + kieContainer); + throw new RuntimeException("Failed to generate the MD5 hash of [" + s + "]: " + e.getMessage()); } catch (UnsupportedEncodingException e) { - throw new UnsupportedEncodingException("Failed to generate the MD5 hash of " + kieContainer); + throw new RuntimeException("Failed to generate the MD5 hash of [" + s + "]: " + e.getMessage()); } } } diff --git a/kieserver/63/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerBasicMulltiContainerTest.java b/kieserver/63/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerBasicMultiContainerTest.java similarity index 97% rename from kieserver/63/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerBasicMulltiContainerTest.java rename to kieserver/63/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerBasicMultiContainerTest.java index db6bd84..6b1fcaf 100644 --- a/kieserver/63/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerBasicMulltiContainerTest.java +++ b/kieserver/63/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerBasicMultiContainerTest.java @@ -55,7 +55,7 @@ @OpenShiftResources({ @OpenShiftResource("https://raw.githubusercontent.com/${template.repository:jboss-openshift}/application-templates/${template.branch:master}/secrets/decisionserver-app-secret.json") }) -public class DecisionServerBasicMulltiContainerTest extends DecisionServerTestBase { +public class DecisionServerBasicMultiContainerTest extends DecisionServerTestBase { @RouteURL("kie-app") private URL routeURL; diff --git a/kieserver/63/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerTestBase.java b/kieserver/63/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerTestBase.java index e6be2bc..235dbaf 100644 --- a/kieserver/63/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerTestBase.java +++ b/kieserver/63/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerTestBase.java @@ -25,9 +25,7 @@ import java.io.IOException; import java.io.StringReader; -import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; -import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; @@ -70,7 +68,6 @@ import org.kie.server.client.KieServicesConfiguration; import org.kie.server.client.KieServicesFactory; import org.kie.server.client.RuleServicesClient; -import org.openshift.kieserver.common.coder.SumCoder; import org.openshift.quickstarts.decisionserver.hellorules.Greeting; import org.openshift.quickstarts.decisionserver.hellorules.Person; @@ -148,10 +145,10 @@ public void checkDecisionServerContainer() throws MalformedURLException { prepareClientInvocation(); for (KieContainerResource container : getKieRestServiceClient(getRouteURL()).listContainers().getResult().getContainers()) { - String containerAliasToID = new SumCoder.MD5().encode(container.getResolvedReleaseId().getArtifactId() + "=" + container.getReleaseId()); + String containerAliasToID = md5sum(container.getResolvedReleaseId().getArtifactId() + "=" + container.getReleaseId()); //Make sure the second container name is AnotherContainer if (!containerAliasToID.equals(container.getContainerId())) { - containerAliasToID = new SumCoder.MD5().encode("AnotherContainer=" + container.getReleaseId()); + containerAliasToID = md5sum("AnotherContainer=" + container.getReleaseId()); } Assert.assertTrue(container.getContainerId().equals(containerAliasToID)); Assert.assertEquals(org.kie.server.api.model.KieContainerStatus.STARTED, container.getStatus()); @@ -244,10 +241,10 @@ public void checkDecisionServerContainerAMQ() throws NamingException { log.info("Running test checkDecisionServerContainerAMQ"); log.info("Trying to connect to AMQ HOST: " + AMQ_HOST); for (KieContainerResource container : getKieJmsServiceClient().listContainers().getResult().getContainers()) { - String containerAliasToID = new SumCoder.MD5().encode(container.getResolvedReleaseId().getArtifactId() + "=" + container.getReleaseId()); + String containerAliasToID = md5sum(container.getResolvedReleaseId().getArtifactId() + "=" + container.getReleaseId()); //Make sure the second container name is AnotherContainer if (!containerAliasToID.equals(container.getContainerId())) { - containerAliasToID = new SumCoder.MD5().encode("AnotherContainer=" + container.getReleaseId()); + containerAliasToID = md5sum("AnotherContainer=" + container.getReleaseId()); } Assert.assertTrue(container.getContainerId().equals(containerAliasToID)); Assert.assertEquals(org.kie.server.api.model.KieContainerStatus.STARTED, container.getStatus()); @@ -259,7 +256,7 @@ public void checkDecisionServerContainerAMQ() throws NamingException { * Verifies the KieContainer ID, it should be AnotherContainer * Verifies the KieContainer Status, it should be org.kie.server.api.model.KieContainerStatus.STARTED */ - public void checkSecondDecisionServerContainer() throws MalformedURLException, UnsupportedEncodingException, NoSuchAlgorithmException { + public void checkSecondDecisionServerContainer() throws MalformedURLException { log.info("Running test checkSecondDecisionServerContainer"); // for untrusted connections prepareClientInvocation(); @@ -311,7 +308,7 @@ public void checkFireAllRulesInSecondContainer() throws MalformedURLException { * Verifies the Second KieContainer ID using AMQ client, it should be AnotherContainer * Verifies the KieContainer Status, it should be org.kie.server.api.model.KieContainerStatus.STARTED */ - public void checkDecisionServerSecondContainerAMQ() throws NamingException, UnsupportedEncodingException, NoSuchAlgorithmException { + public void checkDecisionServerSecondContainerAMQ() throws NamingException { log.info("Running test checkDecisionServerSecondContainerAMQ"); List kieContainers = getKieJmsServiceClient().listContainers().getResult().getContainers(); @@ -491,10 +488,10 @@ public void checkDecisionServerSecureMultiContainerHttpClient() { //kieContainers's should be 2 Assert.assertEquals(2, kieContainers.getContainers().size()); for (KieContainerResource container : kieContainers.getContainers()) { - String containerAliasToID = new SumCoder.MD5().encode(container.getResolvedReleaseId().getArtifactId() + "=" + container.getReleaseId()); + String containerAliasToID = md5sum(container.getResolvedReleaseId().getArtifactId() + "=" + container.getReleaseId()); //Make sure the second container name is AnotherContainer if (!containerAliasToID.equals(container.getContainerId())) { - containerAliasToID = new SumCoder.MD5().encode("AnotherContainer=" + container.getReleaseId()); + containerAliasToID = md5sum("AnotherContainer=" + container.getReleaseId()); } Assert.assertEquals(container.getContainerId(), containerAliasToID); Assert.assertEquals(org.kie.server.api.model.KieContainerStatus.STARTED, container.getStatus()); diff --git a/kieserver/64/README.md b/kieserver/64/README.md new file mode 100644 index 0000000..b58f8dd --- /dev/null +++ b/kieserver/64/README.md @@ -0,0 +1,86 @@ +# CE-Testsuite - Kie Server (Decision Server and Intelligent Process Server) + +This testsuite will test all KIE Server 6.4 S2I application templates which are: + + - [decisionserver64-amq-s2i.json](https://github.com/jboss-openshift/application-templates/blob/master/decisionserver/decisionserver64-amq-s2i.json) + - [decisionserver64-basic-s2i.json](https://github.com/jboss-openshift/application-templates/blob/master/decisionserver/decisionserver64-basic-s2i.json) + - [decisionserver64-https-s2i.json](https://github.com/jboss-openshift/application-templates/blob/master/decisionserver/decisionserver64-https-s2i.json) + - [processserver64-amq-mysql-persistent-s2i.json](https://github.com/jboss-openshift/application-templates/blob/master/processserver/processserver64-amq-mysql-persistent-s2i.json) + - [processserver64-amq-mysql-s2i.json](https://github.com/jboss-openshift/application-templates/blob/master/processserver/processserver64-amq-mysql-s2i.json) + - [processserver64-amq-postgresql-persistent-s2i.json](https://github.com/jboss-openshift/application-templates/blob/master/processserver/processserver64-amq-postgresql-persistent-s2i.json) + - [processserver64-amq-postgresql-s2i.json](https://github.com/jboss-openshift/application-templates/blob/master/processserver/processserver64-amq-postgresql-s2i.json) + - [processserver64-basic-s2i.json](https://github.com/jboss-openshift/application-templates/blob/master/processserver/processserver64-basic-s2i.json) + - [processserver64-mysql-persistent-s2i.json](https://github.com/jboss-openshift/application-templates/blob/master/processserver/processserver64-mysql-persistent-s2i.json) + - [processserver64-mysql-s2i.json](https://github.com/jboss-openshift/application-templates/blob/master/processserver/processserver64-mysql-s2i.json) + - [processserver64-postgresql-persistent-s2i.json](https://github.com/jboss-openshift/application-templates/blob/master/processserver/processserver64-postgresql-persistent-s2i.json) + - [processserver64-postgresql-s2i.json](https://github.com/jboss-openshift/application-templates/blob/master/processserver/processserver64-postgresql-s2i.json) + +For all tests, on this case we are using the following quickstart application: + + - [Hellorules](https://github.com/jboss-openshift/openshift-quickstarts/tree/master/decisionserver/hellorules) + +This aplication, basically, only prints the salutation of the given Person's name used to *fire-all-rules*. Example: +```java + person.setName("Filippe Spolti"); + List> commands = new ArrayList<>(); + commands.add((Command) CommandFactory.newInsert(person)); + commands.add((Command) CommandFactory.newFireAllRules()); + commands.add((Command) CommandFactory.newQuery("greetings", "get greeting")); + return CommandFactory.newBatchExecution(commands, "HelloRulesSession"); +``` + +### How to run the tests +The Ce-Testsuite uses the [ce-arq](https://github.com/jboss-openshift/ce-arq) which is a API that allow us to test our application templates in a running OpenshiftV3 instance. To run the tests you need: + - Maven 3 or higher + - Java 7 or higher + - Openshift V3 or higher + +The CE-Testsuite is divided by profiles, to enable the Kie Server profile all you need to do is to use the following maven parameter: +```sh +-Pkieserver64 +``` +###### Required ce-arq parameteres + - -P**profile_name** + - -Pkieserver64 + - -Dkubernetes.master=**address of your running OSE instance (master note)** + - -Dkubernetes.master=https://openshift-master.mydomain.com:8443 + - -Dkubernetes.registry.url=**the registry address running in your ose instance** + - -Dkubernetes.registry.url=openshift-master.mydomain.com:5001 + - -Ddocker.url=**Docker url address** + - -Ddocker.url=https://openshift-master.mydomain.com:2375 + - -Drouter.hostIP=**The OSE router IP** + - -Drouter.hostIP=192.168.1.254 + - You can change this parameter name in the pom.xml + +###### Optional ce-arq parameteres + - -Dtest=**The test class name, if you want to run only one test, otherwise all tests will be executed** + - -Dtest=DecisionServerAmqTest + - -Dkubernetes.ignore.cleanup=true **(default is false), It will ignore the resources cleanup, so you can take a look in the used pods to troubleshooting** + +> **All those are java parameters, so use -D.** +___ + +###### Running all tests +For this example we'll consider the IP address 192.168.1.254 for required parameters, Example: +```sh +$ mvn clean package test -Pkieserver64 -Dkubernetes.master=https://192.168.1.254:8443 -Dkubernetes.registry.url=192.168.1.254:5001 -Ddocker.url=http://192.168.1.254:2375 -Drouter.hostIP=192.168.1.254 +``` +###### Running a specific test and ignoring the cleanup after the tests gets finished +Example: +```sh +$ mvn clean package test -Pkieserver64 -Dkubernetes.master=https://192.168.1.254:8443 -Dkubernetes.registry.url=192.168.1.254:5001 -Ddocker.url=http://192.168.1.254:2375 -Drouter.hostIP=192.168.1.254 -Dtest=DecisionServerAmqTest -Dkubernetes.ignore.cleanup=true +``` + +#### What this tests cover? +This test covers all basic operations to make sure the docker image generated by the used application templates will work as expected, it will do basic operations against the deployed quickstart, which is: + + - Create a single container and: + - Test if the container was successfully created and started. + - Check the Decision Server capability, (BRM). + - Fire all rules. +Both tests are tested againts all supported ways: using Drools JAVA API, Rest API and AMQ interface. + +#### Found an issue? +Please, feel free to report the issue that you found [here](https://github.com/jboss-openshift/ce-testsuite/issues/new). + +__For feedbacks please send us an email (cloud-enablement-feedback@redhat.com) and let us know what you are thinking.__ diff --git a/kieserver/64/pom.xml b/kieserver/64/pom.xml new file mode 100644 index 0000000..7d6b4ed --- /dev/null +++ b/kieserver/64/pom.xml @@ -0,0 +1,275 @@ + + + + + + org.jboss.ce.testsuite + kieserver-ce-testsuite + 1.0.0-SNAPSHOT + + + + 4.0.0 + + + kieserver64-ce-testsuite + jar + KIE Server v6.4 CE Testsuite + KIE Server Cloud Enablement Testsuite includes tests for decision server and process server + + + 5.8.0.redhat-60083 + 1.0.1.Final-SNAPSHOT + 1.0.1.Final + 3.19.0-GA + + 6.4.2.GA-redhat-2 + 6.5.0.Final-redhat-7 + + + + + + + org.jboss.bom.brms + jboss-brms-bpmsuite-bom + ${version.jboss.bom.brms} + pom + import + + + + org.kie + kie-bom + ${version.org.kie} + pom + import + + + + org.apache.activemq + activemq-all + ${version.activemq} + + + + org.hibernate.javax.persistence + hibernate-jpa-2.0-api + ${version.javax.jpa} + + + + org.javassist + javassist + ${version.javassist} + + + + org.jboss.arquillian.container + arquillian-ce-api + ${version.arquillian.ce} + + + + org.jboss.arquillian.container + arquillian-ce-cube + ${version.arquillian.ce} + + + + org.jboss.arquillian.container + arquillian-ce-fabric8 + ${version.arquillian.ce} + + + + org.jboss.arquillian.container + arquillian-ce-httpclient + ${version.arquillian.ce} + + + + org.jboss.arquillian.container + arquillian-ce-shrinkwrap + ${version.arquillian.ce} + + + + org.jboss.arquillian.container + arquillian-ce-utils + ${version.arquillian.ce} + + + + + + + + + org.jboss.logging + jboss-logging + + + + org.apache.httpcomponents + httpclient + + + + org.slf4j + slf4j-log4j12 + + + + + + org.jboss.arquillian.junit + arquillian-junit-container + test + + + + org.jboss.arquillian.protocol + arquillian-protocol-jmx + test + + + + org.jboss.arquillian.container + arquillian-ce-api + test + + + + org.jboss.arquillian.container + arquillian-ce-cube + test + + + + org.jboss.arquillian.container + arquillian-ce-fabric8 + test + + + + org.jboss.arquillian.container + arquillian-ce-httpclient + + + + org.jboss.arquillian.container + arquillian-ce-shrinkwrap + test + + + + org.jboss.arquillian.container + arquillian-ce-utils + test + + + + org.jboss.as + jboss-as-arquillian-container-remote + test + + + + junit + junit + test + + + + + + org.kie.server + kie-server-api + + + + org.kie.server + kie-server-client + + + + org.kie.remote + kie-remote-jaxb + + + + org.kie.remote + kie-remote-client + + + + + + org.apache.activemq + activemq-all + + + + org.hibernate.javax.persistence + hibernate-jpa-2.0-api + provided + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + unpack-dependencies + process-test-classes + + unpack-dependencies + + + org.jboss + test-jar + test + ${project.build.directory}/test-classes + false + true + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + alphabetical + true + false + once + + org/jboss/**/*Test.java + + + + + dns,CEArquillianNameService + default + ${kubernetes.master} + ${kubernetes.auth.token} + ${router.hostIP} + jboss-openshift + master + + + + + + + diff --git a/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/common/KieServerTestBase.java b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/common/KieServerTestBase.java new file mode 100644 index 0000000..23c849b --- /dev/null +++ b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/common/KieServerTestBase.java @@ -0,0 +1,249 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2015 Red Hat Inc. and/or its affiliates and other + * contributors as indicated by the @author tags. All rights reserved. + * See the copyright.txt in the distribution for a full listing of + * individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.test.arquillian.ce.common; + +import java.io.UnsupportedEncodingException; +import java.net.MalformedURLException; +import java.net.URL; +import java.security.InvalidParameterException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Properties; +import java.util.logging.Logger; +import java.util.regex.Pattern; + +import javax.jms.ConnectionFactory; +import javax.jms.Queue; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.xml.bind.DatatypeConverter; + +import org.jboss.arquillian.ce.shrinkwrap.Files; +import org.jboss.arquillian.ce.shrinkwrap.Libraries; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.jboss.test.arquillian.ce.decisionserver.DecisionServerTestBase; +import org.junit.Assert; +import org.kie.server.api.marshalling.MarshallingFormat; +import org.kie.server.api.model.KieContainerResource; +import org.kie.server.api.model.KieServerInfo; +import org.kie.server.client.KieServicesClient; +import org.kie.server.client.KieServicesConfiguration; +import org.kie.server.client.KieServicesFactory; +import org.openshift.quickstarts.decisionserver.hellorules.Person; + +/** + * @author Filippe Spolti + *

+ * Place here all code/methods in common for process and decision server + */ +public abstract class KieServerTestBase { + + protected static final String FILENAME = "kie.properties"; + private KieServicesConfiguration kieServicesConfiguration; + private HashMap clients = new HashMap<>(); + + public String AMQ_HOST = "tcp://kie-app-amq-tcp:61616"; + + /* + * Sort the kieContainers list in alphabetical order + * To sort the list just add the following in the desired method: + * Collections.sort(KieContainersList, ALPHABETICAL_ORDER); + */ + public static final Comparator ALPHABETICAL_ORDER = + new Comparator() { + @Override + public int compare(KieContainerResource o1, KieContainerResource o2) { + return o1.getContainerId().compareTo(o2.getContainerId()); + } + }; + //kie-server credentials + protected static final String KIE_USERNAME = System.getProperty("kie.username", "kieserver"); + protected static final String KIE_PASSWORD = System.getProperty("kie.password", "Redhat@123"); + // AMQ credentials + public static final String MQ_USERNAME = System.getProperty("mq.username", "kieserver"); + public static final String MQ_PASSWORD = System.getProperty("mq.password", "Redhat@123"); + + protected static WebArchive getDeploymentInternal() throws Exception { + WebArchive war = ShrinkWrap.create(WebArchive.class, "run-in-pod.war"); + war.setWebXML("web.xml"); + war.addClass(KieServerTestBase.class); + war.addClass(DecisionServerTestBase.class); + war.addPackage(Person.class.getPackage()); + war.addAsLibraries(Libraries.transitive("org.kie.server", "kie-server-client")); + war.addAsLibraries(Libraries.transitive("org.jboss.arquillian.container", "arquillian-ce-httpclient")); + Files.PropertiesHandle handle = Files.createPropertiesHandle(FILENAME); + handle.addProperty("kie.username", KIE_USERNAME); + handle.addProperty("kie.password", KIE_PASSWORD); + handle.addProperty("mq.username", MQ_USERNAME); + handle.addProperty("mq.password", MQ_PASSWORD); + handle.store(war); + + return war; + } + + protected final Logger log = Logger.getLogger(KieServerTestBase.class.getName()); + + protected abstract URL getRouteURL(); + + protected void prepareClientInvocation() { + // do nothing in basic + } + + protected KieServicesConfiguration configureRestClient(URL baseURL) throws MalformedURLException { + log.info("Received a new client build request for url " + baseURL); + if (clients.containsKey(baseURL)) { + log.info("Returning cached Kie client for base url: " + baseURL); + return clients.get(baseURL); + + } else { + log.info("Kie Service Client empty or configuration for base url " + baseURL + " not found, building a new one..."); + kieServicesConfiguration = KieServicesFactory.newRestConfiguration(new URL(baseURL, + "/kie-server/services/rest/server").toString(), KIE_USERNAME, KIE_PASSWORD); + kieServicesConfiguration.setMarshallingFormat(MarshallingFormat.XSTREAM); + clients.put(baseURL, kieServicesConfiguration); + return kieServicesConfiguration; + } + } + + protected KieServicesConfiguration configureAmqClient() throws Exception { + Properties props = new Properties(); + props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory"); + props.setProperty(Context.PROVIDER_URL, AMQ_HOST); + props.setProperty(Context.SECURITY_PRINCIPAL, KIE_USERNAME); + props.setProperty(Context.SECURITY_CREDENTIALS, KIE_PASSWORD); + InitialContext context = new InitialContext(props); + ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup("ConnectionFactory"); + Queue requestQueue = (Queue) context.lookup("dynamicQueues/queue/KIE.SERVER.REQUEST"); + Queue responseQueue = (Queue) context.lookup("dynamicQueues/queue/KIE.SERVER.RESPONSE"); + KieServicesConfiguration kieServicesConfiguration = KieServicesFactory.newJMSConfiguration(connectionFactory, requestQueue, + responseQueue, MQ_USERNAME, MQ_PASSWORD); + kieServicesConfiguration.setMarshallingFormat(MarshallingFormat.XSTREAM); + return kieServicesConfiguration; + } + + /* + * @returns the kieService client + * @param URL url - KieServer address + * @throwns Exception for any issue + */ + protected KieServicesClient getKieRestServiceClient(URL baseURL) throws MalformedURLException { + return KieServicesFactory.newKieServicesClient(configureRestClient(baseURL)); + } + + /* + * Verifies the server capabilities, for: + * decisionserver-openshift:6.3: KieServer BRM + * processserver-openshift:6.3: KieServer BPM + * @params URL url - kieserver address + * String cap - capability to test + * @throws Exception for all issues + */ + public void checkKieServerCapabilities(URL url, String cap) throws MalformedURLException { + log.info("Running test checkKieServerCapabilities"); + // for untrusted connections + prepareClientInvocation(); + + // Getting the KieServiceClient + KieServicesClient kieServicesClient = getKieRestServiceClient(url); + KieServerInfo serverInfo = kieServicesClient.getServerInfo().getResult(); + + // Where the result will be stored + String serverCapabilitiesResult = ""; + + // Reading Server capabilities + for (String capability : serverInfo.getCapabilities()) { + if (!capability.toUpperCase().equals("KIESERVER")) { + serverCapabilitiesResult += capability; // TODO -- we used to have empty 'if' here ... ??!!? + } + } + + // Sometimes the getCapabilities returns "KieServer BRM" and another time "BRM KieServer" + // We have to make sure the result will be the same always + if ("BRM".equals(cap)) { + Assert.assertTrue(serverCapabilitiesResult.contains("BRM")); + } else if ("BPM".equals(cap)) { + //for process server both BPM and BRM capabilities should be enabled + Assert.assertTrue(serverCapabilitiesResult.contains("BPM") || serverCapabilitiesResult.contains("BRM")); + } + } + + /* + * Verifies a single container + * Verifies the KieContainer ID + * Verifies the KieContainer Status, it should be org.kie.server.api.model.KieContainerStatus.STARTED + * @param String containerId + */ + public void checkKieServerContainer(String containerId) throws Exception { + log.info("Running test checkKieServerContainer"); + // for untrusted connections + prepareClientInvocation(); + + List kieContainers = getKieRestServiceClient(getRouteURL()).listContainers().getResult().getContainers(); + + log.info("Container ID: " + kieContainers.get(0).getContainerId()); + log.info("Container Status: " + kieContainers.get(0).getStatus()); + + Assert.assertTrue(kieContainers.get(0).getContainerId().equals(convertKieContainerId(containerId))); + // verify the KieContainer Status + Assert.assertEquals(org.kie.server.api.model.KieContainerStatus.STARTED, kieContainers.get(0).getStatus()); + } + + /* + * Convert the deployed container in a md5 hash + * @param String KieContainer in the following pattern: + * ContainerName=G:A:V + * Ex: processserver-library=org.openshift.quickstarts:processserver-library:1.3.0.Final + * @returns the MD5 hash of the given container. + * @throws Exception for any kind of error. + */ + public String convertKieContainerId(String kieContainer) { + //validate the container name received: + final Pattern PATTERN = Pattern.compile("(^\\w*=*)(\\w:*)(\\w*:*)"); + if (!PATTERN.matcher(kieContainer).find()) { + throw new InvalidParameterException("Please use the following format: ContainerName=G:A:V"); + } + return md5sum(kieContainer); + } + + /* + * Convert the provided string into a md5 hash. + * @param s + * @return the MD5 hash of the given string + */ + protected String md5sum(String s) { + try { + MessageDigest md5 = MessageDigest.getInstance("MD5"); + byte[] digest = md5.digest(s.getBytes("UTF-8")); + return DatatypeConverter.printHexBinary(digest).toLowerCase(); + } catch (NoSuchAlgorithmException e) { + throw new RuntimeException("Failed to generate the MD5 hash of [" + s + "]: " + e.getMessage()); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException("Failed to generate the MD5 hash of [" + s + "]: " + e.getMessage()); + } + } +} diff --git a/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerAmqTest.java b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerAmqTest.java new file mode 100644 index 0000000..fd3098a --- /dev/null +++ b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerAmqTest.java @@ -0,0 +1,109 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2015 Red Hat Inc. and/or its affiliates and other + * contributors as indicated by the @author tags. All rights reserved. + * See the copyright.txt in the distribution for a full listing of + * individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.test.arquillian.ce.decisionserver; + +import java.net.MalformedURLException; +import java.net.URL; + +import javax.naming.NamingException; + +import org.jboss.arquillian.ce.api.OpenShiftResource; +import org.jboss.arquillian.ce.api.OpenShiftResources; +import org.jboss.arquillian.ce.api.Template; +import org.jboss.arquillian.ce.api.TemplateParameter; +import org.jboss.arquillian.ce.cube.RouteURL; +import org.jboss.arquillian.ce.shrinkwrap.Libraries; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.container.test.api.RunAsClient; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + +/** + * @author Filippe Spolti + */ +@RunWith(Arquillian.class) +@Template(url = "https://raw.githubusercontent.com/${template.repository:jboss-openshift}/application-templates/${template.branch:master}/decisionserver/decisionserver64-amq-s2i.json", + parameters = { + @TemplateParameter(name = "KIE_SERVER_USER", value = "${kie.username:kieserver}"), + @TemplateParameter(name = "KIE_SERVER_PASSWORD", value = "${kie.password:Redhat@123}"), + @TemplateParameter(name = "MQ_USERNAME", value = "${mq.username:kieserver}"), + @TemplateParameter(name = "MQ_PASSWORD", value = "${mq.password:Redhat@123}") + } +) +@OpenShiftResources({ + @OpenShiftResource("https://raw.githubusercontent.com/${template.repository:jboss-openshift}/application-templates/${template.branch:master}/secrets/decisionserver-app-secret.json") +}) +public class DecisionServerAmqTest extends DecisionServerTestBase { + + @Deployment + public static WebArchive getDeployment() throws Exception { + WebArchive war = getDeploymentInternal(); + war.addAsLibraries(Libraries.transitive("org.apache.activemq","activemq-all")); + war.addClass(DecisionServerAmqTest.class); + return war; + } + + @RouteURL("kie-app") + private URL routeURL; + + @Override + protected URL getRouteURL() { + return routeURL; + } + + @Test + @RunAsClient + public void testDecisionServerCapabilities() throws MalformedURLException { + checkKieServerCapabilities(getRouteURL(), "BRM"); + } + + @Test + @RunAsClient + public void testDecisionServerContainer() throws MalformedURLException { + checkDecisionServerContainer(); + } + + @Test + @RunAsClient + public void testFireAllRules() throws MalformedURLException { + checkFireAllRules(); + } + + @Test + public void testFireAllRulesAMQ() throws NamingException { + checkFireAllRulesAMQ(); + } + + @Test + public void testDecisionServerCapabilitiesAMQ() throws NamingException { + checkDecisionServerCapabilitiesAMQ(); + } + + @Test + public void testDecisionServerContainerAMQ() throws NamingException { + checkDecisionServerContainerAMQ(); + } +} diff --git a/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerBasicMultiContainerTest.java b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerBasicMultiContainerTest.java new file mode 100644 index 0000000..8b61031 --- /dev/null +++ b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerBasicMultiContainerTest.java @@ -0,0 +1,97 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2015 Red Hat Inc. and/or its affiliates and other + * contributors as indicated by the @author tags. All rights reserved. + * See the copyright.txt in the distribution for a full listing of + * individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.test.arquillian.ce.decisionserver; + +import java.io.UnsupportedEncodingException; +import java.net.MalformedURLException; +import java.net.URL; +import java.security.NoSuchAlgorithmException; + +import org.jboss.arquillian.ce.api.OpenShiftResource; +import org.jboss.arquillian.ce.api.OpenShiftResources; +import org.jboss.arquillian.ce.api.Template; +import org.jboss.arquillian.ce.api.TemplateParameter; +import org.jboss.arquillian.ce.cube.RouteURL; +import org.jboss.arquillian.container.test.api.RunAsClient; +import org.jboss.arquillian.junit.Arquillian; +import org.junit.Test; +import org.junit.runner.RunWith; + +/** + * @author Filippe Spolti + */ + +@RunWith(Arquillian.class) +@Template(url = "https://raw.githubusercontent.com/${template.repository:jboss-openshift}/application-templates/${template.branch:master}/decisionserver/decisionserver64-basic-s2i.json", + parameters = { + //the Containers list will be sorted in alphabetical order + @TemplateParameter(name = "KIE_CONTAINER_DEPLOYMENT", value = "decisionserver-hellorules=org.openshift.quickstarts:decisionserver-hellorules:1.3.0.Final|" + + "AnotherContainer=org.openshift.quickstarts:decisionserver-hellorules:1.3.0.Final"), + @TemplateParameter(name = "KIE_SERVER_USER", value = "${kie.username:kieserver}"), + @TemplateParameter(name = "KIE_SERVER_PASSWORD", value = "${kie.password:Redhat@123}") + } +) +@OpenShiftResources({ + @OpenShiftResource("https://raw.githubusercontent.com/${template.repository:jboss-openshift}/application-templates/${template.branch:master}/secrets/decisionserver-app-secret.json") +}) +public class DecisionServerBasicMultiContainerTest extends DecisionServerTestBase { + + @RouteURL("kie-app") + private URL routeURL; + + @Override + protected URL getRouteURL() { + return routeURL; + } + + @Test + @RunAsClient + public void testDecisionServerCapabilities() throws MalformedURLException { + checkKieServerCapabilities(getRouteURL(), "BRM"); + } + + @Test + @RunAsClient + public void testDecisionServerContainer() throws MalformedURLException { + checkDecisionServerContainer(); + } + + @Test + @RunAsClient + public void testFireAllRules() throws MalformedURLException { + checkFireAllRules(); + } + + @Test + @RunAsClient + public void testSecondDecisionServerContainer() throws UnsupportedEncodingException, NoSuchAlgorithmException, MalformedURLException { + checkSecondDecisionServerContainer(); + } + + @Test + @RunAsClient + public void testFireAllRulesInSecondContainer() throws MalformedURLException { + checkFireAllRulesInSecondContainer(); + } +} diff --git a/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerBasicSecureMultiContainerTest.java b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerBasicSecureMultiContainerTest.java new file mode 100644 index 0000000..64f40a1 --- /dev/null +++ b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerBasicSecureMultiContainerTest.java @@ -0,0 +1,112 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2015 Red Hat Inc. and/or its affiliates and other + * contributors as indicated by the @author tags. All rights reserved. + * See the copyright.txt in the distribution for a full listing of + * individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.test.arquillian.ce.decisionserver; + +import static org.jboss.arquillian.ce.api.Tools.trustAllCertificates; + +import java.io.UnsupportedEncodingException; +import java.net.MalformedURLException; +import java.net.URL; +import java.security.NoSuchAlgorithmException; + +import org.jboss.arquillian.ce.api.OpenShiftResource; +import org.jboss.arquillian.ce.api.OpenShiftResources; +import org.jboss.arquillian.ce.api.Template; +import org.jboss.arquillian.ce.api.TemplateParameter; +import org.jboss.arquillian.ce.cube.RouteURL; +import org.jboss.arquillian.container.test.api.RunAsClient; +import org.jboss.arquillian.junit.Arquillian; +import org.junit.Test; +import org.junit.runner.RunWith; + +/** + * @author Filippe Spolti + */ + +@RunWith(Arquillian.class) +@Template(url = "https://raw.githubusercontent.com/${template.repository:jboss-openshift}/application-templates/${template.branch:master}/decisionserver/decisionserver64-https-s2i.json", + parameters = { + //the Containers list will be sorted in alphabetical order + @TemplateParameter(name = "KIE_CONTAINER_DEPLOYMENT", value = "decisionserver-hellorules=org.openshift.quickstarts:decisionserver-hellorules:1.3.0.Final|" + + "AnotherContainer=org.openshift.quickstarts:decisionserver-hellorules:1.3.0.Final"), + @TemplateParameter(name = "KIE_SERVER_USER", value = "${kie.username:kieserver}"), + @TemplateParameter(name = "KIE_SERVER_PASSWORD", value = "${kie.password:Redhat@123}") + } +) +@OpenShiftResources({ + @OpenShiftResource("https://raw.githubusercontent.com/${template.repository:jboss-openshift}/application-templates/${template.branch:master}/secrets/decisionserver-app-secret.json") +}) +public class DecisionServerBasicSecureMultiContainerTest extends DecisionServerTestBase { + + @RouteURL("secure-kie-app") + private URL routeURL; + + @Override + protected URL getRouteURL() { + return routeURL; + } + + @Test + @RunAsClient + public void testDecisionServerCapabilities() throws MalformedURLException { + checkKieServerCapabilities(getRouteURL(), "BRM"); + } + + @Test + @RunAsClient + public void testDecisionServerContainer() throws MalformedURLException { + checkDecisionServerContainer(); + } + + @Test + @RunAsClient + public void testFireAllRules() throws MalformedURLException { + checkFireAllRules(); + } + + @Test + @RunAsClient + public void testSecondDecisionServerContainer() throws UnsupportedEncodingException, NoSuchAlgorithmException, MalformedURLException { + checkSecondDecisionServerContainer(); + } + + @Test + @RunAsClient + public void testFireAllRulesInSecondContainer() throws MalformedURLException { + checkFireAllRulesInSecondContainer(); + } + + /* only needed for non-production test scenarios + * @throws Exception for any error, inherited from org.jboss.arquillian.ce.api.trustAllCertificates + */ + @Override + protected void prepareClientInvocation() { + try { + trustAllCertificates(); + } catch (Exception e) { + e.printStackTrace(); + } + log.info("Trusting all certs"); + } +} diff --git a/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerBasicSecureTest.java b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerBasicSecureTest.java new file mode 100644 index 0000000..231c7e8 --- /dev/null +++ b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerBasicSecureTest.java @@ -0,0 +1,95 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2015 Red Hat Inc. and/or its affiliates and other + * contributors as indicated by the @author tags. All rights reserved. + * See the copyright.txt in the distribution for a full listing of + * individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.test.arquillian.ce.decisionserver; + +import static org.jboss.arquillian.ce.api.Tools.trustAllCertificates; + +import java.net.MalformedURLException; +import java.net.URL; + +import org.jboss.arquillian.ce.api.OpenShiftResource; +import org.jboss.arquillian.ce.api.OpenShiftResources; +import org.jboss.arquillian.ce.api.Template; +import org.jboss.arquillian.ce.api.TemplateParameter; +import org.jboss.arquillian.ce.cube.RouteURL; +import org.jboss.arquillian.container.test.api.RunAsClient; +import org.jboss.arquillian.junit.Arquillian; +import org.junit.Test; +import org.junit.runner.RunWith; + +/** + * @author Filippe Spolti + */ + +@RunWith(Arquillian.class) +@Template(url = "https://raw.githubusercontent.com/${template.repository:jboss-openshift}/application-templates/${template.branch:master}/decisionserver/decisionserver64-https-s2i.json", + parameters = { + @TemplateParameter(name = "KIE_SERVER_USER", value = "${kie.username:kieserver}"), + @TemplateParameter(name = "KIE_SERVER_PASSWORD", value = "${kie.password:Redhat@123}") + } +) +@OpenShiftResources({ + @OpenShiftResource("https://raw.githubusercontent.com/${template.repository:jboss-openshift}/application-templates/${template.branch:master}/secrets/decisionserver-app-secret.json") +}) +public class DecisionServerBasicSecureTest extends DecisionServerTestBase { + + @RouteURL("secure-kie-app") + private URL routeURL; + + @Override + protected URL getRouteURL() { + return routeURL; + } + + @Test + @RunAsClient + public void testDecisionServerCapabilities() throws MalformedURLException { + checkKieServerCapabilities(getRouteURL(), "BRM"); + } + + @Test + @RunAsClient + public void testDecisionServerContainer() throws MalformedURLException { + checkDecisionServerContainer(); + } + + @Test + @RunAsClient + public void testFireAllRules() throws MalformedURLException { + checkFireAllRules(); + } + + /* only needed for non-production test scenarios + * @throws Exception for any error, inherited from org.jboss.arquillian.ce.api.trustAllCertificates + */ + @Override + protected void prepareClientInvocation() { + try { + trustAllCertificates(); + } catch (Exception e) { + e.printStackTrace(); + } + log.info("Trusting all certs"); + } +} diff --git a/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerBasicTest.java b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerBasicTest.java new file mode 100644 index 0000000..e185bb9 --- /dev/null +++ b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerBasicTest.java @@ -0,0 +1,80 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2015 Red Hat Inc. and/or its affiliates and other + * contributors as indicated by the @author tags. All rights reserved. + * See the copyright.txt in the distribution for a full listing of + * individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.test.arquillian.ce.decisionserver; + +import java.net.MalformedURLException; +import java.net.URL; + +import org.jboss.arquillian.ce.api.OpenShiftResource; +import org.jboss.arquillian.ce.api.OpenShiftResources; +import org.jboss.arquillian.ce.api.Template; +import org.jboss.arquillian.ce.api.TemplateParameter; +import org.jboss.arquillian.ce.cube.RouteURL; +import org.jboss.arquillian.container.test.api.RunAsClient; +import org.jboss.arquillian.junit.Arquillian; +import org.junit.Test; +import org.junit.runner.RunWith; + +/** + * @author Filippe Spolti + */ + +@RunWith(Arquillian.class) +@Template(url = "https://raw.githubusercontent.com/${template.repository:jboss-openshift}/application-templates/${template.branch:master}/decisionserver/decisionserver64-basic-s2i.json", + parameters = { + @TemplateParameter(name = "KIE_SERVER_USER", value = "${kie.username:kieserver}"), + @TemplateParameter(name = "KIE_SERVER_PASSWORD", value = "${kie.password:Redhat@123}") + } +) +@OpenShiftResources({ + @OpenShiftResource("https://raw.githubusercontent.com/${template.repository:jboss-openshift}/application-templates/${template.branch:master}/secrets/decisionserver-app-secret.json") +}) +public class DecisionServerBasicTest extends DecisionServerTestBase { + + @RouteURL("kie-app") + private URL routeURL; + + @Override + protected URL getRouteURL() { + return routeURL; + } + + @Test + @RunAsClient + public void testDecisionServerCapabilities() throws MalformedURLException { + checkKieServerCapabilities(getRouteURL(), "BRM"); + } + + @Test + @RunAsClient + public void testDecisionServerContainer() throws MalformedURLException { + checkDecisionServerContainer(); + } + + @Test + @RunAsClient + public void testFireAllRules() throws MalformedURLException { + checkFireAllRules(); + } +} diff --git a/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerHttpClientSecureAllInOneTest.java b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerHttpClientSecureAllInOneTest.java new file mode 100644 index 0000000..cd6a21a --- /dev/null +++ b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerHttpClientSecureAllInOneTest.java @@ -0,0 +1,94 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2015 Red Hat Inc. and/or its affiliates and other + * contributors as indicated by the @author tags. All rights reserved. + * See the copyright.txt in the distribution for a full listing of + * individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.test.arquillian.ce.decisionserver; + +import java.net.URL; + +import org.jboss.arquillian.ce.api.OpenShiftResource; +import org.jboss.arquillian.ce.api.OpenShiftResources; +import org.jboss.arquillian.ce.api.Template; +import org.jboss.arquillian.ce.api.TemplateParameter; +import org.jboss.arquillian.ce.shrinkwrap.Libraries; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + +import io.fabric8.utils.Base64Encoder; + +/** + * @author fspolti + */ + +@RunWith(Arquillian.class) +@Template(url = "https://raw.githubusercontent.com/${template.repository:jboss-openshift}/application-templates/${template.branch:master}/decisionserver/decisionserver64-https-s2i.json", + parameters = { + //the Containers list will be sorted in alphabetical order + @TemplateParameter(name = "KIE_CONTAINER_DEPLOYMENT", value = "decisionserver-hellorules=org.openshift.quickstarts:decisionserver-hellorules:1.3.0.Final|" + + "AnotherContainer=org.openshift.quickstarts:decisionserver-hellorules:1.3.0.Final"), + @TemplateParameter(name = "KIE_SERVER_USER", value = "${kie.username:kieserver}"), + @TemplateParameter(name = "KIE_SERVER_PASSWORD", value = "${kie.password:Redhat@123}") + } +) +@OpenShiftResources({ + @OpenShiftResource("https://raw.githubusercontent.com/${template.repository:jboss-openshift}/application-templates/${template.branch:master}/secrets/decisionserver-app-secret.json") +}) +public class DecisionServerHttpClientSecureAllInOneTest extends DecisionServerTestBase { + + @Deployment + public static WebArchive getDeployment() throws Exception { + WebArchive war = getDeploymentInternal(); + war.addAsLibraries(Libraries.single("org.jboss.arquillian.container", "arquillian-ce-httpclient")); + war.addAsLibraries(Libraries.transitive("org.apache.httpcomponents", "httpclient")); + war.addClass(Base64Encoder.class); + return war; + } + + @Override + protected URL getRouteURL() { + // no client side tests + return null; + } + + @Test + public void testDecisionServerCapabilitiesHttpClient() { + checkDecisionServerCapabilitiesHttpClient(); + } + + @Test + public void testDecisionServerSecureMultiContainerHttpClient() { + checkDecisionServerSecureMultiContainerHttpClient(); + } + + @Test + public void testFireAllRulesSecureHttpClient() throws Exception { + checkFireAllRulesSecureHttpClient(); + } + + @Test + public void testFireAllRulesSecureSecondContainerHttpClient() throws Exception { + checkFireAllRulesSecureSecondContainerHttpClient(); + } +} diff --git a/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerMultiContainerAmqTest.java b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerMultiContainerAmqTest.java new file mode 100644 index 0000000..629b933 --- /dev/null +++ b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerMultiContainerAmqTest.java @@ -0,0 +1,138 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2015 Red Hat Inc. and/or its affiliates and other + * contributors as indicated by the @author tags. All rights reserved. + * See the copyright.txt in the distribution for a full listing of + * individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.test.arquillian.ce.decisionserver; + +import java.io.UnsupportedEncodingException; +import java.net.MalformedURLException; +import java.net.URL; +import java.security.NoSuchAlgorithmException; + +import javax.naming.NamingException; + +import org.jboss.arquillian.ce.api.OpenShiftResource; +import org.jboss.arquillian.ce.api.OpenShiftResources; +import org.jboss.arquillian.ce.api.Template; +import org.jboss.arquillian.ce.api.TemplateParameter; +import org.jboss.arquillian.ce.cube.RouteURL; +import org.jboss.arquillian.ce.shrinkwrap.Libraries; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.container.test.api.RunAsClient; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + + +/** + * @author Filippe Spolti + */ + +@RunWith(Arquillian.class) +@Template(url = "https://raw.githubusercontent.com/${template.repository:jboss-openshift}/application-templates/${template.branch:master}/decisionserver/decisionserver64-amq-s2i.json", + parameters = { + //the Containers list will be sorted in alphabetical order + @TemplateParameter(name = "KIE_CONTAINER_DEPLOYMENT", value = "decisionserver-hellorules=org.openshift.quickstarts:decisionserver-hellorules:1.3.0.Final|" + + "AnotherContainer=org.openshift.quickstarts:decisionserver-hellorules:1.3.0.Final"), + @TemplateParameter(name = "KIE_SERVER_USER", value = "${kie.username:kieserver}"), + @TemplateParameter(name = "KIE_SERVER_PASSWORD", value = "${kie.password:Redhat@123}"), + @TemplateParameter(name = "MQ_USERNAME", value = "${mq.username:kieserver}"), + @TemplateParameter(name = "MQ_PASSWORD", value = "${mq.password:Redhat@123}") + } +) +@OpenShiftResources({ + @OpenShiftResource("https://raw.githubusercontent.com/${template.repository:jboss-openshift}/application-templates/${template.branch:master}/secrets/decisionserver-app-secret.json") +}) +public class DecisionServerMultiContainerAmqTest extends DecisionServerTestBase { + + @Deployment + public static WebArchive getDeployment() throws Exception { + WebArchive war = getDeploymentInternal(); + war.addAsLibraries(Libraries.transitive("org.apache.activemq","activemq-all")); + war.addClass(DecisionServerMultiContainerAmqTest.class); + return war; + } + + @RouteURL("kie-app") + private URL routeURL; + + @Override + protected URL getRouteURL() { + return routeURL; + } + + @Test + @RunAsClient + public void testDecisionServerCapabilities() throws MalformedURLException { + checkKieServerCapabilities(getRouteURL(), "BRM"); + } + + @Test + @RunAsClient + public void testDecisionServerContainer() throws MalformedURLException { + checkDecisionServerContainer(); + } + + @Test + @RunAsClient + public void testFireAllRules() throws MalformedURLException { + checkFireAllRules(); + } + + @Test + public void testFireAllRulesAMQ() throws NamingException { + checkFireAllRulesAMQ(); + } + + @Test + public void testDecisionServerCapabilitiesAMQ() throws NamingException { + checkDecisionServerCapabilitiesAMQ(); + } + + @Test + public void testDecisionServerContainerAMQ() throws NamingException { + checkDecisionServerContainerAMQ(); + } + + @Test + @RunAsClient + public void testSecondDecisionServerContainer() throws UnsupportedEncodingException, NoSuchAlgorithmException, MalformedURLException { + checkSecondDecisionServerContainer(); + } + + @Test + public void testDecisionServerSecondContainerAMQ() throws UnsupportedEncodingException, NamingException, NoSuchAlgorithmException { + checkDecisionServerSecondContainerAMQ(); + } + + @Test + @RunAsClient + public void testFireAllRulesInSecondContainer() throws MalformedURLException { + checkFireAllRulesInSecondContainer(); + } + + @Test + public void testFireAllRulesInSecondContainerAMQ() throws NamingException { + checkFireAllRulesInSecondContainerAMQ(); + } +} diff --git a/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerTestBase.java b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerTestBase.java new file mode 100644 index 0000000..235dbaf --- /dev/null +++ b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/decisionserver/DecisionServerTestBase.java @@ -0,0 +1,573 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2015 Red Hat Inc. and/or its affiliates and other + * contributors as indicated by the @author tags. All rights reserved. + * See the copyright.txt in the distribution for a full listing of + * individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.test.arquillian.ce.decisionserver; + +import java.io.IOException; +import java.io.StringReader; +import java.net.MalformedURLException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Properties; +import java.util.Set; +import java.util.logging.Logger; + +import javax.jms.ConnectionFactory; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; + +import org.jboss.arquillian.ce.api.ConfigurationHandle; +import org.jboss.arquillian.ce.httpclient.HttpClient; +import org.jboss.arquillian.ce.httpclient.HttpClientBuilder; +import org.jboss.arquillian.ce.httpclient.HttpRequest; +import org.jboss.arquillian.ce.httpclient.HttpResponse; +import org.jboss.arquillian.test.api.ArquillianResource; +import org.jboss.test.arquillian.ce.common.KieServerTestBase; +import org.junit.Assert; +import org.kie.api.command.BatchExecutionCommand; +import org.kie.api.command.Command; +import org.kie.api.runtime.ExecutionResults; +import org.kie.api.runtime.rule.QueryResults; +import org.kie.api.runtime.rule.QueryResultsRow; +import org.kie.internal.command.CommandFactory; +import org.kie.internal.runtime.helper.BatchExecutionHelper; +import org.kie.server.api.marshalling.Marshaller; +import org.kie.server.api.marshalling.MarshallerFactory; +import org.kie.server.api.marshalling.MarshallingFormat; +import org.kie.server.api.model.KieContainerResource; +import org.kie.server.api.model.KieContainerResourceList; +import org.kie.server.api.model.KieServerInfo; +import org.kie.server.api.model.ServiceResponse; +import org.kie.server.client.KieServicesClient; +import org.kie.server.client.KieServicesConfiguration; +import org.kie.server.client.KieServicesFactory; +import org.kie.server.client.RuleServicesClient; +import org.openshift.quickstarts.decisionserver.hellorules.Greeting; +import org.openshift.quickstarts.decisionserver.hellorules.Person; + +import io.fabric8.utils.Base64Encoder; + +/** + * @author Filippe Spolti + * @author Ales justin + */ +public abstract class DecisionServerTestBase extends KieServerTestBase { + protected final Logger log = Logger.getLogger(getClass().getName()); + + public Person person = new Person(); + + @ArquillianResource + protected ConfigurationHandle configuration; + + /* + * Returns the JMS kieService client + * TODO move to KieServerTestBase + */ + public KieServicesClient getKieJmsServiceClient() throws NamingException { + Properties props = new Properties(); + props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory"); + props.setProperty(Context.PROVIDER_URL, AMQ_HOST); + props.setProperty(Context.SECURITY_PRINCIPAL, KIE_USERNAME); + props.setProperty(Context.SECURITY_CREDENTIALS, KIE_PASSWORD); + InitialContext context = new InitialContext(props); + ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup("ConnectionFactory"); + javax.jms.Queue requestQueue = (javax.jms.Queue) context.lookup("dynamicQueues/queue/KIE.SERVER.REQUEST"); + javax.jms.Queue responseQueue = (javax.jms.Queue) context.lookup("dynamicQueues/queue/KIE.SERVER.RESPONSE"); + KieServicesConfiguration config = KieServicesFactory.newJMSConfiguration(connectionFactory, requestQueue, responseQueue, MQ_USERNAME, MQ_PASSWORD); + config.setMarshallingFormat(MarshallingFormat.XSTREAM); + return KieServicesFactory.newKieServicesClient(config); + } + + /* + * Return the RuleServicesClient + */ + public RuleServicesClient getRuleServicesClient(KieServicesClient client) { + return client.getServicesClient(RuleServicesClient.class); + } + + /* + * Return the classes used in the MarshallerFactory + */ + public Set> getClasses() { + Set> classes = new HashSet<>(); + classes.add(Person.class); + classes.add(Greeting.class); + return classes; + } + + /* + * Return the batch command used to fire rules + */ + public BatchExecutionCommand batchCommand() { + person.setName("Filippe Spolti"); + List> commands = new ArrayList<>(); + commands.add((Command) CommandFactory.newInsert(person)); + commands.add((Command) CommandFactory.newFireAllRules()); + commands.add((Command) CommandFactory.newQuery("greetings", "get greeting")); + return CommandFactory.newBatchExecution(commands, "HelloRulesSession"); + } + + /* + * Verifies the KieContainer ID, it should be 41895328c0d0a1747e2b24d53cbbfeb2 for decisionserver-hellorules + * and 5fe16e3ab6fc8ae7fbf9fd71b8eb57f1 for AnotherContainer + * Verifies the KieContainer Status, it should be org.kie.server.api.model.KieContainerStatus.STARTED + */ + public void checkDecisionServerContainer() throws MalformedURLException { + log.info("Running test checkDecisionServerContainer"); + + // for untrusted connections + prepareClientInvocation(); + + for (KieContainerResource container : getKieRestServiceClient(getRouteURL()).listContainers().getResult().getContainers()) { + String containerAliasToID = md5sum(container.getResolvedReleaseId().getArtifactId() + "=" + container.getReleaseId()); + //Make sure the second container name is AnotherContainer + if (!containerAliasToID.equals(container.getContainerId())) { + containerAliasToID = md5sum("AnotherContainer=" + container.getReleaseId()); + } + Assert.assertTrue(container.getContainerId().equals(containerAliasToID)); + Assert.assertEquals(org.kie.server.api.model.KieContainerStatus.STARTED, container.getStatus()); + } + } + + /* + * Test the rule deployed on Openshift, the template used to register the HelloRules container with the Kie jar: + * https://github.com/jboss-openshift/openshift-quickstarts/tree/master/decisionserver + */ + public void checkFireAllRules() throws MalformedURLException { + log.info("Running test checkFireAllRules"); + // for untrusted connections + prepareClientInvocation(); + + KieServicesClient client = getKieRestServiceClient(getRouteURL()); + + ServiceResponse response = getRuleServicesClient(client).executeCommandsWithResults("decisionserver-hellorules", batchCommand()); + + // response cannot be null + Assert.assertNotNull(response); + + QueryResults queryResults = (QueryResults) response.getResult().getValue("greetings"); + Greeting greeting = new Greeting(); + for (QueryResultsRow queryResult : queryResults) { + greeting = (Greeting) queryResult.get("greeting"); + System.out.println("Result: " + greeting.getSalutation()); + } + + Assert.assertEquals("Hello " + person.getName() + "!", greeting.getSalutation()); + } + + /* + * Test the rule deployed on Openshift using AMQ client, the template used to register the HelloRules container with the Kie jar: + * https://github.com/jboss-openshift/openshift-quickstarts/tree/master/decisionserver + */ + public void checkFireAllRulesAMQ() throws NamingException { + log.info("Running test checkFireAllRulesAMQ"); + log.info("Trying to connect to AMQ HOST: " + AMQ_HOST); + + KieServicesClient client = getKieJmsServiceClient(); + + ServiceResponse response = getRuleServicesClient(client).executeCommandsWithResults("decisionserver-hellorules", batchCommand()); + + // results cannot be null + Assert.assertNotNull(response); + + QueryResults queryResults = (QueryResults) response.getResult().getValue("greetings"); + Greeting greeting = new Greeting(); + for (QueryResultsRow queryResult : queryResults) { + greeting = (Greeting) queryResult.get("greeting"); + System.out.println("Result AMQ: " + greeting.getSalutation()); + } + + Assert.assertEquals("Hello " + person.getName() + "!", greeting.getSalutation()); + } + + /* + * Verifies the server capabilities using AMQ client, for decisionserver-openshift:6.2 it + * should be KieServer BRM + */ + public void checkDecisionServerCapabilitiesAMQ() throws NamingException { + log.info("Running test checkDecisionServerCapabilitiesAMQ"); + log.info("Trying to connect to AMQ HOST: " + AMQ_HOST); + // Where the result will be stored + String serverCapabilitiesResult = ""; + + // Getting the KieServiceClient JMS + KieServicesClient kieServicesClient = getKieJmsServiceClient(); + KieServerInfo serverInfo = kieServicesClient.getServerInfo().getResult(); + + // Reading Server capabilities + for (String capability : serverInfo.getCapabilities()) { + serverCapabilitiesResult += (capability); + } + + // Sometimes the getCapabilities returns "KieServer BRM" and another time "BRM KieServer" + // We have to make sure the result will be the same always + Assert.assertTrue(serverCapabilitiesResult.equals("KieServerBRM") || serverCapabilitiesResult.equals("BRMKieServer")); + } + + + //Multiple Container Tests + + /* + * Verifies the KieContainer ID, it should be decisionserver-hellorules + * Verifies the KieContainer Status, it should be org.kie.server.api.model.KieContainerStatus.STARTED + */ + public void checkDecisionServerContainerAMQ() throws NamingException { + log.info("Running test checkDecisionServerContainerAMQ"); + log.info("Trying to connect to AMQ HOST: " + AMQ_HOST); + for (KieContainerResource container : getKieJmsServiceClient().listContainers().getResult().getContainers()) { + String containerAliasToID = md5sum(container.getResolvedReleaseId().getArtifactId() + "=" + container.getReleaseId()); + //Make sure the second container name is AnotherContainer + if (!containerAliasToID.equals(container.getContainerId())) { + containerAliasToID = md5sum("AnotherContainer=" + container.getReleaseId()); + } + Assert.assertTrue(container.getContainerId().equals(containerAliasToID)); + Assert.assertEquals(org.kie.server.api.model.KieContainerStatus.STARTED, container.getStatus()); + } + } + + /* + * Tests a decision server with 2 containers: + * Verifies the KieContainer ID, it should be AnotherContainer + * Verifies the KieContainer Status, it should be org.kie.server.api.model.KieContainerStatus.STARTED + */ + public void checkSecondDecisionServerContainer() throws MalformedURLException { + log.info("Running test checkSecondDecisionServerContainer"); + // for untrusted connections + prepareClientInvocation(); + List kieContainers = getKieRestServiceClient(getRouteURL()).listContainers().getResult().getContainers(); + + // Sorting kieContainerList + Collections.sort(kieContainers, ALPHABETICAL_ORDER); + + //kieContainers size should be 2 + Assert.assertEquals(2, kieContainers.size()); + + //Convert the KIE_CONTAINER_DEPLOYMENT into md5 hash + String containerAliasToID = convertKieContainerId("AnotherContainer=org.openshift.quickstarts:decisionserver-hellorules:1.3.0.Final"); + + // verify the KieContainer Name + Assert.assertEquals(containerAliasToID, kieContainers.get(1).getContainerId()); + // verify the KieContainer Status + Assert.assertEquals(org.kie.server.api.model.KieContainerStatus.STARTED, kieContainers.get(1).getStatus()); + } + + /* + * Test the rule deployed on Openshift, the template used to register the HelloRules container with the Kie jar: + * https://github.com/jboss-openshift/openshift-quickstarts/tree/master/decisionserver + */ + public void checkFireAllRulesInSecondContainer() throws MalformedURLException { + log.info("Running test checkFireAllRulesInSecondContainer"); + // for untrusted connections + prepareClientInvocation(); + KieServicesClient client = getKieRestServiceClient(getRouteURL()); + + ServiceResponse response = getRuleServicesClient(client).executeCommandsWithResults("AnotherContainer", batchCommand()); + + Assert.assertTrue(response.getResult() != null && response.getResult().getIdentifiers().size() > 0); + + // results cannot be null + Assert.assertNotNull(response); + + QueryResults queryResults = (QueryResults) response.getResult().getValue("greetings"); + Greeting greeting = new Greeting(); + for (QueryResultsRow queryResult : queryResults) { + greeting = (Greeting) queryResult.get("greeting"); + System.out.println("Result: " + greeting.getSalutation()); + } + + Assert.assertEquals("Hello " + person.getName() + "!", greeting.getSalutation()); + } + + /* + * Verifies the Second KieContainer ID using AMQ client, it should be AnotherContainer + * Verifies the KieContainer Status, it should be org.kie.server.api.model.KieContainerStatus.STARTED + */ + public void checkDecisionServerSecondContainerAMQ() throws NamingException { + log.info("Running test checkDecisionServerSecondContainerAMQ"); + List kieContainers = getKieJmsServiceClient().listContainers().getResult().getContainers(); + + // Sorting kieContainerList + Collections.sort(kieContainers, ALPHABETICAL_ORDER); + + //kieContainers size should be 2 + Assert.assertEquals(2, kieContainers.size()); + + // verify the KieContainer Name + Assert.assertEquals(convertKieContainerId("AnotherContainer=org.openshift.quickstarts:decisionserver-hellorules:1.3.0.Final"), kieContainers.get(1).getContainerId()); + // verify the KieContainer Status + Assert.assertEquals(org.kie.server.api.model.KieContainerStatus.STARTED, kieContainers.get(1).getStatus()); + } + + /* + * Test the rule deployed on Openshift using AMQ client, this test case register a new template called AnotherContainer with the Kie jar: + * https://github.com/jboss-openshift/openshift-quickstarts/tree/master/decisionserver + */ + public void checkFireAllRulesInSecondContainerAMQ() throws NamingException { + log.info("Running test checkFireAllRulesInSecondContainerAMQ"); + log.info("Trying to connect to AMQ HOST: " + AMQ_HOST); + + KieServicesClient client = getKieJmsServiceClient(); + + ServiceResponse response = getRuleServicesClient(client).executeCommandsWithResults("AnotherContainer", batchCommand()); + + Assert.assertTrue(response.getResult() != null && response.getResult().getIdentifiers().size() > 0); + + // results cannot be null + Assert.assertNotNull(response); + + QueryResults queryResults = (QueryResults) response.getResult().getValue("greetings"); + Greeting greeting = new Greeting(); + for (QueryResultsRow queryResult : queryResults) { + greeting = (Greeting) queryResult.get("greeting"); + System.out.println("Result AMQ: " + greeting.getSalutation()); + } + + Assert.assertEquals("Hello " + person.getName() + "!", greeting.getSalutation()); + } + + /* + * Returns httpClient client + * @throws Exception, inherited from org.jboss.arquillian.ce.httpclient.untrustedConnectionClient() + */ + private HttpClient getClient() throws Exception { + return HttpClientBuilder.untrustedConnectionClient(); + } + + /* + * Returns httpClient client Authorization Base64 encoded + */ + private String authEncoding() { + return Base64Encoder.encode(KIE_USERNAME + ":" + KIE_PASSWORD); + } + + /* + *Return the formatted xml to perform the fire-all-rules using httpClient + */ + private String streamXML() { + return BatchExecutionHelper.newXStreamMarshaller().toXML(batchCommand()); + } + + /* + * Return the HttpPost response for fire-all-rules using httpClient + * @throws Exception - see getClient() + */ + private HttpResponse responseFireAllRules(String host, String containerId) throws Exception { + + //request + HttpRequest request = HttpClientBuilder.doPOST(host + "/kie-server/services/rest/server/containers/instances/" + containerId); + //setting headers + request.setHeader("accept", "application/xml"); + request.setHeader("X-KIE-ContentType", "XSTREAM"); + request.setHeader("Content-Type", "application/xml"); + request.setHeader("X-KIE-ClassType", "org.drools.core.command.runtime.BatchExecutionCommandImpl"); + + //setting authorization + request.setHeader("Authorization", "Basic " + authEncoding()); + + //Set the request post body + request.setEntity(streamXML()); + + //performing request + HttpClient client = getClient(); + return client.execute(request); + } + + /* + * Return the HttpGet response for generic requests using httpClient + */ + private HttpResponse genericResponse(String host, String uri) { + //request + HttpRequest request = HttpClientBuilder.doGET(host + uri); + try { + //setting header + request.setHeader("accept", "application/xml"); + //setting authorization + request.setHeader("Authorization", "Basic " + authEncoding()); + return getClient().execute(request); + } catch (Throwable e) { + throw new RuntimeException(String.format("Error executing request: %s", request), e); + } + } + + /* Verifies the server capabilities using httpClient, for decisionserver-openshift:6.2 it + * should be KieServer BRM + */ + public void checkDecisionServerCapabilitiesHttpClient() { + + String HOST = "https://" + System.getenv("SECURE_KIE_APP_SERVICE_HOST") + ":" + System.getenv("SECURE_KIE_APP_SERVICE_PORT"); + String URI = "/kie-server/services/rest/server"; + + //performing request + HttpResponse response = genericResponse(HOST, URI); + + //response code should be 200 + Assert.assertEquals(200, response.getResponseCode()); + + // retrieving output response + String output = null; + try { + output = response.getResponseBodyAsString(); + + //converting response in a object (org.kie.server.api.model.ServiceResponse) + JAXBContext jaxbContent = JAXBContext.newInstance(ServiceResponse.class); + Unmarshaller unmarshaller = jaxbContent.createUnmarshaller(); + + ServiceResponse serviceResponse = (ServiceResponse) unmarshaller.unmarshal(new StringReader(output)); + KieServerInfo serverInfo = (KieServerInfo) serviceResponse.getResult(); + + // Reading Server capabilities + String serverCapabilitiesResult = ""; + for (String capability : serverInfo.getCapabilities()) { + serverCapabilitiesResult += (capability); + } + + Assert.assertTrue(serverCapabilitiesResult.equals("KieServerBRM") || serverCapabilitiesResult.equals("BRMKieServer")); + + } catch (IOException e) { + e.printStackTrace(); + } catch (JAXBException e) { + e.printStackTrace(); + } + } + + /* + * Verifies the KieContainer ID + * Verifies the KieContainer Status, it should be org.kie.server.api.model.KieContainerStatus.STARTED + * test using httpClient + */ + public void checkDecisionServerSecureMultiContainerHttpClient() { + + String HOST = "https://" + System.getenv("SECURE_KIE_APP_SERVICE_HOST") + ":" + System.getenv("SECURE_KIE_APP_SERVICE_PORT"); + String URI = "/kie-server/services/rest/server/containers"; + + //Retrieving response + HttpResponse response = genericResponse(HOST, URI); + + //response code should be 200 + Assert.assertEquals(200, response.getResponseCode()); + + // retrieving output response + String output = null; + try { + output = response.getResponseBodyAsString(); + + + //converting response in a object (org.kie.server.api.model.ServiceResponse) + JAXBContext jaxbContent = JAXBContext.newInstance(ServiceResponse.class); + Unmarshaller unmarshaller = jaxbContent.createUnmarshaller(); + + ServiceResponse serviceResponse = (ServiceResponse) unmarshaller.unmarshal(new StringReader(output)); + KieContainerResourceList kieContainers = (KieContainerResourceList) serviceResponse.getResult(); + + //kieContainers's should be 2 + Assert.assertEquals(2, kieContainers.getContainers().size()); + for (KieContainerResource container : kieContainers.getContainers()) { + String containerAliasToID = md5sum(container.getResolvedReleaseId().getArtifactId() + "=" + container.getReleaseId()); + //Make sure the second container name is AnotherContainer + if (!containerAliasToID.equals(container.getContainerId())) { + containerAliasToID = md5sum("AnotherContainer=" + container.getReleaseId()); + } + Assert.assertEquals(container.getContainerId(), containerAliasToID); + Assert.assertEquals(org.kie.server.api.model.KieContainerStatus.STARTED, container.getStatus()); + } + } catch (IOException e) { + e.printStackTrace(); + } catch (JAXBException e) { + e.printStackTrace(); + } + } + + /* + * Test the rule deployed on Openshift using httpClient, the template used register the decisionserver-hellorules with the Kie jar: + * https://github.com/jboss-openshift/openshift-quickstarts/tree/master/decisionserver + * @throwns Exception, see responseFireAllRules + */ + public void checkFireAllRulesSecureHttpClient() throws Exception { + + String HOST = "https://" + System.getenv("SECURE_KIE_APP_SERVICE_HOST") + ":" + System.getenv("SECURE_KIE_APP_SERVICE_PORT"); + + HttpResponse response = responseFireAllRules(HOST, "decisionserver-hellorules"); + + //response code should be 200 + Assert.assertEquals(200, response.getResponseCode()); + + // retrieving output response + String output = response.getResponseBodyAsString(); + Assert.assertTrue(output != null && output.length() > 0); + + Marshaller marshaller = MarshallerFactory.getMarshaller(getClasses(), MarshallingFormat.XSTREAM, Person.class.getClassLoader()); + ServiceResponse serviceResponse = marshaller.unmarshall(output, null); + + Assert.assertTrue(serviceResponse.getType() == ServiceResponse.ResponseType.SUCCESS); + + QueryResults queryResults = (QueryResults) serviceResponse.getResult().getValue("greetings"); + Greeting greeting = new Greeting(); + for (QueryResultsRow queryResult : queryResults) { + greeting = (Greeting) queryResult.get("greeting"); + System.out.println("Result: " + greeting.getSalutation()); + } + + Assert.assertEquals("Hello " + person.getName() + "!", greeting.getSalutation()); + } + + /* + * Test the rule deployed on Openshift using httpClient and multicontainer feature, the template used register the + * AnotherContainer with the Kie jar: + * https://github.com/jboss-openshift/openshift-quickstarts/tree/master/decisionserver + * @throwns Exception, see responseFireAllRules + */ + public void checkFireAllRulesSecureSecondContainerHttpClient() throws Exception { + + String HOST = "https://" + System.getenv("SECURE_KIE_APP_SERVICE_HOST") + ":" + System.getenv("SECURE_KIE_APP_SERVICE_PORT"); + + //The value used here should be the same on the template definition + HttpResponse response = responseFireAllRules(HOST, convertKieContainerId("AnotherContainer=org.openshift.quickstarts:decisionserver-hellorules:1.3.0.Final")); + + //response code should be 200 + Assert.assertEquals(200, response.getResponseCode()); + + // retrieving output response + String output = response.getResponseBodyAsString(); + Assert.assertTrue(output != null && output.length() > 0); + + Marshaller marshaller = MarshallerFactory.getMarshaller(getClasses(), MarshallingFormat.XSTREAM, Person.class.getClassLoader()); + ServiceResponse serviceResponse = marshaller.unmarshall(output, null); + + Assert.assertTrue(serviceResponse.getType() == ServiceResponse.ResponseType.SUCCESS); + QueryResults queryResults = (QueryResults) serviceResponse.getResult().getValue("greetings"); + + Greeting greeting = new Greeting(); + for (QueryResultsRow queryResult : queryResults) { + greeting = (Greeting) queryResult.get("greeting"); + System.out.println("Result: " + greeting.getSalutation()); + } + + Assert.assertEquals("Hello " + person.getName() + "!", greeting.getSalutation()); + } +} \ No newline at end of file diff --git a/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/LibraryClient.java b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/LibraryClient.java new file mode 100644 index 0000000..d948e93 --- /dev/null +++ b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/LibraryClient.java @@ -0,0 +1,140 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2016 Red Hat Inc. and/or its affiliates and other + * contributors as indicated by the @author tags. All rights reserved. + * See the copyright.txt in the distribution for a full listing of + * individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jboss.test.arquillian.ce.processserver; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.kie.api.KieServices; +import org.kie.api.command.BatchExecutionCommand; +import org.kie.api.command.Command; +import org.kie.api.command.KieCommands; +import org.kie.api.runtime.ExecutionResults; +import org.kie.api.runtime.rule.QueryResults; +import org.kie.api.runtime.rule.QueryResultsRow; +import org.kie.server.api.marshalling.MarshallerFactory; +import org.kie.server.api.marshalling.MarshallingFormat; +import org.kie.server.api.model.ServiceResponse; +import org.kie.server.client.KieServicesClient; +import org.kie.server.client.KieServicesConfiguration; +import org.kie.server.client.KieServicesFactory; +import org.kie.server.client.ProcessServicesClient; +import org.kie.server.client.RuleServicesClient; +import org.openshift.quickstarts.processserver.library.types.Book; +import org.openshift.quickstarts.processserver.library.types.Loan; +import org.openshift.quickstarts.processserver.library.types.LoanRequest; +import org.openshift.quickstarts.processserver.library.types.LoanResponse; +import org.openshift.quickstarts.processserver.library.types.ReturnRequest; +import org.openshift.quickstarts.processserver.library.types.ReturnResponse; +import org.openshift.quickstarts.processserver.library.types.Suggestion; +import org.openshift.quickstarts.processserver.library.types.SuggestionRequest; +import org.openshift.quickstarts.processserver.library.types.SuggestionResponse; + +/** + * LibraryClient + *

+ * Client for working with a Library service. + */ +public class LibraryClient { + + private final KieCommands commands = KieServices.Factory.get().getCommands(); + private final KieServicesClient kieServicesClient; + + /** + * Create a new LibraryClient. + */ + public LibraryClient(KieServicesConfiguration config) { + Set> classes = new HashSet>(); + classes.add(Book.class); + classes.add(Loan.class); + classes.add(LoanRequest.class); + classes.add(LoanResponse.class); + classes.add(ReturnRequest.class); + classes.add(ReturnResponse.class); + classes.add(Suggestion.class); + classes.add(SuggestionRequest.class); + classes.add(SuggestionResponse.class); + config.setMarshallingFormat(MarshallingFormat.XSTREAM); + MarshallerFactory.getMarshaller(classes, config.getMarshallingFormat(), + Book.class.getClassLoader()); + kieServicesClient = KieServicesFactory.newKieServicesClient(config); + } + + public Suggestion getSuggestion(String keyword) { + RuleServicesClient ruleServicesClient = kieServicesClient.getServicesClient(RuleServicesClient.class); + SuggestionRequest suggestionRequest = new SuggestionRequest(); + suggestionRequest.setKeyword(keyword); + List> cmds = new ArrayList>(); + cmds.add(commands.newInsert(suggestionRequest)); + cmds.add(commands.newFireAllRules()); + cmds.add(commands.newQuery("suggestion", "get suggestion")); + BatchExecutionCommand batch = commands.newBatchExecution(cmds, "LibraryRuleSession"); + ExecutionResults execResults; + ServiceResponse serviceResponse = ruleServicesClient.executeCommandsWithResults( + "processserver-library", batch); + // logger.info(String.valueOf(serviceResponse)); + execResults = serviceResponse.getResult(); + QueryResults queryResults = (QueryResults) execResults.getValue("suggestion"); + if (queryResults != null) { + for (QueryResultsRow queryResult : queryResults) { + SuggestionResponse suggestionResponse = (SuggestionResponse) queryResult.get("suggestionResponse"); + if (suggestionResponse != null) { + return suggestionResponse.getSuggestion(); + } + } + } + return null; + } + + public Loan attemptLoan(Book book) { + ProcessServicesClient processServicesClient = kieServicesClient.getServicesClient(ProcessServicesClient.class); + Map parameters = new HashMap(); + LoanRequest loanRequest = new LoanRequest(); + loanRequest.setIsbn(book.getIsbn()); + parameters.put("loanRequest", loanRequest); + LoanResponse loanResponse; + Long pid = processServicesClient.startProcess("processserver-library", "LibraryProcess", parameters); + loanResponse = (LoanResponse) processServicesClient.getProcessInstanceVariable("processserver-library", pid, + "loanResponse"); + return loanResponse != null ? loanResponse.getLoan() : null; + } + + public boolean returnLoan(Loan loan) { + ProcessServicesClient processServicesClient = kieServicesClient.getServicesClient(ProcessServicesClient.class); + ReturnRequest returnRequest = new ReturnRequest(); + returnRequest.setLoan(loan); + ReturnResponse returnResponse; + processServicesClient.signalProcessInstance("processserver-library", loan.getId(), "ReturnSignal", returnRequest); + // returnResponse = + // (ReturnResponse)procserv.getProcessInstanceVariable("processserver-library", + // loan.getId(), "returnResponse"); + returnResponse = new ReturnResponse(); + returnResponse.setAcknowledged(true); + return returnResponse != null ? returnResponse.isAcknowledged() : false; + } + +} diff --git a/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/LibraryProcessAmqTestBase.java b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/LibraryProcessAmqTestBase.java new file mode 100644 index 0000000..516fd98 --- /dev/null +++ b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/LibraryProcessAmqTestBase.java @@ -0,0 +1,44 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2015 Red Hat Inc. and/or its affiliates and other + * contributors as indicated by the @author tags. All rights reserved. + * See the copyright.txt in the distribution for a full listing of + * individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.test.arquillian.ce.processserver; + +import org.jboss.arquillian.ce.shrinkwrap.Libraries; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Test; + +public abstract class LibraryProcessAmqTestBase extends LibraryProcessTestBase { + + public static WebArchive getDeployment() throws Exception { + WebArchive war = LibraryProcessTestBase.getDeployment(); + war.addAsLibraries(Libraries.transitive("org.apache.activemq", "activemq-all")); + war.addClass(LibraryProcessAmqTestBase.class); + return war; + } + + @Test + public void testLibraryAMQ() throws Exception { + runLibraryTest(configureAmqClient()); + } + +} diff --git a/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/LibraryProcessTestBase.java b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/LibraryProcessTestBase.java new file mode 100644 index 0000000..e8a50b3 --- /dev/null +++ b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/LibraryProcessTestBase.java @@ -0,0 +1,93 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2015 Red Hat Inc. and/or its affiliates and other + * contributors as indicated by the @author tags. All rights reserved. + * See the copyright.txt in the distribution for a full listing of + * individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.test.arquillian.ce.processserver; + +import java.net.URL; + +import org.jboss.arquillian.ce.cube.RouteURL; +import org.jboss.arquillian.ce.shrinkwrap.Libraries; +import org.jboss.arquillian.container.test.api.RunAsClient; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.jboss.test.arquillian.ce.common.KieServerTestBase; +import org.junit.Assert; +import org.junit.Test; +import org.kie.server.client.KieServicesConfiguration; +import org.openshift.quickstarts.processserver.library.types.Book; +import org.openshift.quickstarts.processserver.library.types.Loan; +import org.openshift.quickstarts.processserver.library.types.Suggestion; + +/** + * @author Filippe Spolti + */ +public abstract class LibraryProcessTestBase extends KieServerTestBase { + + @RouteURL("kie-app") + private URL routeURL; + + public static WebArchive getDeployment() throws Exception { + WebArchive war = getDeploymentInternal(); + war.addAsLibraries(Libraries.transitive("org.apache.activemq", "activemq-all")); + war.addPackage("org.openshift.quickstarts.processserver.library.types"); + war.addClass(LibraryClient.class); + war.addClass(LibraryProcessTestBase.class); + return war; + } + + @Override + protected URL getRouteURL() { + return routeURL; + } + + @Test + public void testLibraryREST() throws Exception { + runLibraryTest(configureRestClient(new URL("http://" + System.getenv("KIE_APP_SERVICE_HOST") + ":" + System.getenv("KIE_APP_SERVICE_PORT") + "/"))); + } + + @Test + @RunAsClient + public void testLibraryRESTRemote() throws Exception { + runLibraryTest(configureRestClient(getRouteURL())); + } + + protected void runLibraryTest(KieServicesConfiguration kiecfg) { + LibraryClient client = new LibraryClient(kiecfg); + + Suggestion suggestion1_Zombie = client.getSuggestion("Zombie War"); + Book book1_WorldWarZ = suggestion1_Zombie.getBook(); + log.info("Received suggestion for book: " + book1_WorldWarZ.getTitle() + " (isbn: " + book1_WorldWarZ.getIsbn() + + ")"); + Assert.assertEquals("World War Z", book1_WorldWarZ.getTitle()); + // take out 1st loan + log.info("Attempting 1st loan for isbn: " + book1_WorldWarZ.getIsbn()); + Loan loan1_WorldWarZ = client.attemptLoan(book1_WorldWarZ); + log.info("1st loan approved? " + loan1_WorldWarZ.isApproved()); + Assert.assertTrue(loan1_WorldWarZ.isApproved()); + Loan loan2_WorldWarZ = client.attemptLoan(book1_WorldWarZ); + log.info("2nd loan approved? " + loan1_WorldWarZ.isApproved()); + Assert.assertTrue(!loan2_WorldWarZ.isApproved()); + boolean returned = client.returnLoan(loan1_WorldWarZ); + log.info("Returned? " + returned); + Assert.assertTrue(returned); + } +} \ No newline at end of file diff --git a/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/PersistentTimersTestBase.java b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/PersistentTimersTestBase.java new file mode 100644 index 0000000..b0b068a --- /dev/null +++ b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/PersistentTimersTestBase.java @@ -0,0 +1,307 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2015 Red Hat Inc. and/or its affiliates and other + * contributors as indicated by the @author tags. All rights reserved. + * See the copyright.txt in the distribution for a full listing of + * individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.test.arquillian.ce.processserver; + +import org.jboss.arquillian.ce.api.OpenShiftHandle; +import org.jboss.arquillian.container.test.api.RunAsClient; +import org.jboss.arquillian.junit.InSequence; +import org.jboss.arquillian.test.api.ArquillianResource; +import org.jboss.test.arquillian.ce.common.KieServerTestBase; +import org.junit.Assert; +import org.junit.Test; +import org.kie.server.api.model.instance.VariableInstance; +import org.kie.server.client.ProcessServicesClient; +import org.kie.server.client.QueryServicesClient; +import org.kie.server.client.UserTaskServicesClient; +import org.openshift.quickstarts.processserver.timerprocess.Inputs; + +import java.io.UnsupportedEncodingException; +import java.net.MalformedURLException; +import java.net.URL; +import java.security.NoSuchAlgorithmException; +import java.util.HashMap; +import java.util.Map; +import java.util.logging.Logger; +import java.util.stream.Collectors; + +/** + * @author fspolti + */ +public class PersistentTimersTestBase extends KieServerTestBase { + + private final String TIMER_PROCESS_NAME = "timerprocess.QuartzTimerProcess"; + private final Logger log = Logger.getLogger(PersistentTimersTestBase.class.getName()); + + @ArquillianResource + private OpenShiftHandle adapter; + + @Override + protected URL getRouteURL() { + return null; + } + + /** + * Test if the containerID is correctly + * + * @throws Exception for any issue + */ + @Test + @RunAsClient + @InSequence(1) + public void checkContainerId() throws Exception { + checkKieServerContainer("timerProcess=org.openshift.quickstarts:processserver-timerprocess:1.3.0.Final"); + } + + /** + * Test the bpm process normal flow + * + * @throws MalformedURLException if the provided url is not valid + * @throws UnsupportedEncodingException if the encoding used is unsupported + * @throws NoSuchAlgorithmException if the algorithm used is not found + */ + @Test + @RunAsClient + @InSequence(2) + public void testTimerProcessNormalWorkFlow() throws UnsupportedEncodingException, NoSuchAlgorithmException, MalformedURLException { + // Start Process - PLUS operation + long processIdPlus = startProcess(containerId(), TIMER_PROCESS_NAME); + log.info("PLUS operation process ID: " + processIdPlus); + Assert.assertNotNull(processIdPlus); + log.info("Completing task ID: " + processIdPlus); + completeTask(containerId(), processIdPlus, 10, 20, Operation.PLUS); + int plusResult = Integer.parseInt(getVariable(processIdPlus).toString()); + log.info("Result PLUS operation: [ 10 + 20 = " + plusResult + "]"); + Assert.assertEquals(30, plusResult); + + // Start a process - MINUS operation + long processIdMinus = startProcess(containerId(), TIMER_PROCESS_NAME); + log.info("MINUS operation process ID: " + processIdMinus); + Assert.assertNotNull(processIdMinus); + log.info("Completing task ID: " + processIdMinus); + completeTask(containerId(), processIdMinus, 490, 332, Operation.MINUS); + int minusResult = Integer.parseInt(getVariable(processIdMinus).toString()); + log.info("Result MINUS operation: [ 490 - 332 = " + minusResult + "]"); + Assert.assertEquals(158, minusResult); + + // Start Process - TIMES operation + long processIdTimes = startProcess(containerId(), TIMER_PROCESS_NAME); + log.info("TIMES operation process ID: " + processIdTimes); + Assert.assertNotNull(processIdTimes); + log.info("Completing task ID: " + processIdTimes); + completeTask(containerId(), processIdTimes, 44, 671, Operation.TIMES); + int timesResult = Integer.parseInt(getVariable(processIdTimes).toString()); + log.info("Result TIMES operation: [ 44 * 671 = " + timesResult + "]"); + Assert.assertEquals(29524, timesResult); + + //Start Process - DIVIDE operation + long processIdDivide = startProcess(containerId(), TIMER_PROCESS_NAME); + log.info("DIVIDE operation process ID: " + processIdDivide); + Assert.assertNotNull(processIdDivide); + log.info("Completing task ID: " + processIdDivide); + completeTask(containerId(), processIdDivide, 1000, 50, Operation.DIVIDE); + int divideResult = Integer.parseInt(getVariable(processIdDivide).toString()); + log.info("Result DIVIDE operation: [ 1000 / 50 = " + divideResult + "]"); + Assert.assertEquals(20, divideResult); + } + + /** + * Start 2 processes + * + * @throws MalformedURLException if the provided url is not valid + * @throws UnsupportedEncodingException if the encoding used is unsupported + * @throws NoSuchAlgorithmException if the algorithm used is not found + */ + @Test + @RunAsClient + @InSequence(3) + public void startProcesses() throws UnsupportedEncodingException, NoSuchAlgorithmException, MalformedURLException { + startProcess(containerId(), TIMER_PROCESS_NAME); + log.info("PROCESS_ID_1 id: " + 5); + + startProcess(containerId(), TIMER_PROCESS_NAME); + log.info("PROCESS_ID_2 id: " + 6); + } + + /** + * Restart the pods + * + * @throws Exception for any issue + */ + @Test + @RunAsClient + @InSequence(4) + public void restartKieServer() throws Exception { + log.info("Scaling the pods down..."); + adapter.scaleDeployment("kie-app", 0); + if (this.getClass().toString().endsWith("ProcessServerPersistentTimersPostgreSqlTest")) { + adapter.scaleDeployment("kie-app-postgresql", 0); + } else { + adapter.scaleDeployment("kie-app-mysql", 0); + } + log.info("... Done"); + + log.info("Scaling the pods up..."); + if (this.getClass().toString().endsWith("ProcessServerPersistentTimersPostgreSqlTest")) { + adapter.scaleDeployment("kie-app-postgresql", 1); + } else { + adapter.scaleDeployment("kie-app-mysql", 1); + } + adapter.scaleDeployment("kie-app", 1); + log.info("... Done"); + } + + /** + * Test if the timers still active after a pod restart then complete the human task + * + * @throws MalformedURLException if the provided url is not valid + * @throws UnsupportedEncodingException if the encoding used is unsupported + * @throws NoSuchAlgorithmException if the algorithm used is not found + */ + @Test + @RunAsClient + @InSequence(5) + public void completeProcessAfterRestart() throws UnsupportedEncodingException, NoSuchAlgorithmException, MalformedURLException { + log.info("Completing task ID: " + 5); + completeTask(containerId(), 5, 40, 584, Operation.PLUS); + int process_id_1_result = Integer.parseInt(getVariable(5).toString()); + log.info("RESULT AFTER RESTART: " + process_id_1_result); + Assert.assertEquals(624, process_id_1_result); + + log.info("Completing task ID: " + 6); + completeTask(containerId(), 6, 584, 40, Operation.MINUS); + int process_id_2_result = Integer.parseInt(getVariable(6).toString()); + log.info("RESULT AFTER RESTART: " + process_id_2_result); + Assert.assertEquals(544, process_id_2_result); + } + + /** + * Start a process + * + * @param containerID String + * @param processName String + * @return long processID + * @throws MalformedURLException if the provided url is not valid + */ + private long startProcess(String containerID, String processName) throws MalformedURLException { + ProcessServicesClient processServicesClient = getKieServerProcessClient(ProcessServicesClient.class); + return processServicesClient.startProcess(containerID, processName); + } + + /** + * Complete a Human Task + * + * @param containerId String + * @param processId long + * @param number1 int + * @param number2 int + * @param operator Enum Operation + * @throws MalformedURLException if the provided url is not valid + * @throws UnsupportedEncodingException if the encoding used is unsupported + * @throws NoSuchAlgorithmException if the algorithm used is not found + */ + private void completeTask(String containerId, long processId, Integer number1, Integer number2, Enum operator) throws MalformedURLException, UnsupportedEncodingException, NoSuchAlgorithmException { + UserTaskServicesClient userTaskServicesClient = getKieServerProcessClient(UserTaskServicesClient.class); + userTaskServicesClient.startTask(containerId, processId, KIE_USERNAME); + userTaskServicesClient.completeTask(containerId, processId, KIE_USERNAME, parameters(number1, number2, operator)); + } + + /** + * Search for a process variable + * + * @param processId long + * @return Object result + * @throws MalformedURLException if the provided url is not valid + * @throws UnsupportedEncodingException if the encoding used is unsupported + * @throws NoSuchAlgorithmException if the algorithm used is not found + */ + private Object getVariable(long processId) throws MalformedURLException, UnsupportedEncodingException, NoSuchAlgorithmException { + QueryServicesClient queryClient = getKieServerProcessClient(QueryServicesClient.class); + return queryClient.findVariableHistory(processId, "result", 0, 1) + .stream() + .map(VariableInstance::getValue) + .collect(Collectors.joining()); + } + + /** + * In the KieServer 64 the containers are converted to a MD5 hash in the following patter: CONTAINER_ID=G:A:V + * + * @return convertKieContainerId + * @throws UnsupportedEncodingException if the encoding used is unsupported + * @throws NoSuchAlgorithmException if the algorithm used is not found + */ + private String containerId() throws UnsupportedEncodingException, NoSuchAlgorithmException { + return convertKieContainerId("timerProcess=org.openshift.quickstarts:processserver-timerprocess:1.3.0.Final"); + } + + /** + * Returns the needed parameters needed by the timerprocess.QuartzTimerProcess + * + * @param number1 Integer + * @param number2 Integer + * @param operator Enum Operation + * @return Map parameters + */ + private Map parameters(Integer number1, Integer number2, Enum operator) { + Inputs input = new Inputs(); + input.setNumber1(number1); + input.setNumber2(number2); + input.setOperator(String.valueOf(Operation.valueOf(operator.name()).operator)); + Map parameters = new HashMap<>(); + parameters.put("input", input); + return parameters; + } + + /** + * Returns the client based on the given class passed to this method + * + * @param clazz The needed Clients for this test are: + * ProcessServicesClient.class + * UserTaskServicesClient.class + * QueryServicesClient.class + * @throws MalformedURLException if the provided url is not valid + */ + private T getKieServerProcessClient(Class clazz) throws MalformedURLException { + return getKieRestServiceClient(getRouteURL()).getServicesClient(clazz); + } + + /** + * Valid math operations + */ + public enum Operation { + PLUS("+"), + MINUS("-"), + TIMES("*"), + DIVIDE("/"); + + private String operator; + + Operation(String operator) { + this.operator = operator; + } + + public String operator() { + return operator; + } + } +} diff --git a/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/ProcessServerAmqMySqlPersistentTest.java b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/ProcessServerAmqMySqlPersistentTest.java new file mode 100644 index 0000000..cb816e3 --- /dev/null +++ b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/ProcessServerAmqMySqlPersistentTest.java @@ -0,0 +1,55 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2015 Red Hat Inc. and/or its affiliates and other + * contributors as indicated by the @author tags. All rights reserved. + * See the copyright.txt in the distribution for a full listing of + * individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.test.arquillian.ce.processserver; + +import org.jboss.arquillian.ce.api.OpenShiftResource; +import org.jboss.arquillian.ce.api.OpenShiftResources; +import org.jboss.arquillian.ce.api.Template; +import org.jboss.arquillian.ce.api.TemplateParameter; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.runner.RunWith; + +/** + * @author Filippe Spolti + */ + +@RunWith(Arquillian.class) +@Template(url = "https://raw.githubusercontent.com/${template.repository:jboss-openshift}/application-templates/${template.branch:master}/processserver/processserver64-amq-mysql-persistent-s2i.json", parameters = { + @TemplateParameter(name = "KIE_SERVER_USER", value = "${kie.username:kieserver}"), + @TemplateParameter(name = "KIE_SERVER_PASSWORD", value = "${kie.password:Redhat@123}"), + @TemplateParameter(name = "MQ_USERNAME", value = "${mq.username:kieserver}"), + @TemplateParameter(name = "MQ_PASSWORD", value = "${mq.password:Redhat@123}") }) +@OpenShiftResources({@OpenShiftResource("https://raw.githubusercontent.com/${template.repository:jboss-openshift}/application-templates/${template.branch:master}/secrets/processserver-app-secret.json") }) +public class ProcessServerAmqMySqlPersistentTest extends LibraryProcessAmqTestBase { + + @Deployment + public static WebArchive getDeployment() throws Exception { + WebArchive war = LibraryProcessAmqTestBase.getDeployment(); + war.addClass(ProcessServerAmqMySqlPersistentTest.class); + return war; + } + +} diff --git a/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/ProcessServerAmqMySqlTest.java b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/ProcessServerAmqMySqlTest.java new file mode 100644 index 0000000..08ab8dd --- /dev/null +++ b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/ProcessServerAmqMySqlTest.java @@ -0,0 +1,55 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2015 Red Hat Inc. and/or its affiliates and other + * contributors as indicated by the @author tags. All rights reserved. + * See the copyright.txt in the distribution for a full listing of + * individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.test.arquillian.ce.processserver; + +import org.jboss.arquillian.ce.api.OpenShiftResource; +import org.jboss.arquillian.ce.api.OpenShiftResources; +import org.jboss.arquillian.ce.api.Template; +import org.jboss.arquillian.ce.api.TemplateParameter; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.runner.RunWith; + +/** + * @author Filippe Spolti + */ + +@RunWith(Arquillian.class) +@Template(url = "https://raw.githubusercontent.com/${template.repository:jboss-openshift}/application-templates/${template.branch:master}/processserver/processserver64-amq-mysql-s2i.json", parameters = { + @TemplateParameter(name = "KIE_SERVER_USER", value = "${kie.username:kieserver}"), + @TemplateParameter(name = "KIE_SERVER_PASSWORD", value = "${kie.password:Redhat@123}"), + @TemplateParameter(name = "MQ_USERNAME", value = "${mq.username:kieserver}"), + @TemplateParameter(name = "MQ_PASSWORD", value = "${mq.password:Redhat@123}") }) +@OpenShiftResources({@OpenShiftResource("https://raw.githubusercontent.com/${template.repository:jboss-openshift}/application-templates/${template.branch:master}/secrets/processserver-app-secret.json") }) +public class ProcessServerAmqMySqlTest extends LibraryProcessAmqTestBase { + + @Deployment + public static WebArchive getDeployment() throws Exception { + WebArchive war = LibraryProcessAmqTestBase.getDeployment(); + war.addClass(ProcessServerAmqMySqlTest.class); + return war; + } + +} diff --git a/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/ProcessServerAmqPostgresqlPersistentTest.java b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/ProcessServerAmqPostgresqlPersistentTest.java new file mode 100644 index 0000000..dd5044d --- /dev/null +++ b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/ProcessServerAmqPostgresqlPersistentTest.java @@ -0,0 +1,55 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2015 Red Hat Inc. and/or its affiliates and other + * contributors as indicated by the @author tags. All rights reserved. + * See the copyright.txt in the distribution for a full listing of + * individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.test.arquillian.ce.processserver; + +import org.jboss.arquillian.ce.api.OpenShiftResource; +import org.jboss.arquillian.ce.api.OpenShiftResources; +import org.jboss.arquillian.ce.api.Template; +import org.jboss.arquillian.ce.api.TemplateParameter; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.runner.RunWith; + +/** + * @author Filippe Spolti + */ + +@RunWith(Arquillian.class) +@Template(url = "https://raw.githubusercontent.com/${template.repository:jboss-openshift}/application-templates/${template.branch:master}/processserver/processserver64-amq-postgresql-persistent-s2i.json", parameters = { + @TemplateParameter(name = "KIE_SERVER_USER", value = "${kie.username:kieserver}"), + @TemplateParameter(name = "KIE_SERVER_PASSWORD", value = "${kie.password:Redhat@123}"), + @TemplateParameter(name = "MQ_USERNAME", value = "${mq.username:kieserver}"), + @TemplateParameter(name = "MQ_PASSWORD", value = "${mq.password:Redhat@123}") }) +@OpenShiftResources({@OpenShiftResource("https://raw.githubusercontent.com/${template.repository:jboss-openshift}/application-templates/${template.branch:master}/secrets/processserver-app-secret.json") }) +public class ProcessServerAmqPostgresqlPersistentTest extends LibraryProcessAmqTestBase { + + @Deployment + public static WebArchive getDeployment() throws Exception { + WebArchive war = LibraryProcessAmqTestBase.getDeployment(); + war.addClass(ProcessServerAmqPostgresqlPersistentTest.class); + return war; + } + +} diff --git a/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/ProcessServerAmqPostgresqlTest.java b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/ProcessServerAmqPostgresqlTest.java new file mode 100644 index 0000000..7b937db --- /dev/null +++ b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/ProcessServerAmqPostgresqlTest.java @@ -0,0 +1,55 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2015 Red Hat Inc. and/or its affiliates and other + * contributors as indicated by the @author tags. All rights reserved. + * See the copyright.txt in the distribution for a full listing of + * individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.test.arquillian.ce.processserver; + +import org.jboss.arquillian.ce.api.OpenShiftResource; +import org.jboss.arquillian.ce.api.OpenShiftResources; +import org.jboss.arquillian.ce.api.Template; +import org.jboss.arquillian.ce.api.TemplateParameter; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.runner.RunWith; + +/** + * @author Filippe Spolti + */ + +@RunWith(Arquillian.class) +@Template(url = "https://raw.githubusercontent.com/${template.repository:jboss-openshift}/application-templates/${template.branch:master}/processserver/processserver64-amq-postgresql-s2i.json", parameters = { + @TemplateParameter(name = "KIE_SERVER_USER", value = "${kie.username:kieserver}"), + @TemplateParameter(name = "KIE_SERVER_PASSWORD", value = "${kie.password:Redhat@123}"), + @TemplateParameter(name = "MQ_USERNAME", value = "${mq.username:kieserver}"), + @TemplateParameter(name = "MQ_PASSWORD", value = "${mq.password:Redhat@123}") }) +@OpenShiftResources({@OpenShiftResource("https://raw.githubusercontent.com/${template.repository:jboss-openshift}/application-templates/${template.branch:master}/secrets/processserver-app-secret.json") }) +public class ProcessServerAmqPostgresqlTest extends LibraryProcessAmqTestBase { + + @Deployment + public static WebArchive getDeployment() throws Exception { + WebArchive war = LibraryProcessAmqTestBase.getDeployment(); + war.addClass(ProcessServerAmqPostgresqlTest.class); + return war; + } + +} diff --git a/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/ProcessServerBasicTest.java b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/ProcessServerBasicTest.java new file mode 100644 index 0000000..721d2b9 --- /dev/null +++ b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/ProcessServerBasicTest.java @@ -0,0 +1,80 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2015 Red Hat Inc. and/or its affiliates and other + * contributors as indicated by the @author tags. All rights reserved. + * See the copyright.txt in the distribution for a full listing of + * individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.test.arquillian.ce.processserver; + +import java.net.URL; + +import org.jboss.arquillian.ce.api.OpenShiftResource; +import org.jboss.arquillian.ce.api.OpenShiftResources; +import org.jboss.arquillian.ce.api.Template; +import org.jboss.arquillian.ce.api.TemplateParameter; +import org.jboss.arquillian.ce.cube.RouteURL; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.container.test.api.RunAsClient; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + +/** + * @author Filippe Spolti + */ + +@RunWith(Arquillian.class) +@Template(url = "https://raw.githubusercontent.com/${template.repository:jboss-openshift}/application-templates/${template.branch:master}/processserver/processserver64-basic-s2i.json", + parameters = { + @TemplateParameter(name = "KIE_SERVER_USER", value = "${kie.username:kieserver}"), + @TemplateParameter(name = "KIE_SERVER_PASSWORD", value = "${kie.password:Redhat@123}") + } +) +@OpenShiftResources({ + @OpenShiftResource("https://raw.githubusercontent.com/${template.repository:jboss-openshift}/application-templates/${template.branch:master}/secrets/processserver-app-secret.json") +}) +public class ProcessServerBasicTest extends LibraryProcessTestBase { + + @RouteURL("kie-app") + private URL routeURL; + + @Override + protected URL getRouteURL() { + return routeURL; + } + + @Deployment + public static WebArchive deployment() throws Exception { + return getDeployment(); + } + + @Test + @RunAsClient + public void testProcessServerCapabilities() throws Exception { + checkKieServerCapabilities(getRouteURL(), "BPM"); + } + + @Test + @RunAsClient + public void testProcessServerContainer() throws Exception { + checkKieServerContainer("processserver-library=org.openshift.quickstarts:processserver-library:1.3.0.Final"); + } +} diff --git a/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/ProcessServerMySqlPersistentTest.java b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/ProcessServerMySqlPersistentTest.java new file mode 100644 index 0000000..b5b23e6 --- /dev/null +++ b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/ProcessServerMySqlPersistentTest.java @@ -0,0 +1,85 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2015 Red Hat Inc. and/or its affiliates and other + * contributors as indicated by the @author tags. All rights reserved. + * See the copyright.txt in the distribution for a full listing of + * individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.test.arquillian.ce.processserver; + +import java.net.URL; + +import org.jboss.arquillian.ce.api.OpenShiftResource; +import org.jboss.arquillian.ce.api.OpenShiftResources; +import org.jboss.arquillian.ce.api.Template; +import org.jboss.arquillian.ce.api.TemplateParameter; +import org.jboss.arquillian.ce.cube.RouteURL; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.container.test.api.RunAsClient; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + +/** + * @author Filippe Spolti + */ + +@RunWith(Arquillian.class) +@Template(url = "https://raw.githubusercontent.com/${template.repository:jboss-openshift}/application-templates/${template.branch:master}/processserver/processserver64-mysql-persistent-s2i.json", + parameters = { + @TemplateParameter(name = "KIE_SERVER_USER", value = "${kie.username:kieserver}"), + @TemplateParameter(name = "KIE_SERVER_PASSWORD", value = "${kie.password:Redhat@123}") + } +) +@OpenShiftResources({ + @OpenShiftResource("https://raw.githubusercontent.com/${template.repository:jboss-openshift}/application-templates/${template.branch:master}/secrets/processserver-app-secret.json") +}) +public class ProcessServerMySqlPersistentTest extends LibraryProcessTestBase { + + @Deployment + public static WebArchive getDeployment() throws Exception { + WebArchive war = getDeploymentInternal(); + war.addPackage("org.openshift.quickstarts.processserver.library.types"); + war.addClass(LibraryClient.class); + war.addClass(LibraryProcessTestBase.class); + return war; + } + + @RouteURL("kie-app") + private URL routeURL; + + @Override + protected URL getRouteURL() { + return routeURL; + } + + @Test + @RunAsClient + public void testProcessServerCapabilities() throws Exception { + checkKieServerCapabilities(getRouteURL(), "BPM"); + } + + @Test + @RunAsClient + public void testProcessServerContainer() throws Exception { + checkKieServerContainer("processserver-library=org.openshift.quickstarts:processserver-library:1.3.0.Final"); + } + +} diff --git a/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/ProcessServerMySqlTest.java b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/ProcessServerMySqlTest.java new file mode 100644 index 0000000..adf4bfa --- /dev/null +++ b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/ProcessServerMySqlTest.java @@ -0,0 +1,85 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2015 Red Hat Inc. and/or its affiliates and other + * contributors as indicated by the @author tags. All rights reserved. + * See the copyright.txt in the distribution for a full listing of + * individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.test.arquillian.ce.processserver; + +import java.net.URL; + +import org.jboss.arquillian.ce.api.OpenShiftResource; +import org.jboss.arquillian.ce.api.OpenShiftResources; +import org.jboss.arquillian.ce.api.Template; +import org.jboss.arquillian.ce.api.TemplateParameter; +import org.jboss.arquillian.ce.cube.RouteURL; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.container.test.api.RunAsClient; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + +/** + * @author Filippe Spolti + */ + +@RunWith(Arquillian.class) +@Template(url = "https://raw.githubusercontent.com/${template.repository:jboss-openshift}/application-templates/${template.branch:master}/processserver/processserver64-mysql-s2i.json", + parameters = { + @TemplateParameter(name = "KIE_SERVER_USER", value = "${kie.username:kieserver}"), + @TemplateParameter(name = "KIE_SERVER_PASSWORD", value = "${kie.password:Redhat@123}") + } +) +@OpenShiftResources({ + @OpenShiftResource("https://raw.githubusercontent.com/${template.repository:jboss-openshift}/application-templates/${template.branch:master}/secrets/processserver-app-secret.json") +}) +public class ProcessServerMySqlTest extends LibraryProcessTestBase { + + @Deployment + public static WebArchive getDeployment() throws Exception { + WebArchive war = getDeploymentInternal(); + war.addPackage("org.openshift.quickstarts.processserver.library.types"); + war.addClass(LibraryClient.class); + war.addClass(LibraryProcessTestBase.class); + return war; + } + + @RouteURL("kie-app") + private URL routeURL; + + @Override + protected URL getRouteURL() { + return routeURL; + } + + @Test + @RunAsClient + public void testProcessServerCapabilities() throws Exception { + checkKieServerCapabilities(getRouteURL(), "BPM"); + } + + @Test + @RunAsClient + public void testProcessServerContainer() throws Exception { + checkKieServerContainer("processserver-library=org.openshift.quickstarts:processserver-library:1.3.0.Final"); + } + +} diff --git a/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/ProcessServerPersistentTimersMySqlTest.java b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/ProcessServerPersistentTimersMySqlTest.java new file mode 100644 index 0000000..d2248ca --- /dev/null +++ b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/ProcessServerPersistentTimersMySqlTest.java @@ -0,0 +1,61 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2015 Red Hat Inc. and/or its affiliates and other + * contributors as indicated by the @author tags. All rights reserved. + * See the copyright.txt in the distribution for a full listing of + * individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.test.arquillian.ce.processserver; + +import org.jboss.arquillian.ce.api.OpenShiftResource; +import org.jboss.arquillian.ce.api.OpenShiftResources; +import org.jboss.arquillian.ce.api.Template; +import org.jboss.arquillian.ce.api.TemplateParameter; +import org.jboss.arquillian.ce.cube.RouteURL; +import org.jboss.arquillian.junit.Arquillian; +import org.junit.runner.RunWith; + +import java.net.URL; + +/** + * @author fspolti + */ +@RunWith(Arquillian.class) +@Template(url = "https://raw.githubusercontent.com/${template.repository:jboss-openshift}/application-templates/${template.branch:master}/processserver/processserver64-mysql-persistent-s2i.json", + parameters = { + @TemplateParameter(name = "KIE_SERVER_USER", value = "${kie.username:kieserver}"), + @TemplateParameter(name = "KIE_SERVER_PASSWORD", value = "${kie.password:Redhat@123}"), + @TemplateParameter(name = "CONTEXT_DIR", value = "processserver/timerprocess"), + @TemplateParameter(name = "KIE_CONTAINER_DEPLOYMENT", value = "timerProcess=org.openshift.quickstarts:processserver-timerprocess:1.3.0.Final") + } +) +@OpenShiftResources({ + @OpenShiftResource("https://raw.githubusercontent.com/${template.repository:jboss-openshift}/application-templates/${template.branch:master}/secrets/processserver-app-secret.json") +}) +public class ProcessServerPersistentTimersMySqlTest extends PersistentTimersTestBase { + + @RouteURL("kie-app") + private URL routeURL; + + @Override + protected URL getRouteURL() { + return routeURL; + } + +} diff --git a/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/ProcessServerPersistentTimersPostgreSqlTest.java b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/ProcessServerPersistentTimersPostgreSqlTest.java new file mode 100644 index 0000000..c85bceb --- /dev/null +++ b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/ProcessServerPersistentTimersPostgreSqlTest.java @@ -0,0 +1,63 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2015 Red Hat Inc. and/or its affiliates and other + * contributors as indicated by the @author tags. All rights reserved. + * See the copyright.txt in the distribution for a full listing of + * individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.test.arquillian.ce.processserver; + +import org.jboss.arquillian.ce.api.OpenShiftResource; +import org.jboss.arquillian.ce.api.OpenShiftResources; +import org.jboss.arquillian.ce.api.Template; +import org.jboss.arquillian.ce.api.TemplateParameter; +import org.jboss.arquillian.ce.cube.RouteURL; +import org.jboss.arquillian.container.test.api.RunAsClient; +import org.jboss.arquillian.junit.Arquillian; +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.net.URL; + +/** + * Created by fspolti on 1/16/17. + */ +@RunWith(Arquillian.class) +@Template(url = "https://raw.githubusercontent.com/${template.repository:jboss-openshift}/application-templates/${template.branch:master}/processserver/processserver64-postgresql-persistent-s2i.json", + parameters = { + @TemplateParameter(name = "KIE_SERVER_USER", value = "${kie.username:kieserver}"), + @TemplateParameter(name = "KIE_SERVER_PASSWORD", value = "${kie.password:Redhat@123}"), + @TemplateParameter(name = "CONTEXT_DIR", value = "processserver/timerprocess"), + @TemplateParameter(name = "KIE_CONTAINER_DEPLOYMENT", value = "timerProcess=org.openshift.quickstarts:processserver-timerprocess:1.3.0.Final") + } +) +@OpenShiftResources({ + @OpenShiftResource("https://raw.githubusercontent.com/${template.repository:jboss-openshift}/application-templates/${template.branch:master}/secrets/processserver-app-secret.json") +}) +public class ProcessServerPersistentTimersPostgreSqlTest extends PersistentTimersTestBase { + + @RouteURL("kie-app") + private URL routeURL; + + @Override + protected URL getRouteURL() { + return routeURL; + } + +} diff --git a/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/ProcessServerPostgreSqlPersistentTest.java b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/ProcessServerPostgreSqlPersistentTest.java new file mode 100644 index 0000000..1cf658a --- /dev/null +++ b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/ProcessServerPostgreSqlPersistentTest.java @@ -0,0 +1,84 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2015 Red Hat Inc. and/or its affiliates and other + * contributors as indicated by the @author tags. All rights reserved. + * See the copyright.txt in the distribution for a full listing of + * individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.test.arquillian.ce.processserver; + +import java.net.URL; + +import org.jboss.arquillian.ce.api.OpenShiftResource; +import org.jboss.arquillian.ce.api.OpenShiftResources; +import org.jboss.arquillian.ce.api.Template; +import org.jboss.arquillian.ce.api.TemplateParameter; +import org.jboss.arquillian.ce.cube.RouteURL; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.container.test.api.RunAsClient; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + +/** + * @author Filippe Spolti + */ + +@RunWith(Arquillian.class) +@Template(url = "https://raw.githubusercontent.com/${template.repository:jboss-openshift}/application-templates/${template.branch:master}/processserver/processserver64-postgresql-persistent-s2i.json", + parameters = { + @TemplateParameter(name = "KIE_SERVER_USER", value = "${kie.username:kieserver}"), + @TemplateParameter(name = "KIE_SERVER_PASSWORD", value = "${kie.password:Redhat@123}") + } +) +@OpenShiftResources({ + @OpenShiftResource("https://raw.githubusercontent.com/${template.repository:jboss-openshift}/application-templates/${template.branch:master}/secrets/processserver-app-secret.json") +}) +public class ProcessServerPostgreSqlPersistentTest extends LibraryProcessTestBase { + + @Deployment + public static WebArchive getDeployment() throws Exception { + WebArchive war = getDeploymentInternal(); + war.addPackage("org.openshift.quickstarts.processserver.library.types"); + war.addClass(LibraryClient.class); + war.addClass(LibraryProcessTestBase.class); + return war; + } + + @RouteURL("kie-app") + private URL routeURL; + + @Override + protected URL getRouteURL() { + return routeURL; + } + + @Test + @RunAsClient + public void testProcessServerCapabilities() throws Exception { + checkKieServerCapabilities(getRouteURL(), "BPM"); + } + + @Test + @RunAsClient + public void testProcessServerContainer() throws Exception { + checkKieServerContainer("processserver-library=org.openshift.quickstarts:processserver-library:1.3.0.Final"); + } +} diff --git a/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/ProcessServerPostgreSqlTest.java b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/ProcessServerPostgreSqlTest.java new file mode 100644 index 0000000..d1eb89b --- /dev/null +++ b/kieserver/64/src/test/java/org/jboss/test/arquillian/ce/processserver/ProcessServerPostgreSqlTest.java @@ -0,0 +1,84 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2015 Red Hat Inc. and/or its affiliates and other + * contributors as indicated by the @author tags. All rights reserved. + * See the copyright.txt in the distribution for a full listing of + * individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.test.arquillian.ce.processserver; + +import java.net.URL; + +import org.jboss.arquillian.ce.api.OpenShiftResource; +import org.jboss.arquillian.ce.api.OpenShiftResources; +import org.jboss.arquillian.ce.api.Template; +import org.jboss.arquillian.ce.api.TemplateParameter; +import org.jboss.arquillian.ce.cube.RouteURL; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.container.test.api.RunAsClient; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + +/** + * @author Filippe Spolti + */ + +@RunWith(Arquillian.class) +@Template(url = "https://raw.githubusercontent.com/${template.repository:jboss-openshift}/application-templates/${template.branch:master}/processserver/processserver64-postgresql-s2i.json", + parameters = { + @TemplateParameter(name = "KIE_SERVER_USER", value = "${kie.username:kieserver}"), + @TemplateParameter(name = "KIE_SERVER_PASSWORD", value = "${kie.password:Redhat@123}") + } +) +@OpenShiftResources({ + @OpenShiftResource("https://raw.githubusercontent.com/${template.repository:jboss-openshift}/application-templates/${template.branch:master}/secrets/processserver-app-secret.json") +}) +public class ProcessServerPostgreSqlTest extends LibraryProcessTestBase { + + @Deployment + public static WebArchive getDeployment() throws Exception { + WebArchive war = getDeploymentInternal(); + war.addPackage("org.openshift.quickstarts.processserver.library.types"); + war.addClass(LibraryClient.class); + war.addClass(LibraryProcessTestBase.class); + return war; + } + + @RouteURL("kie-app") + private URL routeURL; + + @Override + protected URL getRouteURL() { + return routeURL; + } + + @Test + @RunAsClient + public void testProcessServerCapabilities() throws Exception { + checkKieServerCapabilities(getRouteURL(), "BPM"); + } + + @Test + @RunAsClient + public void testProcessServerContainer() throws Exception { + checkKieServerContainer("processserver-library=org.openshift.quickstarts:processserver-library:1.3.0.Final"); + } +} diff --git a/kieserver/64/src/test/java/org/openshift/quickstarts/decisionserver/hellorules/Greeting.java b/kieserver/64/src/test/java/org/openshift/quickstarts/decisionserver/hellorules/Greeting.java new file mode 100644 index 0000000..7040b6b --- /dev/null +++ b/kieserver/64/src/test/java/org/openshift/quickstarts/decisionserver/hellorules/Greeting.java @@ -0,0 +1,47 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2015 Red Hat Inc. and/or its affiliates and other + * contributors as indicated by the @author tags. All rights reserved. + * See the copyright.txt in the distribution for a full listing of + * individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.openshift.quickstarts.decisionserver.hellorules; + +/** + * Copied from OpenShift-quickstarts. + */ +public class Greeting { + + private String salutation; + + public Greeting() {} + + public Greeting(String salutation) { + setSalutation(salutation); + } + + public String getSalutation() { + return salutation; + } + + public void setSalutation(String salutation) { + this.salutation = salutation; + } + +} diff --git a/kieserver/64/src/test/java/org/openshift/quickstarts/decisionserver/hellorules/Person.java b/kieserver/64/src/test/java/org/openshift/quickstarts/decisionserver/hellorules/Person.java new file mode 100644 index 0000000..f065ba4 --- /dev/null +++ b/kieserver/64/src/test/java/org/openshift/quickstarts/decisionserver/hellorules/Person.java @@ -0,0 +1,47 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2015 Red Hat Inc. and/or its affiliates and other + * contributors as indicated by the @author tags. All rights reserved. + * See the copyright.txt in the distribution for a full listing of + * individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.openshift.quickstarts.decisionserver.hellorules; + +/** + * Copied from OpenShift-quickstarts. + */ +public class Person { + + private String name; + + public Person() {} + + public Person(String name) { + setName(name); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + +} diff --git a/kieserver/64/src/test/java/org/openshift/quickstarts/processserver/library/types/Book.java b/kieserver/64/src/test/java/org/openshift/quickstarts/processserver/library/types/Book.java new file mode 100644 index 0000000..4d9d826 --- /dev/null +++ b/kieserver/64/src/test/java/org/openshift/quickstarts/processserver/library/types/Book.java @@ -0,0 +1,159 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.5 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2014.09.04 at 12:38:20 PM EDT +// + + +package org.openshift.quickstarts.processserver.library.types; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for book complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="book">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="id" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="isbn" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="title" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="synopsis" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="available" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@SuppressWarnings("serial") +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "book", namespace = "urn:openshift-quickstarts:processserver-library:1.3", propOrder = { + "id", + "isbn", + "title", + "synopsis", + "available" +}) +@Entity +@Table(name="book") +public class Book implements Serializable { + + @Id + @Column(name="book_id") + @GeneratedValue + protected long id; + @Column + protected String isbn; + @Column + protected String title; + @Column + protected String synopsis; + @Column + protected boolean available; + + public Book() {} + + public Book(String isbn, String title, String synopsis) { + setIsbn(isbn); + setTitle(title); + setSynopsis(synopsis); + setAvailable(true); + } + + /** + * Gets the value of the id property. + */ + public long getId() { + return id; + } + + /** + * Sets the value of the id property. + */ + public void setId(long value) { + this.id = value; + } + + /** + * Gets the value of the isbn property. + */ + public String getIsbn() { + return isbn; + } + + /** + * Sets the value of the isbn property. + */ + public void setIsbn(String value) { + this.isbn = value; + } + + /** + * Gets the value of the title property. + */ + public String getTitle() { + return title; + } + + /** + * Sets the value of the title property. + */ + public void setTitle(String value) { + this.title = value; + } + + /** + * Gets the value of the synopsis property. + */ + public String getSynopsis() { + return synopsis; + } + + /** + * Sets the value of the synopsis property. + */ + public void setSynopsis(String value) { + this.synopsis = value; + } + + /** + * Gets the value of the available property. + * + */ + public boolean isAvailable() { + return available; + } + + /** + * Sets the value of the available property. + * + */ + public void setAvailable(boolean value) { + this.available = value; + } + + @Override + public String toString() { + return "Book [id=" + id + ", isbn=" + isbn + ", title=" + title + ", synopsis=" + synopsis + ", available=" + + available + "]"; + } + +} diff --git a/kieserver/64/src/test/java/org/openshift/quickstarts/processserver/library/types/Loan.java b/kieserver/64/src/test/java/org/openshift/quickstarts/processserver/library/types/Loan.java new file mode 100644 index 0000000..9c11624 --- /dev/null +++ b/kieserver/64/src/test/java/org/openshift/quickstarts/processserver/library/types/Loan.java @@ -0,0 +1,140 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.5 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2014.09.04 at 12:38:20 PM EDT +// + + +package org.openshift.quickstarts.processserver.library.types; + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for loan complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="loan">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="id" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="approved" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
+ *         <element name="notes" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element ref="{urn:openshift-quickstarts:processserver-library:1.3}book" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@SuppressWarnings("serial") +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "loan", namespace = "urn:openshift-quickstarts:processserver-library:1.3", propOrder = { + "id", + "approved", + "notes", + "book" +}) +public class Loan implements Serializable { + + protected long id; + protected boolean approved; + protected String notes; + @XmlElement(namespace = "urn:openshift-quickstarts:processserver-library:1.3") + protected Book book; + + /** + * Gets the value of the id property. + */ + public long getId() { + return id; + } + + /** + * Sets the value of the id property. + */ + public void setId(long value) { + this.id = value; + } + + /** + * Gets the value of the approved property. + * + */ + public boolean isApproved() { + return approved; + } + + /** + * Sets the value of the approved property. + * + */ + public void setApproved(boolean value) { + this.approved = value; + } + + /** + * Gets the value of the notes property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getNotes() { + return notes; + } + + /** + * Sets the value of the notes property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setNotes(String value) { + this.notes = value; + } + + /** + * Gets the value of the book property. + * + * @return + * possible object is + * {@link Book } + * + */ + public Book getBook() { + return book; + } + + /** + * Sets the value of the book property. + * + * @param value + * allowed object is + * {@link Book } + * + */ + public void setBook(Book value) { + this.book = value; + } + + @Override + public String toString() { + return "Loan [id=" + id + ", approved=" + approved + ", notes=" + notes + ", book=" + book + "]"; + } + +} diff --git a/kieserver/64/src/test/java/org/openshift/quickstarts/processserver/library/types/LoanRequest.java b/kieserver/64/src/test/java/org/openshift/quickstarts/processserver/library/types/LoanRequest.java new file mode 100644 index 0000000..e77955e --- /dev/null +++ b/kieserver/64/src/test/java/org/openshift/quickstarts/processserver/library/types/LoanRequest.java @@ -0,0 +1,79 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.5 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2014.09.04 at 12:38:20 PM EDT +// + + +package org.openshift.quickstarts.processserver.library.types; + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="isbn" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@SuppressWarnings("serial") +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "loanRequest", namespace = "urn:openshift-quickstarts:processserver-library:1.3", propOrder = { + "isbn" +}) +@XmlRootElement(name = "loanRequest", namespace = "urn:openshift-quickstarts:processserver-library:1.3") +public class LoanRequest implements Serializable { + + @XmlElement(required = true) + protected String isbn; + + /** + * Gets the value of the isbn property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getIsbn() { + return isbn; + } + + /** + * Sets the value of the isbn property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setIsbn(String value) { + this.isbn = value; + } + + @Override + public String toString() { + return "LoanRequest [isbn=" + isbn + "]"; + } + +} diff --git a/kieserver/64/src/test/java/org/openshift/quickstarts/processserver/library/types/LoanResponse.java b/kieserver/64/src/test/java/org/openshift/quickstarts/processserver/library/types/LoanResponse.java new file mode 100644 index 0000000..5724f42 --- /dev/null +++ b/kieserver/64/src/test/java/org/openshift/quickstarts/processserver/library/types/LoanResponse.java @@ -0,0 +1,79 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.5 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2014.09.04 at 12:38:20 PM EDT +// + + +package org.openshift.quickstarts.processserver.library.types; + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element ref="{urn:openshift-quickstarts:processserver-library:1.3}loan"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@SuppressWarnings("serial") +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "loanResponse", namespace = "urn:openshift-quickstarts:processserver-library:1.3", propOrder = { + "loan" +}) +@XmlRootElement(name = "loanResponse", namespace = "urn:openshift-quickstarts:processserver-library:1.3") +public class LoanResponse implements Serializable { + + @XmlElement(namespace = "urn:openshift-quickstarts:processserver-library:1.3", required = true) + protected Loan loan; + + /** + * Gets the value of the loan property. + * + * @return + * possible object is + * {@link Loan } + * + */ + public Loan getLoan() { + return loan; + } + + /** + * Sets the value of the loan property. + * + * @param value + * allowed object is + * {@link Loan } + * + */ + public void setLoan(Loan value) { + this.loan = value; + } + + @Override + public String toString() { + return "LoanResponse [loan=" + loan + "]"; + } + +} diff --git a/kieserver/64/src/test/java/org/openshift/quickstarts/processserver/library/types/ReturnRequest.java b/kieserver/64/src/test/java/org/openshift/quickstarts/processserver/library/types/ReturnRequest.java new file mode 100644 index 0000000..8c2db72 --- /dev/null +++ b/kieserver/64/src/test/java/org/openshift/quickstarts/processserver/library/types/ReturnRequest.java @@ -0,0 +1,79 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.5 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2014.09.04 at 12:38:20 PM EDT +// + + +package org.openshift.quickstarts.processserver.library.types; + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element ref="{urn:openshift-quickstarts:processserver-library:1.3}loan"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@SuppressWarnings("serial") +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "returnRequest", namespace = "urn:openshift-quickstarts:processserver-library:1.3", propOrder = { + "loan" +}) +@XmlRootElement(name = "returnRequest", namespace = "urn:openshift-quickstarts:processserver-library:1.3") +public class ReturnRequest implements Serializable { + + @XmlElement(namespace = "urn:openshift-quickstarts:processserver-library:1.3", required = true) + protected Loan loan; + + /** + * Gets the value of the loan property. + * + * @return + * possible object is + * {@link Loan } + * + */ + public Loan getLoan() { + return loan; + } + + /** + * Sets the value of the loan property. + * + * @param value + * allowed object is + * {@link Loan } + * + */ + public void setLoan(Loan value) { + this.loan = value; + } + + @Override + public String toString() { + return "ReturnRequest [loan=" + loan + "]"; + } + +} diff --git a/kieserver/64/src/test/java/org/openshift/quickstarts/processserver/library/types/ReturnResponse.java b/kieserver/64/src/test/java/org/openshift/quickstarts/processserver/library/types/ReturnResponse.java new file mode 100644 index 0000000..097e6ef --- /dev/null +++ b/kieserver/64/src/test/java/org/openshift/quickstarts/processserver/library/types/ReturnResponse.java @@ -0,0 +1,69 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.5 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2014.09.04 at 12:38:20 PM EDT +// + + +package org.openshift.quickstarts.processserver.library.types; + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="acknowledged" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@SuppressWarnings("serial") +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "returnResponse", namespace = "urn:openshift-quickstarts:processserver-library:1.3", propOrder = { + "acknowledged" +}) +@XmlRootElement(name = "returnResponse", namespace = "urn:openshift-quickstarts:processserver-library:1.3") +public class ReturnResponse implements Serializable { + + protected boolean acknowledged; + + /** + * Gets the value of the acknowledged property. + * + */ + public boolean isAcknowledged() { + return acknowledged; + } + + /** + * Sets the value of the acknowledged property. + * + */ + public void setAcknowledged(boolean value) { + this.acknowledged = value; + } + + @Override + public String toString() { + return "ReturnResponse [acknowledged=" + acknowledged + "]"; + } + +} diff --git a/kieserver/64/src/test/java/org/openshift/quickstarts/processserver/library/types/Suggestion.java b/kieserver/64/src/test/java/org/openshift/quickstarts/processserver/library/types/Suggestion.java new file mode 100644 index 0000000..346be39 --- /dev/null +++ b/kieserver/64/src/test/java/org/openshift/quickstarts/processserver/library/types/Suggestion.java @@ -0,0 +1,77 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.5 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2014.09.04 at 12:38:20 PM EDT +// + + +package org.openshift.quickstarts.processserver.library.types; + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for suggestion complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="suggestion">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element ref="{urn:openshift-quickstarts:processserver-library:1.3}book" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@SuppressWarnings("serial") +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "suggestion", namespace = "urn:openshift-quickstarts:processserver-library:1.3", propOrder = { + "book" +}) +public class Suggestion implements Serializable { + + @XmlElement(namespace = "urn:openshift-quickstarts:processserver-library:1.3") + protected Book book; + + /** + * Gets the value of the book property. + * + * @return + * possible object is + * {@link Book } + * + */ + public Book getBook() { + return book; + } + + /** + * Sets the value of the book property. + * + * @param value + * allowed object is + * {@link Book } + * + */ + public void setBook(Book value) { + this.book = value; + } + + @Override + public String toString() { + return "Suggestion [book=" + book + "]"; + } + +} diff --git a/kieserver/64/src/test/java/org/openshift/quickstarts/processserver/library/types/SuggestionRequest.java b/kieserver/64/src/test/java/org/openshift/quickstarts/processserver/library/types/SuggestionRequest.java new file mode 100644 index 0000000..a263099 --- /dev/null +++ b/kieserver/64/src/test/java/org/openshift/quickstarts/processserver/library/types/SuggestionRequest.java @@ -0,0 +1,79 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.5 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2014.09.04 at 12:38:20 PM EDT +// + + +package org.openshift.quickstarts.processserver.library.types; + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="keyword" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@SuppressWarnings("serial") +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "suggestionRequest", namespace = "urn:openshift-quickstarts:processserver-library:1.3", propOrder = { + "keyword" +}) +@XmlRootElement(name = "suggestionRequest", namespace = "urn:openshift-quickstarts:processserver-library:1.3") +public class SuggestionRequest implements Serializable { + + @XmlElement(required = true) + protected String keyword; + + /** + * Gets the value of the keyword property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getKeyword() { + return keyword; + } + + /** + * Sets the value of the keyword property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setKeyword(String value) { + this.keyword = value; + } + + @Override + public String toString() { + return "SuggestionRequest [keyword=" + keyword + "]"; + } + +} diff --git a/kieserver/64/src/test/java/org/openshift/quickstarts/processserver/library/types/SuggestionResponse.java b/kieserver/64/src/test/java/org/openshift/quickstarts/processserver/library/types/SuggestionResponse.java new file mode 100644 index 0000000..df3658b --- /dev/null +++ b/kieserver/64/src/test/java/org/openshift/quickstarts/processserver/library/types/SuggestionResponse.java @@ -0,0 +1,79 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.5 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2014.09.04 at 12:38:20 PM EDT +// + + +package org.openshift.quickstarts.processserver.library.types; + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element ref="{urn:openshift-quickstarts:processserver-library:1.3}suggestion" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@SuppressWarnings("serial") +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "suggestionResponse", namespace = "urn:openshift-quickstarts:processserver-library:1.3", propOrder = { + "suggestion" +}) +@XmlRootElement(name = "suggestionResponse", namespace = "urn:openshift-quickstarts:processserver-library:1.3") +public class SuggestionResponse implements Serializable { + + @XmlElement(namespace = "urn:openshift-quickstarts:processserver-library:1.3") + protected Suggestion suggestion; + + /** + * Gets the value of the suggestion property. + * + * @return + * possible object is + * {@link Suggestion } + * + */ + public Suggestion getSuggestion() { + return suggestion; + } + + /** + * Sets the value of the suggestion property. + * + * @param value + * allowed object is + * {@link Suggestion } + * + */ + public void setSuggestion(Suggestion value) { + this.suggestion = value; + } + + @Override + public String toString() { + return "SuggestionResponse [suggestion=" + suggestion + "]"; + } + +} diff --git a/kieserver/64/src/test/java/org/openshift/quickstarts/processserver/timerprocess/Inputs.java b/kieserver/64/src/test/java/org/openshift/quickstarts/processserver/timerprocess/Inputs.java new file mode 100644 index 0000000..6787d77 --- /dev/null +++ b/kieserver/64/src/test/java/org/openshift/quickstarts/processserver/timerprocess/Inputs.java @@ -0,0 +1,69 @@ +package org.openshift.quickstarts.processserver.timerprocess; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; +import java.io.Serializable; + +/** + * Created by fspolti on 1/18/17. + */ +@SuppressWarnings("serial") +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "inputs", propOrder = {"number1", "number2", "operator"}) +@XmlRootElement(name = "inputs") +public class Inputs implements Serializable { + + private Integer number1; + private Integer number2; + private String operator; + + public Inputs(){} + + public Inputs(Integer number1, Integer number2, String operator) { + this.number1 = number1; + this.number2 = number2; + this.operator = operator; + } + + public Integer getNumber1() { + return number1; + } + + public void setNumber1(Integer number1) { + this.number1 = number1; + } + + public Integer getNumber2() { + return number2; + } + + public void setNumber2(Integer number2) { + this.number2 = number2; + } + + public String getOperator() { + return operator; + } + + public void setOperator(String operator) { + this.operator = operator; + } + + public boolean isValid() { + if (this.number1 == null || this.number2 == null || operator == null) { + return false; + } + return true; + } + + @Override + public String toString() { + return "Inputs{" + + "number1=" + number1 + + ", number2=" + number2 + + ", operator='" + operator + '\'' + + '}'; + } +} \ No newline at end of file diff --git a/kieserver/64/src/test/resources/arquillian.xml b/kieserver/64/src/test/resources/arquillian.xml new file mode 100644 index 0000000..507e3d6 --- /dev/null +++ b/kieserver/64/src/test/resources/arquillian.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + cearq-kie + + + + + + + src/test/resources/testrunner-pod.json + + testrunner:9999,testrunner:9990,testrunner:8080 + + + + + + + + admin + Admin#70365 + + + + diff --git a/kieserver/64/src/test/resources/log4j.properties b/kieserver/64/src/test/resources/log4j.properties new file mode 100644 index 0000000..c838824 --- /dev/null +++ b/kieserver/64/src/test/resources/log4j.properties @@ -0,0 +1,17 @@ +#Log to Console as STDOUT +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c %3x - %m%n +#Log to file FILE +log4j.appender.file=org.apache.log4j.DailyRollingFileAppender +log4j.appender.file.File=logfile.log +log4j.appender.file.DatePattern='.'yyyy-MM-dd +log4j.appender.file.append=true +log4j.appender.file.layout=org.apache.log4j.PatternLayout +log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c %3x - %m%n + +#Root Logger +log4j.rootLogger=INFO, stdout + +log4j.logger.org.apache.http.wire=INFO diff --git a/kieserver/64/src/test/resources/testrunner-pod.json b/kieserver/64/src/test/resources/testrunner-pod.json new file mode 100644 index 0000000..165bf7d --- /dev/null +++ b/kieserver/64/src/test/resources/testrunner-pod.json @@ -0,0 +1,78 @@ +{ + "apiVersion":"v1", + "kind": "Pod", + "metadata": { + "name": "testrunner", + "labels": { + "name": "testrunner" + } + }, + "spec": { + "terminationGracePeriodSeconds": 0, + "containers": [{ + "name": "testrunner", + "readinessProbe" : { + "exec": { + "command": [ + "/bin/bash", + "-c", + "/opt/eap/bin/readinessProbe.sh" + ] + } + }, + "image": "jboss-eap-6/eap64-openshift:1.4", + "ports": [ + { + "containerPort": 8080, + "protocol": "TCP" + }, + { + "containerPort": 9990, + "protocol": "TCP" + }, + { + "containerPort": 9999, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "MQ_SERVICE_PREFIX_MAPPING", + "value": "kie-app-amq=MQ" + }, + { + "name": "MQ_JNDI", + "value": "java:/ConnectionFactory" + }, + { + "name": "MQ_USERNAME", + "value": "kieserver" + }, + { + "name": "MQ_PASSWORD", + "value": "Redhat@123" + }, + { + "name": "MQ_PROTOCOL", + "value": "tcp" + }, + { + "name": "MQ_QUEUES", + "value": "KIE.SERVER.REQUEST,KIE.SERVER.RESPONSE" + }, + { + "name": "MQ_TOPICS", + "value": "" + }, + { + "name": "ADMIN_USERNAME", + "value": "admin" + }, + { + "name": "ADMIN_PASSWORD", + "value": "Admin#70365" + } + ] + }] + } +} diff --git a/kieserver/64/src/test/resources/web.xml b/kieserver/64/src/test/resources/web.xml new file mode 100644 index 0000000..49a7a45 --- /dev/null +++ b/kieserver/64/src/test/resources/web.xml @@ -0,0 +1,34 @@ + + + + + + + index.html + + + diff --git a/kieserver/pom.xml b/kieserver/pom.xml index cb90b97..0856bff 100644 --- a/kieserver/pom.xml +++ b/kieserver/pom.xml @@ -16,57 +16,132 @@ kieserver-ce-testsuite pom KIE Server CE Testsuite - Decision Server Cloud Enablement Testsuite + KIE Server Cloud Enablement Testsuite + + + + Apache License Version 2.0 + https://repository.jboss.org/licenses/apache-2.0.txt + repo + + - + 63 + 64 - - 6.2.0.GA-redhat-1 - 6.2.0.Final-redhat-14 - 5.8.0.redhat-60083 - 1.0.1.Final - 1.0.8.Final-redhat-1 - - - - - - org.jboss.bom.brms - jboss-brms-bpmsuite-bom - ${version.jboss.bom.brms} - pom - import - - - org.kie - kie-bom - ${version.org.kie} - pom - import - - - - org.apache.activemq - activemq-all - ${version.activemq} - + + + redhat-ga-repository + http://maven.repository.redhat.com/ga/ + + true + never + + + false + never + + + + redhat-ea-repository + http://maven.repository.redhat.com/earlyaccess/all/ + + true + never + + + false + never + + + + redhat-tp-repository + http://maven.repository.redhat.com/techpreview/all + default + + true + never + + + false + never + + + - - org.hibernate.javax.persistence - hibernate-jpa-2.0-api - ${version.javax.jpa} - + + + redhat-ga-plugin-repository + http://maven.repository.redhat.com/ga/ + + true + never + + + false + never + + + + redhat-ea-plugin-repository + http://maven.repository.redhat.com/earlyaccess/all/ + + true + never + + + false + never + + + + redhat-tp-plugin-repository + http://maven.repository.redhat.com/techpreview/all + default + + true + never + + + false + never + + + - - org.openshift.kieserver - openshift-kieserver-common - ${version.org.openshift.kieserver} - test - - - + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.commonjava.maven.plugins + project-sources-maven-plugin + [0.3,) + + archive + + + + + + + + + + + + +