-
Notifications
You must be signed in to change notification settings - Fork 597
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
16635fd
commit 7db99d4
Showing
10 changed files
with
375 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
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
151 changes: 151 additions & 0 deletions
151
dev/com.ibm.ws.jbatch.open_fat/fat/src/batch/fat/junit/JdbcConfigTestCheckpoint.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,151 @@ | ||
package batch.fat.junit; | ||
|
||
import java.util.Collections; | ||
import java.util.concurrent.Callable; | ||
|
||
import org.junit.ClassRule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import com.ibm.websphere.simplicity.log.Log; | ||
|
||
import batch.fat.util.BatchFATHelper; | ||
import componenttest.annotation.CheckpointTest; | ||
|
||
import com.ibm.ws.jbatch.test.BatchAppUtils; | ||
import com.ibm.ws.jbatch.test.FatUtils; | ||
|
||
import componenttest.custom.junit.runner.FATRunner; | ||
import componenttest.topology.impl.LibertyServerFactory; | ||
import io.openliberty.checkpoint.spi.CheckpointPhase; | ||
|
||
/** | ||
* | ||
* Test dynamic updates to JDBC config using various schemas and tablePrefixes. | ||
* | ||
*/ | ||
@RunWith(FATRunner.class) | ||
@CheckpointTest | ||
public class JdbcConfigTestCheckpoint extends BatchFATHelper { | ||
|
||
/** | ||
* Used with DynamicConfigRule. | ||
*/ | ||
public static Callable<Void> initialSetup = new Callable<Void>() { | ||
@Override | ||
public Void call() throws Exception { | ||
setup(); | ||
return null; | ||
} | ||
}; | ||
|
||
/** | ||
* Used with DynamicConfigRule. | ||
*/ | ||
public static Callable<Void> finalTearDown = new Callable<Void>() { | ||
@Override | ||
public Void call() throws Exception { | ||
tearDown(); | ||
return null; | ||
} | ||
}; | ||
|
||
/** | ||
* Used with DynamicConfigRule. Called after each iteration. | ||
*/ | ||
public static Callable<Void> afterEach = new Callable<Void>() { | ||
@Override | ||
public Void call() throws Exception { | ||
afterEach(); | ||
return null; | ||
} | ||
}; | ||
|
||
/** | ||
* This ClassRule will run all the tests in this class multiple times, against | ||
* all the given server.xml configuration files. | ||
* | ||
* Use setInitialSetup/setFinalTearDown to run logic before/after ALL | ||
* tests (against all configurations) have run. | ||
*/ | ||
@ClassRule | ||
public static DynamicConfigRule dynamicConfigRule = new DynamicConfigRule().setServer(server).setInitialSetup(initialSetup).setFinalTearDown(finalTearDown).setAfterEach(afterEach).addServerXml("JDBCPersistenceCheckpoint/jdbc.config.myschema1.server.xml").addServerXml("JDBCPersistenceCheckpoint/jdbc.config.myschema2.server.xml").addServerXml("JDBCPersistenceCheckpoint/jdbc.config.myschema1.tp1.server.xml").addServerXml("JDBCPersistenceCheckpoint/jdbc.config.myschema1.tp2.server.xml"); | ||
|
||
/** | ||
* Start the server and setup the DB. | ||
*/ | ||
public static void setup() throws Exception { | ||
|
||
log("setup", "start server and execute DDLs"); | ||
|
||
server = LibertyServerFactory.getLibertyServer("batchFAT"); | ||
BatchAppUtils.addDropinsBatchFATWar(server); | ||
BatchAppUtils.addDropinsBonusPayoutWar(server); | ||
BatchAppUtils.addDropinsDbServletAppWar(server); | ||
|
||
// Disabling security test for checkpoint | ||
FATSuite.configureBootStrapProperties(server, Collections.singletonMap("websphere.java.security.exempt","true")); | ||
|
||
// Start server | ||
server.setServerConfigurationFile("JDBCPersistenceCheckpoint/jdbc.config.myschema1.server.xml"); | ||
server.setCheckpoint(CheckpointPhase.AFTER_APP_START, true, null); | ||
server.startServer("JdbcConfig.log"); | ||
|
||
// Apply config and restore | ||
server.waitForStringInLog("CWWKF0011I", 20000); | ||
FatUtils.waitForSmarterPlanet(server); | ||
|
||
// Setup chunk test data | ||
executeSql("jdbc/batch", getChunkInTableSql()); | ||
executeSql("jdbc/batch", getChunkOutTableSql("APP.OUT4")); | ||
|
||
executeSql("jdbc/myds", getChunkInTableSql()); | ||
executeSql("jdbc/myds", getChunkOutTableSql("APP.OUT1")); | ||
executeSql("jdbc/myds", getChunkOutTableSql("APP.OUT2")); | ||
|
||
executeSql("jdbc/mydsNonTran", getChunkInTableSql()); | ||
executeSql("jdbc/mydsNonTran", getChunkOutTableSql("APP.OUT3")); | ||
} | ||
|
||
/** | ||
* Stop the server. | ||
*/ | ||
public static void tearDown() throws Exception { | ||
log("tearDown", "stopping server"); | ||
if (server != null && server.isStarted()) { | ||
server.stopServer(); | ||
} | ||
} | ||
|
||
/** | ||
* Clear out the OUT4 table used by the chunk tests. | ||
*/ | ||
public static void afterEach() throws Exception { | ||
log("afterEach", ""); | ||
executeSql(DFLT_PERSISTENCE_JNDI, "DELETE FROM APP.OUT4;"); | ||
} | ||
|
||
/** | ||
* Test a simple batchlet. | ||
*/ | ||
@Test | ||
public void testBasicJDBCPersistence() throws Exception { | ||
test("Basic", "jslName=BasicPersistence"); | ||
} | ||
|
||
/** | ||
* Chunk test using the same datasource as the batch tables. | ||
*/ | ||
@Test | ||
public void testSharedResourceMultiChunk() throws Exception { | ||
test("Chunk", "jslName=ChunkTestMultipleCheckpoint&writeTable=APP.OUT4&sharedDB=true"); | ||
} | ||
|
||
/** | ||
* Log helper. | ||
*/ | ||
public static void log(String method, String msg) { | ||
Log.info(JdbcConfigTestCheckpoint .class, method, msg); | ||
} | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
....jbatch.open_fat/publish/files/JDBCPersistenceCheckpoint/jdbc.config.myschema1.server.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,47 @@ | ||
<server> | ||
|
||
<featureManager> | ||
<feature>osgiconsole-1.0</feature> | ||
<feature>batch-1.0</feature> | ||
<feature>servlet-3.1</feature> | ||
<feature>servlet-4.0</feature> | ||
</featureManager> | ||
|
||
<include location="../fatTestPorts.xml"/> | ||
|
||
<!-- Configured with schema --> | ||
<batchPersistence jobStoreRef="BatchDatabaseStore" /> | ||
|
||
<databaseStore id="BatchDatabaseStore" dataSourceRef="batchDB" schema="MYSCHEMA1" tablePrefix="" /> | ||
|
||
<!-- The derby driver --> | ||
<library id="DerbyLib"> | ||
<file name="${shared.resource.dir}/derby/derby.jar"/> | ||
</library> | ||
|
||
<!-- The following configures in-memory Derby. For Derby on disk, which is needed if the database | ||
is required beyond a single server start, configure the databaseName with a file location such as: | ||
databaseName="${shared.config.dir}/data/derbydb" --> | ||
|
||
<!-- Derby datasource used for batch tables--> | ||
<dataSource id="batchDB" jndiName="jdbc/batch" type="javax.sql.XADataSource"> | ||
<jdbcDriver libraryRef="DerbyLib"/> | ||
<properties.derby.embedded createDatabase="create" databaseName="memory:JdbcConfigTestCheckpointDb" user="user" password="pass" /> | ||
</dataSource> | ||
|
||
<!-- Derby datasource used by chunk tests, transactional --> | ||
<dataSource jndiName="jdbc/myds" type="javax.sql.XADataSource"> | ||
<jdbcDriver libraryRef="DerbyLib"/> | ||
<properties.derby.embedded createDatabase="create" databaseName="memory:ChunkTestTwoResources" user="user" password="pass" /> | ||
</dataSource> | ||
|
||
<!-- Derby datasource used by chunk tests, non-transactional --> | ||
<dataSource jndiName="jdbc/mydsNonTran" type="javax.sql.ConnectionPoolDataSource" transactional="false"> | ||
<jdbcDriver libraryRef="DerbyLib"/> | ||
<properties.derby.embedded createDatabase="create" databaseName="memory:ChunkTestTwoResourcesNonTran" user="user" password="pass" /> | ||
</dataSource> | ||
|
||
<javaPermission className="java.util.PropertyPermission" name="*" actions="read"/> | ||
<javaPermission className="java.security.AllPermission" codebase="${shared.resource.dir}/derby/derby.jar"/> | ||
|
||
</server> |
46 changes: 46 additions & 0 deletions
46
...tch.open_fat/publish/files/JDBCPersistenceCheckpoint/jdbc.config.myschema1.tp1.server.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,46 @@ | ||
<server> | ||
|
||
<featureManager> | ||
<feature>osgiconsole-1.0</feature> | ||
<feature>batch-1.0</feature> | ||
<feature>servlet-3.1</feature> | ||
<feature>servlet-4.0</feature> | ||
</featureManager> | ||
|
||
<include location="../fatTestPorts.xml"/> | ||
|
||
<!-- Configured with schema --> | ||
<batchPersistence jobStoreRef="BatchDatabaseStore" /> | ||
|
||
<databaseStore id="BatchDatabaseStore" dataSourceRef="batchDB" schema="MYSCHEMA1" tablePrefix="TP1_"/> | ||
|
||
<!-- The derby driver --> | ||
<library id="DerbyLib"> | ||
<file name="${shared.resource.dir}/derby/derby.jar"/> | ||
</library> | ||
|
||
<!-- The following configures in-memory Derby. For Derby on disk, which is needed if the database | ||
is required beyond a single server start, configure the databaseName with a file location such as: | ||
databaseName="${shared.config.dir}/data/derbydb" --> | ||
|
||
<!-- Derby datasource used for batch tables--> | ||
<dataSource id="batchDB" jndiName="jdbc/batch" type="javax.sql.XADataSource"> | ||
<jdbcDriver libraryRef="DerbyLib"/> | ||
<properties.derby.embedded createDatabase="create" databaseName="memory:JdbcConfigTestCheckpointDb" user="user" password="pass" /> | ||
</dataSource> | ||
|
||
<!-- Derby datasource used by chunk tests, transactional --> | ||
<dataSource jndiName="jdbc/myds" type="javax.sql.XADataSource"> | ||
<jdbcDriver libraryRef="DerbyLib"/> | ||
<properties.derby.embedded createDatabase="create" databaseName="memory:ChunkTestTwoResources" user="user" password="pass" /> | ||
</dataSource> | ||
|
||
<!-- Derby datasource used by chunk tests, non-transactional --> | ||
<dataSource jndiName="jdbc/mydsNonTran" type="javax.sql.ConnectionPoolDataSource" transactional="false"> | ||
<jdbcDriver libraryRef="DerbyLib"/> | ||
<properties.derby.embedded createDatabase="create" databaseName="memory:ChunkTestTwoResourcesNonTran" user="user" password="pass" /> | ||
</dataSource> | ||
|
||
<javaPermission className="java.util.PropertyPermission" name="*" actions="read"/> | ||
|
||
</server> |
Oops, something went wrong.