-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #72 fix PurgeBatchlet to work with the JdbcRepository wrapper i…
…n WildFly, and add wildfly-jberet-samples/purgeJdbcRepository2.
- Loading branch information
Showing
11 changed files
with
323 additions
and
10 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
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
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
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,86 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!-- | ||
Copyright (c) 2016 Red Hat, Inc. and/or its affiliates. | ||
All rights reserved. This program and the accompanying materials | ||
are made available under the terms of the Eclipse Public License v1.0 | ||
which accompanies this distribution, and is available at | ||
http://www.eclipse.org/legal/epl-v10.html | ||
Contributors: | ||
Cheng Fang - Initial API and implementation | ||
--> | ||
|
||
<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/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<artifactId>wildfly-jberet-samples</artifactId> | ||
<groupId>org.jberet.samples</groupId> | ||
<version>1.3.0.Beta2-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>purgeJdbcRepository</artifactId> | ||
|
||
<packaging>war</packaging> | ||
|
||
<name>purgeJdbcRepository Maven Webapp</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.jberet.samples</groupId> | ||
<artifactId>jberet-samples-common</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<finalName>purgeJdbcRepository2</finalName> | ||
</build> | ||
|
||
<profiles> | ||
<profile> | ||
<id>default</id> | ||
<activation> | ||
<activeByDefault>true</activeByDefault> | ||
</activation> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<configuration> | ||
<excludes> | ||
<exclude>**/*.java</exclude> | ||
</excludes> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
<profile> | ||
<id>wildfly</id> | ||
<activation> | ||
<property> | ||
<name>wildfly</name> | ||
</property> | ||
</activation> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.wildfly.plugins</groupId> | ||
<artifactId>wildfly-maven-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<configuration> | ||
<includes> | ||
<include>**/*IT.java</include> | ||
</includes> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
</project> |
26 changes: 26 additions & 0 deletions
26
...-jberet-samples/purgeJdbcRepository2/src/main/resources/META-INF/batch-jobs/prepurge2.xml
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 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!-- | ||
Copyright (c) 2016 Red Hat, Inc. and/or its affiliates. | ||
All rights reserved. This program and the accompanying materials | ||
are made available under the terms of the Eclipse Public License v1.0 | ||
which accompanies this distribution, and is available at | ||
http://www.eclipse.org/legal/epl-v10.html | ||
Contributors: | ||
Cheng Fang - Initial API and implementation | ||
--> | ||
|
||
<job id="prepurge2" xmlns="http://xmlns.jcp.org/xml/ns/javaee" version="1.0"> | ||
<step id="prepurge2.step1"> | ||
<batchlet> | ||
<script type="javascript"> | ||
function process() { | ||
print('Running prepurge2.step1'); | ||
return null; | ||
} | ||
</script> | ||
</batchlet> | ||
</step> | ||
</job> |
39 changes: 39 additions & 0 deletions
39
...ples/purgeJdbcRepository2/src/main/resources/META-INF/batch-jobs/purgeJdbcRepository2.xml
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,39 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!-- | ||
Copyright (c) 2016 Red Hat, Inc. and/or its affiliates. | ||
All rights reserved. This program and the accompanying materials | ||
are made available under the terms of the Eclipse Public License v1.0 | ||
which accompanies this distribution, and is available at | ||
http://www.eclipse.org/legal/epl-v10.html | ||
Contributors: | ||
Cheng Fang - Initial API and implementation | ||
--> | ||
|
||
<job id="purgeJdbcRepository2" xmlns="http://xmlns.jcp.org/xml/ns/javaee" version="1.0"> | ||
<step id="purgeJdbcRepository2.step1"> | ||
<batchlet ref="org.jberet.repository.PurgeBatchlet"> | ||
<properties> | ||
<property name="sql" value="#{jobParameters['sql']}"/> | ||
<property name="sqlFile" value="#{jobParameters['sqlFile']}"/> | ||
|
||
<property name="jobExecutionSelector" value="#{jobParameters['jobExecutionSelector']}"/> | ||
<property name="keepRunningJobExecutions" value="#{jobParameters['keepRunningJobExecutions']}"/> | ||
<property name="purgeJobsByNames" value="#{jobParameters['purgeJobsByNames']}"/> | ||
<property name="jobExecutionIds" value="#{jobParameters['jobExecutionIds']}"/> | ||
<property name="numberOfRecentJobExecutionsToKeep" | ||
value="#{jobParameters['numberOfRecentJobExecutionsToKeep']}"/> | ||
<property name="jobExecutionIdFrom" value="#{jobParameters['jobExecutionIdFrom']}"/> | ||
<property name="jobExecutionIdTo" value="#{jobParameters['jobExecutionIdTo']}"/> | ||
<property name="withinPastMinutes" value="#{jobParameters['withinPastMinutes']}"/> | ||
<property name="jobExecutionEndTimeFrom" value="#{jobParameters['jobExecutionEndTimeFrom']}"/> | ||
<property name="jobExecutionEndTimeTo" value="#{jobParameters['jobExecutionEndTimeTo']}"/> | ||
<property name="batchStatuses" value="#{jobParameters['batchStatuses']}"/> | ||
<property name="exitStatuses" value="#{jobParameters['exitStatuses']}"/> | ||
<property name="jobExecutionsByJobNames" value="#{jobParameters['jobExecutionsByJobNames']}"/> | ||
</properties> | ||
</batchlet> | ||
</step> | ||
</job> |
8 changes: 8 additions & 0 deletions
8
wildfly-jberet-samples/purgeJdbcRepository2/src/main/resources/purgeJdbcRepository2.sql
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,8 @@ | ||
delete from STEP_EXECUTION where JOBEXECUTIONID in | ||
(select JOBEXECUTIONID from JOB_EXECUTION, JOB_INSTANCE | ||
where JOB_EXECUTION.JOBINSTANCEID = JOB_INSTANCE.JOBINSTANCEID and JOB_INSTANCE.JOBNAME = 'prepurge2'); | ||
|
||
|
||
delete from JOB_EXECUTION where JOBEXECUTIONID in | ||
(select JOBEXECUTIONID from JOB_EXECUTION, JOB_INSTANCE | ||
where JOB_EXECUTION.JOBINSTANCEID = JOB_INSTANCE.JOBINSTANCEID and JOB_INSTANCE.JOBNAME = 'prepurge2') |
Empty file.
7 changes: 7 additions & 0 deletions
7
...beret-samples/purgeJdbcRepository2/src/main/webapp/WEB-INF/jboss-deployment-structure.xml
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,7 @@ | ||
<jboss-deployment-structure> | ||
<deployment> | ||
<dependencies> | ||
<module name="com.google.guava"/> | ||
</dependencies> | ||
</deployment> | ||
</jboss-deployment-structure> |
9 changes: 9 additions & 0 deletions
9
wildfly-jberet-samples/purgeJdbcRepository2/src/main/webapp/WEB-INF/web.xml
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,9 @@ | ||
<web-app version="3.1" | ||
xmlns="http://xmlns.jcp.org/xml/ns/javaee" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"> | ||
<servlet-mapping> | ||
<servlet-name>javax.ws.rs.core.Application</servlet-name> | ||
<url-pattern>/api/*</url-pattern> | ||
</servlet-mapping> | ||
</web-app> |
88 changes: 88 additions & 0 deletions
88
...src/test/java/org/jberet/samples/wildfly/purgeJdbcRepository2/PurgeJdbcRepository2IT.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,88 @@ | ||
/* | ||
* Copyright (c) 2014-2016 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Cheng Fang - Initial API and implementation | ||
*/ | ||
|
||
package org.jberet.samples.wildfly.purgeJdbcRepository2; | ||
|
||
import java.util.Properties; | ||
import javax.batch.runtime.BatchStatus; | ||
|
||
import org.jberet.rest.client.BatchClient; | ||
import org.jberet.rest.entity.JobExecutionEntity; | ||
import org.jberet.samples.wildfly.common.BatchTestBase; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
/** | ||
* Tests to verify {@code PurgeBatchlet} in JBoss EAP and WildFly. | ||
* | ||
* Similar tests for Java SE environment are: | ||
* <ul> | ||
* <li>test-apps/purgeJdbcRepository | ||
* <li>test-apps/purgeInMemoryRepository | ||
* <li>test-apps/purgeMongoRepository | ||
* </ul> | ||
*/ | ||
public final class PurgeJdbcRepository2IT extends BatchTestBase { | ||
/** | ||
* The job name defined in {@code META-INF/batch-jobs/purgeJdbcRepository2.xml} | ||
*/ | ||
private static final String jobName = "purgeJdbcRepository2"; | ||
|
||
/** | ||
* The job name defined in {@code META-INF/batch-jobs/prepurge2.xml} | ||
*/ | ||
private static final String prepurge2JobName = "prepurge2"; | ||
|
||
/** | ||
* The full REST API URL, including scheme, hostname, port number, context path, servlet path for REST API. | ||
* For example, "http://localhost:8080/testApp/api" | ||
*/ | ||
private static final String restUrl = BASE_URL + "purgeJdbcRepository2/api"; | ||
|
||
private BatchClient batchClient = new BatchClient(restUrl); | ||
|
||
@Override | ||
protected BatchClient getBatchClient() { | ||
return batchClient; | ||
} | ||
|
||
@Test | ||
public void withSql() throws Exception { | ||
final long prepurgeExecutionId = prepurge(); | ||
JobExecutionEntity prepurgeJobExecution = batchClient.getJobExecution(prepurgeExecutionId); | ||
assertEquals(BatchStatus.COMPLETED, prepurgeJobExecution.getBatchStatus()); | ||
|
||
final String sql = | ||
"delete from STEP_EXECUTION where JOBEXECUTIONID in " + | ||
"(select JOBEXECUTIONID from JOB_EXECUTION, JOB_INSTANCE " + | ||
"where JOB_EXECUTION.JOBINSTANCEID = JOB_INSTANCE.JOBINSTANCEID and JOB_INSTANCE.JOBNAME like 'prepurge%'); " + | ||
|
||
"delete from JOB_EXECUTION where JOBINSTANCEID in " + | ||
"(select JOBINSTANCEID from JOB_INSTANCE where JOBNAME like 'prepurge%');"; | ||
|
||
|
||
final Properties jobParams = new Properties(); | ||
jobParams.setProperty("sql", sql); | ||
startJobCheckStatus(jobName, jobParams, 3000, BatchStatus.COMPLETED); | ||
|
||
// prepurgeJobExecution = batchClient.getJobExecution(prepurgeExecutionId); | ||
// assertEquals(null, prepurgeJobExecution); | ||
} | ||
|
||
private long prepurge() throws Exception { | ||
final JobExecutionEntity jobExecutionEntity = batchClient.startJob(prepurge2JobName, null); | ||
Thread.sleep(1000); | ||
return jobExecutionEntity.getExecutionId(); | ||
} | ||
|
||
} |