-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WELD-1870 Probe integration tests - initial commit
- Loading branch information
Showing
20 changed files
with
1,101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>weld-probe-parent</artifactId> | ||
<groupId>org.jboss.weld.probe</groupId> | ||
<version>3.0.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.jboss.weld.probe</groupId> | ||
<artifactId>integration-tests</artifactId> | ||
<version>3.0.0-SNAPSHOT</version> | ||
|
||
<properties> | ||
<gson.version>2.3.1</gson.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.weld.probe</groupId> | ||
<artifactId>weld-probe-core</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.enterprise</groupId> | ||
<artifactId>cdi-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.arquillian.junit</groupId> | ||
<artifactId>arquillian-junit-container</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.shrinkwrap</groupId> | ||
<artifactId>shrinkwrap-impl-base</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.code.gson</groupId> | ||
<artifactId>gson</artifactId> | ||
<version>${gson.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.spec.javax.servlet</groupId> | ||
<artifactId>jboss-servlet-api_3.0_spec</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>net.sourceforge.htmlunit</groupId> | ||
<artifactId>htmlunit</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<profiles> | ||
<profile> | ||
<id>default</id> | ||
<activation> | ||
<activeByDefault>false</activeByDefault> | ||
<property> | ||
<name>!incontainer</name> | ||
</property> | ||
</activation> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<skipTests>true</skipTests> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
|
||
<profile> | ||
<id>incontainer</id> | ||
<activation> | ||
<activeByDefault>false</activeByDefault> | ||
<property> | ||
<name>incontainer</name> | ||
<value>true</value> | ||
</property> | ||
</activation> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.wildfly</groupId> | ||
<artifactId>wildfly-arquillian-container-managed</artifactId> | ||
<scope>test</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>org.jboss.logmanager</groupId> | ||
<artifactId>log4j-jboss-logmanager</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>log4j</groupId> | ||
<artifactId>log4j</artifactId> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<systemPropertyVariables> | ||
<!-- jboss.server.config.file.name>standalone-full.xml</jboss.server.config.file.name--> | ||
</systemPropertyVariables> | ||
<systemProperties> | ||
<arquillian.xml>arquillian.xml</arquillian.xml> | ||
<jacoco.agent>${jacoco.agent}</jacoco.agent> | ||
<additional.vm.args>${additional.vm.args}</additional.vm.args> | ||
<org.jboss.remoting-jmx.timeout>360</org.jboss.remoting-jmx.timeout> | ||
</systemProperties> | ||
<parallel>none</parallel> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
|
||
<!-- WildFly 8.x - Remote --> | ||
<profile> | ||
<id>incontainer-remote</id> | ||
<activation> | ||
<activeByDefault>false</activeByDefault> | ||
<property> | ||
<name>incontainer</name> | ||
<value>remote</value> | ||
</property> | ||
</activation> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.wildfly</groupId> | ||
<artifactId>wildfly-arquillian-container-remote</artifactId> | ||
<scope>test</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>org.jboss.logmanager</groupId> | ||
<artifactId>log4j-jboss-logmanager</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>log4j</groupId> | ||
<artifactId>log4j</artifactId> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<systemProperties> | ||
<arquillian.xml>arquillian.xml</arquillian.xml> | ||
</systemProperties> | ||
<parallel>none</parallel> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
|
||
</project> |
109 changes: 109 additions & 0 deletions
109
.../integration-tests/src/main/java/org/jboss/weld/probe/integration/tests/JSONTestUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2015, Red Hat, Inc., and individual contributors | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jboss.weld.probe.integration.tests; | ||
|
||
import java.io.IOException; | ||
import java.net.URL; | ||
|
||
import com.gargoylesoftware.htmlunit.WebClient; | ||
import com.google.gson.Gson; | ||
import com.google.gson.JsonArray; | ||
import com.google.gson.JsonObject; | ||
|
||
public class JSONTestUtil { | ||
|
||
public static final String DATA = "data"; | ||
public static final String ID = "id"; | ||
public static final String BDAS = "bdas"; | ||
public static final String BDA_ID = "bdaId"; | ||
public static final String KIND = "kind"; | ||
public static final String SCOPE = "scope"; | ||
public static final String QUALIFIERS = "qualifiers"; | ||
public static final String TYPES = "types"; | ||
public static final String DEPENDENTS = "dependents"; | ||
public static final String DEPENDENCIES = "dependencies"; | ||
public static final String BEAN_CLASS = "beanClass"; | ||
public static final String METHOD_NAME = "methodName"; | ||
public static final String EVENT_INFO = "eventInfo"; | ||
public static final String INSTANCES = "instances"; | ||
public static final String BEAN_DISCOVERY_MODE = "beanDiscoveryMode"; | ||
public static final String DEPLOYMENT_PATH = "weld-probe/deployment"; | ||
public static final String INVOCATIONS_PATH = "weld-probe/invocations"; | ||
public static final String EVENTS_PATH = "weld-probe/events"; | ||
public static final String BEANS_PATH = "weld-probe/beans"; | ||
public static final String SESSION_CONTEXTS_PATH = "weld-probe/contexts/session"; | ||
public static final String APPLICATION_CONTEXTS_PATH = "weld-probe/contexts/application"; | ||
public static final String BEANS_PATH_ALL = "weld-probe/beans?pageSize=0"; | ||
|
||
private JSONTestUtil() { | ||
} | ||
|
||
public static JsonObject getPageAsJSONObject(String path, URL url) throws IOException { | ||
return getPageAsJSONObject(path, url, null); | ||
} | ||
|
||
public static JsonObject getPageAsJSONObject(String path, URL url, WebClient client) throws IOException { | ||
|
||
if (client == null) { | ||
client = new WebClient(); | ||
} | ||
|
||
Gson gson = new Gson(); | ||
JsonObject jsonObject = gson.fromJson(client.getPage(url.toString().concat(path)).getWebResponse().getContentAsString(), JsonObject.class); | ||
return jsonObject; | ||
} | ||
|
||
public static JsonObject getDeploymentByName(String path, String name, URL url) throws IOException { | ||
JsonObject deploymentJSON = getPageAsJSONObject(path, url); | ||
JsonArray deployments = deploymentJSON.getAsJsonArray(BDAS); | ||
JsonObject result = null; | ||
for (int i = 0; i < deployments.size(); i++) { | ||
String bdaId = deployments.get(i).getAsJsonObject().get(BDA_ID).getAsString(); | ||
if (bdaId.contains(name)) { | ||
result = deployments.get(i).getAsJsonObject(); | ||
} | ||
} | ||
return result; | ||
} | ||
|
||
public static JsonObject getBeanDetail(String path, Class clazz, URL url) throws IOException { | ||
JsonObject beans = getPageAsJSONObject(path, url); | ||
JsonArray beansArray = beans.getAsJsonArray(DATA); | ||
String id = null; | ||
for (int i = 0; i < beansArray.size(); i++) { | ||
JsonObject bean = beansArray.get(i).getAsJsonObject(); | ||
if (bean.get(BEAN_CLASS).getAsString().equals(clazz.getName())) { | ||
id = bean.get(ID).getAsString(); | ||
} | ||
} | ||
|
||
if (id != null) { | ||
String beanDetailURL = BEANS_PATH.concat("/".concat(id)); | ||
return getPageAsJSONObject(beanDetailURL, url); | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
public static enum BeanType { | ||
|
||
MANAGED, | ||
INTERCEPTOR, | ||
DECORATOR; | ||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
...tests/src/test/java/org/jboss/weld/probe/integration/tests/ApplicationScopedObserver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2015, Red Hat, Inc., and individual contributors | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jboss.weld.probe.integration.tests; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.enterprise.event.Observes; | ||
|
||
import org.jboss.weld.probe.integration.tests.annotations.Collector; | ||
|
||
@ApplicationScoped | ||
public class ApplicationScopedObserver { | ||
|
||
|
||
public void listen(@Observes @Collector("A") String action){ | ||
} | ||
|
||
public void listen1(@Observes @Collector("B") String action){ | ||
} | ||
|
||
public void listen2(@Observes @Collector("A") @Collector("B") String action){ | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...tegration-tests/src/test/java/org/jboss/weld/probe/integration/tests/InvokingServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.jboss.weld.probe.integration.tests; | ||
|
||
import java.io.IOException; | ||
|
||
import javax.inject.Inject; | ||
import javax.servlet.annotation.WebServlet; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
@WebServlet("/test") | ||
public class InvokingServlet extends HttpServlet { | ||
|
||
@Inject | ||
ModelBean modelBean; | ||
|
||
|
||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { | ||
|
||
modelBean.simpleCall(); | ||
|
||
resp.getWriter().print(req.getSession().getId()); | ||
resp.setContentType("text/html"); | ||
|
||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
probe/integration-tests/src/test/java/org/jboss/weld/probe/integration/tests/ModelBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2015, Red Hat, Inc., and individual contributors | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jboss.weld.probe.integration.tests; | ||
|
||
import javax.enterprise.inject.Model; | ||
import javax.inject.Inject; | ||
|
||
@Model | ||
public class ModelBean { | ||
|
||
@Inject | ||
SessionScopedBean session; | ||
|
||
public void simpleCall() { | ||
session.doSomething(); | ||
} | ||
|
||
} |
Oops, something went wrong.