use of com.adaptris.util.TimeInterval in project interlok by adaptris.
the class MetadataCountInterceptorTest method testCreatesNewTimeSliceAfterTimeDelay.
@Test
public void testCreatesNewTimeSliceAfterTimeDelay() throws Exception {
LifecycleHelper.init(metricsInterceptor);
LifecycleHelper.start(metricsInterceptor);
// a negative number will expire the timeslice immediately after the first message
metricsInterceptor.setTimesliceDuration(new TimeInterval(-1L, TimeUnit.SECONDS));
AdaptrisMessage message = createMessage(COUNTER_1);
assertEquals(0, metricsInterceptor.getStats().size());
submitMessage(message);
assertEquals(1, metricsInterceptor.getStats().size());
assertEquals(1, ((MetadataStatistic) metricsInterceptor.getStats().get(0)).getValue(COUNTER_1));
assertEquals(0, ((MetadataStatistic) metricsInterceptor.getStats().get(0)).getValue(COUNTER_2));
metricsInterceptor.setTimesliceDuration(new TimeInterval(1L, TimeUnit.SECONDS));
submitMessage(message);
submitMessage(message);
assertEquals(2, metricsInterceptor.getStats().size());
assertEquals(1, ((MetadataStatistic) metricsInterceptor.getStats().get(0)).getValue(COUNTER_1));
assertEquals(0, ((MetadataStatistic) metricsInterceptor.getStats().get(0)).getValue(COUNTER_2));
assertEquals(2, ((MetadataStatistic) metricsInterceptor.getStats().get(1)).getValue(COUNTER_1));
assertEquals(0, ((MetadataStatistic) metricsInterceptor.getStats().get(1)).getValue(COUNTER_2));
}
use of com.adaptris.util.TimeInterval in project interlok by adaptris.
the class MetadataCountInterceptorTest method testProduceAfterNewTimeSlice.
@Test
public void testProduceAfterNewTimeSlice() throws Exception {
ProducingStatisticManager producingStatisticManager = new ProducingStatisticManager();
producingStatisticManager.setMarshaller(mockMarshaller);
producingStatisticManager.setProducer(mockStandaloneProducer);
metricsInterceptor.setStatisticManager(producingStatisticManager);
LifecycleHelper.init(metricsInterceptor);
LifecycleHelper.start(metricsInterceptor);
AdaptrisMessage message = DefaultMessageFactory.getDefaultInstance().newMessage();
// A minus time will expire the time slice immediately after the first message
metricsInterceptor.setTimesliceDuration(new TimeInterval(-1L, TimeUnit.SECONDS));
assertEquals(0, metricsInterceptor.getStats().size());
submitMessage(message);
assertEquals(1, metricsInterceptor.getStats().size());
submitMessage(message);
verify(mockMarshaller).marshal(any());
verify(mockStandaloneProducer).produce(any());
}
use of com.adaptris.util.TimeInterval in project interlok by adaptris.
the class MetadataCountWorkflowTest method retrieveObjectForSampleConfig.
@Override
protected Object retrieveObjectForSampleConfig() {
Channel c = new Channel();
StandardWorkflow wf = new StandardWorkflow();
wf.setUniqueId("MyWorkflowName");
MetadataCountInterceptor ti = new MetadataCountInterceptor("metadatakey1");
ti.setUniqueId("Metrics_For_MyWorkflowName");
ti.setTimesliceDuration(new TimeInterval(60L, TimeUnit.SECONDS));
wf.addInterceptor(ti);
c.setUniqueId(UUID.randomUUID().toString());
wf.setUniqueId(UUID.randomUUID().toString());
c.getWorkflowList().add(wf);
return c;
}
use of com.adaptris.util.TimeInterval in project interlok by adaptris.
the class DebugPoolFactoryTest method testPoolBuilder.
@Test
public void testPoolBuilder() throws Exception {
DebugPoolFactory factory = new DebugPoolFactory().withDebugUnreturnedConnectionStackTraces(true).withUnreturnedConnectionTimeout(new TimeInterval(10L, TimeUnit.SECONDS));
;
PluggableJdbcPooledConnection con = createConnection();
C3P0PooledDataSource pooledDs = factory.build(con);
ComboPooledDataSource wrapped = pooledDs.wrapped();
assertEquals(con.getConnectUrl(), wrapped.getJdbcUrl());
assertTrue(wrapped.isDebugUnreturnedConnectionStackTraces());
assertEquals(10, wrapped.getUnreturnedConnectionTimeout());
}
use of com.adaptris.util.TimeInterval in project interlok by adaptris.
the class DefaultPoolFactoryTest method createConnection.
public static PluggableJdbcPooledConnection createConnection() throws Exception {
String url = "jdbc:derby:memory:" + GUID.safeUUID() + ";create=true";
PluggableJdbcPooledConnection con = new PluggableJdbcPooledConnection();
con.setConnectUrl(url);
con.setDriverImp(DRIVER_IMP);
con.setConnectionAttempts(1);
con.setConnectionRetryInterval(new TimeInterval(10L, TimeUnit.MILLISECONDS.name()));
return con;
}
Aggregations