use of io.atlasmap.api.AtlasContext in project atlasmap by atlasmap.
the class ConcurrencyChaosMonkeyTest method chaosMonkeyTestManyContexts.
// one thread, many contexts
@Test
public void chaosMonkeyTestManyContexts() throws Exception {
long startTime = System.nanoTime();
URI mappingURI = generateMappingURI();
Status twitterStatus = generateTwitterStatus();
for (int i = 0; i < 256; i++) {
Thread chaosMonkeyThread = new Thread("ChaosMonkeyThread-" + i) {
public void run() {
LOG.info(this.getName() + " starting.");
for (int j = 0; j < 100000; j++) {
try {
AtlasContext context = atlasContextFactory.createContext(mappingURI);
AtlasSession session = context.createSession();
session.setDefaultSourceDocument(twitterStatus);
context.process(session);
Random rand = new Random(System.currentTimeMillis() % 13);
int randSleep;
randSleep = rand.nextInt(20000);
Thread.sleep(randSleep);
context.process(session);
Thread.sleep(randSleep);
} catch (Throwable e) {
LOG.error("ERROR", e);
}
}
LOG.info(this.getName() + " thread completed.");
}
};
chaosMonkeyThread.start();
}
Thread.sleep(600000L);
long difference = System.nanoTime() - startTime;
LOG.info(String.format("Total time: %d minutes to process 100000 mappings with one context per execution", TimeUnit.NANOSECONDS.toMinutes(difference)));
}
use of io.atlasmap.api.AtlasContext in project atlasmap by atlasmap.
the class JavaJavaFlatMappingTest method testProcessJavaJavaFlatFieldMappingPrimitivesBoxedValues.
@Test
public void testProcessJavaJavaFlatFieldMappingPrimitivesBoxedValues() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-flatprimitive.xml").toURI());
AtlasSession session = context.createSession();
BaseFlatPrimitiveClass sourceClass = generateFlatPrimitiveClassPrimitiveFieldsBoxedValues(SourceFlatPrimitiveClass.class);
session.setDefaultSourceDocument(sourceClass);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertTrue(object instanceof TargetFlatPrimitiveClass);
validateFlatPrimitiveClassPrimitiveFields((TargetFlatPrimitiveClass) object);
Validations validations = session.getValidations();
for (Validation v : validations.getValidation()) {
printValidation(v);
}
}
use of io.atlasmap.api.AtlasContext in project atlasmap by atlasmap.
the class JavaJavaMultiSourceTest method testProcessBasic.
@Test
public void testProcessBasic() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-multisource-basic.xml").toURI());
AtlasSession session = context.createSession();
BaseContact sourceContact = AtlasTestUtil.generateContact(SourceContact.class);
BaseAddress sourceAddress = AtlasTestUtil.generateAddress(SourceAddress.class);
session.setSourceDocument("con", sourceContact);
session.setSourceDocument("addr", sourceAddress);
context.process(session);
assertFalse(printAudit(session), session.hasErrors());
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertEquals(TargetContact.class.getName(), object.getClass().getName());
TargetContact targetContact = (TargetContact) object;
assertEquals("Ozzie", targetContact.getFirstName());
assertNull(targetContact.getLastName());
assertNull(targetContact.getPhoneNumber());
assertEquals("90210", targetContact.getZipCode());
}
use of io.atlasmap.api.AtlasContext in project atlasmap by atlasmap.
the class JavaJavaSeparateTest method testProcessSeparateSkip.
@Test
public void testProcessSeparateSkip() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-separate-skip.xml").toURI());
AtlasSession session = context.createSession();
BaseContact sourceContact = AtlasTestUtil.generateContact(SourceContact.class);
sourceContact.setFirstName("Dr. Mr. Ozzie L. Smith Jr.");
sourceContact.setLastName(null);
session.setDefaultSourceDocument(sourceContact);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertEquals(TargetContact.class.getName(), object.getClass().getName());
TargetContact targetContact = (TargetContact) object;
AtlasTestUtil.validateContact(targetContact);
assertFalse(session.hasErrors());
}
use of io.atlasmap.api.AtlasContext in project atlasmap by atlasmap.
the class JavaJavaSeparateTest method testProcessSeparateOutOfOrder.
@Test
public void testProcessSeparateOutOfOrder() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-separate-outoforder.xml").toURI());
AtlasSession session = context.createSession();
BaseContact sourceContact = AtlasTestUtil.generateContact(SourceContact.class);
sourceContact.setFirstName("Dr. Mr. Ozzie L. Smith Jr.");
sourceContact.setLastName(null);
session.setDefaultSourceDocument(sourceContact);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertEquals(TargetContact.class.getName(), object.getClass().getName());
TargetContact targetContact = (TargetContact) object;
AtlasTestUtil.validateContact(targetContact);
assertFalse(session.hasErrors());
}
Aggregations