use of com.adaptris.util.GuidGenerator in project interlok by adaptris.
the class StaticIdentitySequenceNumberServiceTest method testService_PooledConnection.
@Test
public void testService_PooledConnection() throws Exception {
int maxServices = 5;
final int iterations = 5;
int poolsize = maxServices - 1;
createDatabase();
List<Service> serviceList = new ArrayList<Service>();
String name = Thread.currentThread().getName();
Thread.currentThread().setName(getName());
JdbcPooledConnection conn = PooledConnectionHelper.createPooledConnection(PROPERTIES.getProperty(JDBC_SEQUENCENUMBER_DRIVER), PROPERTIES.getProperty(JDBC_SEQUENCENUMBER_URL), poolsize);
try {
for (int i = 0; i < maxServices; i++) {
StaticIdentitySequenceNumberService service = createServiceForTests(false);
service.setConnection(conn);
service.setIdentity(new GuidGenerator().safeUUID());
serviceList.add(service);
start(service);
}
PooledConnectionHelper.executeTest(serviceList, iterations, new PooledConnectionHelper.MessageCreator() {
@Override
public AdaptrisMessage createMsgForPooledConnectionTest() throws Exception {
return createMessageForTests();
}
});
assertEquals(0, conn.currentBusyConnectionCount());
assertEquals(poolsize, conn.currentIdleConnectionCount());
assertEquals(poolsize, conn.currentConnectionCount());
} finally {
stop(serviceList.toArray(new ComponentLifecycle[0]));
Thread.currentThread().setName(name);
}
}
use of com.adaptris.util.GuidGenerator in project interlok by adaptris.
the class StaticIdentitySequenceNumberServiceTest method testService_AdvancedPooledConnection.
@Test
public void testService_AdvancedPooledConnection() throws Exception {
int maxServices = 5;
final int iterations = 5;
int poolsize = maxServices - 1;
createDatabase();
List<Service> serviceList = new ArrayList<Service>();
String name = Thread.currentThread().getName();
Thread.currentThread().setName(getName());
AdvancedJdbcPooledConnection conn = PooledConnectionHelper.createAdvancedPooledConnection(PROPERTIES.getProperty(JDBC_SEQUENCENUMBER_DRIVER), PROPERTIES.getProperty(JDBC_SEQUENCENUMBER_URL), poolsize);
try {
for (int i = 0; i < maxServices; i++) {
StaticIdentitySequenceNumberService service = createServiceForTests(false);
service.setConnection(conn);
service.setIdentity(new GuidGenerator().safeUUID());
serviceList.add(service);
start(service);
}
PooledConnectionHelper.executeTest(serviceList, iterations, new PooledConnectionHelper.MessageCreator() {
@Override
public AdaptrisMessage createMsgForPooledConnectionTest() throws Exception {
return createMessageForTests();
}
});
assertEquals(0, conn.currentBusyConnectionCount());
assertEquals(poolsize, conn.currentIdleConnectionCount());
assertEquals(poolsize, conn.currentConnectionCount());
} finally {
stop(serviceList.toArray(new ComponentLifecycle[0]));
Thread.currentThread().setName(name);
}
}
use of com.adaptris.util.GuidGenerator in project interlok by adaptris.
the class WriteMetadataToFilesystemTest method testService_Filter.
@Test
public void testService_Filter() throws Exception {
String subDir = new GuidGenerator().getUUID().replaceAll(":", "").replaceAll("-", "");
AdaptrisMessage msg = createMessage();
WriteMetadataToFilesystem service = createService(subDir);
RegexMetadataFilter filter = new RegexMetadataFilter();
filter.addIncludePattern("alt_key.*");
filter.addExcludePattern("^key.*");
service.setMetadataFilter(filter);
File parentDir = FsHelper.createFileReference(FsHelper.createUrlFromString(PROPERTIES.getProperty(BASE_DIR), true));
String propsFilename = parentDir.getCanonicalPath() + "/" + subDir + "/" + msg.getUniqueId();
execute(service, msg);
Properties p = readProperties(new File(propsFilename), false);
assertFalse(p.containsKey("key5"));
assertTrue(p.containsKey("alt_key5"));
assertEquals("av5", p.getProperty("alt_key5"));
}
use of com.adaptris.util.GuidGenerator in project interlok by adaptris.
the class WriteMetadataToFilesystemTest method testService_OutputUnknown.
@Test
public void testService_OutputUnknown() throws Exception {
String subDir = new GuidGenerator().getUUID().replaceAll(":", "").replaceAll("-", "");
AdaptrisMessage msg = createMessage();
WriteMetadataToFilesystem service = createService(subDir);
File parentDir = FsHelper.createFileReference(FsHelper.createUrlFromString(PROPERTIES.getProperty(BASE_DIR), true));
String propsFilename = parentDir.getCanonicalPath() + "/" + subDir + "/" + msg.getUniqueId();
execute(service, msg);
Properties p = readProperties(new File(propsFilename), false);
assertTrue(p.containsKey("key5"));
assertEquals("v5", p.getProperty("key5"));
}
use of com.adaptris.util.GuidGenerator in project interlok by adaptris.
the class WriteMetadataToFilesystemTest method testService_OverwriteFalseFileNonExistent.
@Test
public void testService_OverwriteFalseFileNonExistent() throws Exception {
String subDir = new GuidGenerator().getUUID().replaceAll(":", "").replaceAll("-", "");
AdaptrisMessage msg = createMessage();
WriteMetadataToFilesystem service = createService(subDir);
service.setOverwriteIfExists(false);
File parentDir = FsHelper.createFileReference(FsHelper.createUrlFromString(PROPERTIES.getProperty(BASE_DIR), true));
String propsFilename = parentDir.getCanonicalPath() + "/" + subDir + "/" + msg.getUniqueId();
execute(service, msg);
Properties p = readProperties(new File(propsFilename), false);
assertTrue(p.containsKey("key5"));
assertEquals("v5", p.getProperty("key5"));
}
Aggregations