Skip to content

Commit

Permalink
#117 add byteman to Java EE tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mincong-h committed Jul 23, 2016
1 parent b020c26 commit ceacc8c
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 2 deletions.
42 changes: 42 additions & 0 deletions integrationtest/javaee-wildfly/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
<artifactId>hsearch-jsr352-integrationtest-wildfly</artifactId>
<name>GSoC JSR352 - Integration Tests in WildFly</name>

<properties>
<byteman.version>3.0.6</byteman.version>
<path.tools_jar>${java.home}/../lib/tools.jar</path.tools_jar>
</properties>

<dependencies>
<!-- This integration test refers to classes in his parent -->
<dependency>
Expand Down Expand Up @@ -59,6 +64,43 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<!-- byteman -->
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.6.0</version>
<scope>system</scope>
<systemPath>${path.tools_jar}</systemPath>
</dependency>
<dependency>
<groupId>org.jboss.byteman</groupId>
<artifactId>byteman</artifactId>
<scope>test</scope>
<version>${byteman.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.byteman</groupId>
<artifactId>byteman-submit</artifactId>
<scope>test</scope>
<version>${byteman.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.byteman</groupId>
<artifactId>byteman-install</artifactId>
<scope>test</scope>
<version>${byteman.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.byteman</groupId>
<artifactId>byteman-bmunit</artifactId>
<scope>test</scope>
<version>${byteman.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-extension-byteman</artifactId>
<version>1.0.0.Alpha3</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import org.hibernate.search.jsr352.test.util.BatchTestHelper;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.byteman.contrib.bmunit.BMRule;
import org.jboss.byteman.contrib.bmunit.BMRules;
import org.jboss.logging.Logger;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
Expand All @@ -38,12 +40,18 @@

/**
* This integration test (IT) aims to test the mass-indexer job execution under
* Java EE environment, with step partitioning (parallelism), checkpointing,
* Java EE environment, with step partitioning (parallelism), checkpointing,
* restartability and entity composite PK handling mechanism.
*
* @author Mincong Huang
*/
@RunWith(Arquillian.class)
@BMRules(rules = {
@BMRule(name = "interrupts the item reader",
targetClass = "org.hibernate.search.jsr352.internal.steps.lucene.ItemReader",
targetMethod = "open(Serializable)",
action = "traceln(\"Byteman : open detected\")")
})
public class MassIndexerIT {

private static final Logger logger = Logger.getLogger( MassIndexerIT.class );
Expand Down Expand Up @@ -138,7 +146,8 @@ private void testBatchStatus(StepExecution stepExecution) {
assertEquals( expected, readCount );
assertEquals( expected, writeCount );
assertEquals( BatchStatus.COMPLETED, batchStatus );
} else {
}
else {
String msg = "Unknown step " + stepName;
throw new IllegalStateException( msg );
}
Expand Down
12 changes: 12 additions & 0 deletions integrationtest/javaee-wildfly/src/test/resources/arquillian.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,19 @@
<!-- <property name="javaVmArguments">-javaagent:${byteman.agent.path}=script:${byteman.script.path} -Xmx512m -Djava.net.preferIPv4Stack=true -Djgroups.bind_addr=127.0.0.1</property> -->
<!-- To debug the Arquillian managed application server: -->
<!-- property name="javaVmArguments">-javaagent:${byteman.agent.path}=script:${byteman.script.path} -Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=y -Xmx512m -Dorg.jboss.remoting-jmx.timeout=300 -Djava.net.preferIPv4Stack=true -Djgroups.bind_addr=127.0.0.1</property -->
<!-- When using autoInstallAgent with WildFly, the com.sun.tools.attach
package has to be exposed as a system package and tools.jar added
to the bootstrap classpath. -->
<property name="javaVmArguments">-Djboss.modules.system.pkgs=com.sun.tools.attach,org.jboss.byteman
-Xbootclasspath/a:${path.tools_jar}
</property>
</configuration>
</container>
</group>

<!-- Byteman extension -->
<extension qualifier="byteman">
<property name="autoInstallAgent">true</property>
<property name="agentProperties">org.jboss.byteman.verbose=true</property>
</extension>
</arquillian>

0 comments on commit ceacc8c

Please sign in to comment.