Search in sources :

Example 26 with GuidGenerator

use of com.adaptris.util.GuidGenerator in project interlok by adaptris.

the class SimpleSequenceNumberTest method testDoService_MaximumAndNumberFormattingSetHit.

@Test
public void testDoService_MaximumAndNumberFormattingSetHit() throws Exception {
    SimpleSequenceNumberService service = new SimpleSequenceNumberService();
    service.setMetadataKey(DEFAULT_METADATA_KEY);
    String filename = new File(PROPERTIES.getProperty(KEY_BASEDIR), new GuidGenerator().getUUID()).getCanonicalPath();
    createPropertyFile(filename, 12);
    service.setSequenceNumberFile(filename);
    service.setNumberFormat("000");
    service.setMaximumSequenceNumber(12L);
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
    execute(service, msg);
    assertEquals(1, getSequenceNumber(filename));
    assertTrue(msg.containsKey(DEFAULT_METADATA_KEY));
    assertEquals("012", msg.getMetadataValue(DEFAULT_METADATA_KEY));
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) GuidGenerator(com.adaptris.util.GuidGenerator) File(java.io.File) Test(org.junit.Test)

Example 27 with GuidGenerator

use of com.adaptris.util.GuidGenerator in project interlok by adaptris.

the class SimpleSequenceNumberTest method testDoService_MaximumSetHitPropertyExceededMax.

@Test
public void testDoService_MaximumSetHitPropertyExceededMax() throws Exception {
    SimpleSequenceNumberService service = new SimpleSequenceNumberService();
    service.setMetadataKey(DEFAULT_METADATA_KEY);
    String filename = new File(PROPERTIES.getProperty(KEY_BASEDIR), new GuidGenerator().getUUID()).getCanonicalPath();
    createPropertyFile(filename, 13);
    service.setSequenceNumberFile(filename);
    service.setMaximumSequenceNumber(12L);
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
    execute(service, msg);
    assertEquals(2, getSequenceNumber(filename));
    assertTrue(msg.containsKey(DEFAULT_METADATA_KEY));
    assertEquals("1", msg.getMetadataValue(DEFAULT_METADATA_KEY));
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) GuidGenerator(com.adaptris.util.GuidGenerator) File(java.io.File) Test(org.junit.Test)

Example 28 with GuidGenerator

use of com.adaptris.util.GuidGenerator in project interlok by adaptris.

the class SimpleSequenceNumberTest method testDoService_MaximumSetHit.

@Test
public void testDoService_MaximumSetHit() throws Exception {
    SimpleSequenceNumberService service = new SimpleSequenceNumberService();
    service.setMetadataKey(DEFAULT_METADATA_KEY);
    String filename = new File(PROPERTIES.getProperty(KEY_BASEDIR), new GuidGenerator().getUUID()).getCanonicalPath();
    createPropertyFile(filename, 13);
    service.setSequenceNumberFile(filename);
    service.setMaximumSequenceNumber(12L);
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
    execute(service, msg);
    assertEquals(2, getSequenceNumber(filename));
    assertTrue(msg.containsKey(DEFAULT_METADATA_KEY));
    assertEquals("1", msg.getMetadataValue(DEFAULT_METADATA_KEY));
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) GuidGenerator(com.adaptris.util.GuidGenerator) File(java.io.File) Test(org.junit.Test)

Example 29 with GuidGenerator

use of com.adaptris.util.GuidGenerator in project interlok by adaptris.

the class SimpleSequenceNumberTest method testDoService_MaximumAndNumberFormattingSetHitPropertyExceededMax.

@Test
public void testDoService_MaximumAndNumberFormattingSetHitPropertyExceededMax() throws Exception {
    SimpleSequenceNumberService service = new SimpleSequenceNumberService();
    service.setMetadataKey(DEFAULT_METADATA_KEY);
    String filename = new File(PROPERTIES.getProperty(KEY_BASEDIR), new GuidGenerator().getUUID()).getCanonicalPath();
    createPropertyFile(filename, 13);
    service.setSequenceNumberFile(filename);
    service.setNumberFormat("000");
    service.setMaximumSequenceNumber(12L);
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
    execute(service, msg);
    assertEquals(2, getSequenceNumber(filename));
    assertTrue(msg.containsKey(DEFAULT_METADATA_KEY));
    assertEquals("001", msg.getMetadataValue(DEFAULT_METADATA_KEY));
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) GuidGenerator(com.adaptris.util.GuidGenerator) File(java.io.File) Test(org.junit.Test)

Example 30 with GuidGenerator

use of com.adaptris.util.GuidGenerator in project interlok by adaptris.

the class SimpleSequenceNumberTest method testDoService_MaximumAndNumberFormattingSetNotHit.

@Test
public void testDoService_MaximumAndNumberFormattingSetNotHit() throws Exception {
    SimpleSequenceNumberService service = new SimpleSequenceNumberService();
    service.setMetadataKey(DEFAULT_METADATA_KEY);
    String filename = new File(PROPERTIES.getProperty(KEY_BASEDIR), new GuidGenerator().getUUID()).getCanonicalPath();
    createPropertyFile(filename, 10);
    service.setSequenceNumberFile(filename);
    service.setNumberFormat("000");
    service.setMaximumSequenceNumber(12L);
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
    execute(service, msg);
    assertEquals(11, getSequenceNumber(filename));
    assertTrue(msg.containsKey(DEFAULT_METADATA_KEY));
    assertEquals("010", msg.getMetadataValue(DEFAULT_METADATA_KEY));
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) GuidGenerator(com.adaptris.util.GuidGenerator) File(java.io.File) Test(org.junit.Test)

Aggregations

GuidGenerator (com.adaptris.util.GuidGenerator)134 Test (org.junit.Test)120 File (java.io.File)91 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)61 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)30 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)27 TimeInterval (com.adaptris.util.TimeInterval)25 FixedIntervalPoller (com.adaptris.core.FixedIntervalPoller)24 RandomAccessFile (java.io.RandomAccessFile)24 Perl5FilenameFilter (org.apache.oro.io.Perl5FilenameFilter)23 FilenameFilter (java.io.FilenameFilter)21 ArrayList (java.util.ArrayList)20 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)18 LargeFsConsumer (com.adaptris.core.lms.LargeFsConsumer)15 Properties (java.util.Properties)15 Adapter (com.adaptris.core.Adapter)14 CoreException (com.adaptris.core.CoreException)11 AdaptrisMarshaller (com.adaptris.core.AdaptrisMarshaller)9 ServiceException (com.adaptris.core.ServiceException)8 IOException (java.io.IOException)8