use of org.talend.esb.sam.common.event.Event in project tesb-rt-se by Talend.
the class EventRepositoryTest method testWriteEvent.
@Test
public void testWriteEvent() {
GregorianCalendar cal = new GregorianCalendar(2000, Calendar.JANUARY, 1, 01, 01, 10);
Event event = EventCreator.createEvent("content", cal.getTime(), EventTypeEnum.REQ_IN, "orig_id", "localhost", "10.0.0.1", "1", "2", "3", "operation", "service", "http");
event.getCustomInfo().put("mykey1", "myValue1");
event.getCustomInfo().put("mykey2", "myValue2");
Assert.assertNull(event.getPersistedId());
eventRepository.writeEvent(event);
Assert.assertNotNull(event.getPersistedId());
// read Event from database
Event readEvent = eventRepository.readEvent(event.getPersistedId().longValue());
Assert.assertTrue(EqualsBuilder.reflectionEquals(event, readEvent));
}
use of org.talend.esb.sam.common.event.Event in project tesb-rt-se by Talend.
the class MonitoringServiceFullTest method testSendEvents.
// @Before
// public void setUp() throws Exception {
// executeSqlScript("create.sql", true);
// }
@Test
public void testSendEvents() throws PutEventsFault, MalformedURLException, URISyntaxException {
Client client = ClientProxy.getClient(monitoringService);
HTTPConduit conduit = (HTTPConduit) client.getConduit();
HTTPClientPolicy clientConfig = new HTTPClientPolicy();
clientConfig.setReceiveTimeout(100000);
conduit.setClient(clientConfig);
jdbcTemplate.update("delete from EVENTS");
List<EventType> events = new ArrayList<EventType>();
EventType eventType = new EventType();
eventType.setEventType(EventEnumType.REQ_OUT);
URL messageContentFile = this.getClass().getResource("/testmessage.xml").toURI().toURL();
eventType.setContent(new DataHandler(messageContentFile));
CustomInfoType ciType = new CustomInfoType();
CustomInfoType.Item prop1 = new CustomInfoType.Item();
prop1.setKey("mykey1");
prop1.setValue("myValue1");
ciType.getItem().add(prop1);
CustomInfoType.Item prop2 = new CustomInfoType.Item();
prop2.setKey("mykey2");
prop2.setValue("myValue2");
ciType.getItem().add(prop2);
eventType.setCustomInfo(ciType);
MessageInfoType mit = new MessageInfoType();
mit.setFlowId("uuid");
eventType.setMessageInfo(mit);
events.add(eventType);
String result = monitoringService.putEvents(events);
Assert.assertEquals("success", result);
long id = jdbcTemplate.queryForObject("select id from EVENTS", Long.class);
Event readEvent = eventRepository.readEvent(id);
Assert.assertEquals(EventTypeEnum.REQ_OUT, readEvent.getEventType());
Map<String, String> customInfo = readEvent.getCustomInfo();
Assert.assertEquals("myValue1", customInfo.get("mykey1"));
Assert.assertEquals("myValue2", customInfo.get("mykey2"));
}
use of org.talend.esb.sam.common.event.Event in project tesb-rt-se by Talend.
the class MonitoringServiceImplTest method testWritingSeveralEvents.
// @Before
// public void setUp() throws Exception {
// executeSqlScript("create.sql", true);
// }
@Test
public void testWritingSeveralEvents() {
List<Event> events = new ArrayList<Event>();
events.add(generateEvent());
events.add(generateEvent());
events.add(generateEvent());
monitoringSerivce.putEvents(events);
for (Event event : events) {
EventRowMapper rowMapper = new EventRowMapper();
Event loaded = jdbcTemplate.queryForObject("select * from EVENTS where ID=?", rowMapper, event.getPersistedId());
Assert.assertNotNull(loaded);
Assert.assertEquals(event.getPersistedId(), loaded.getPersistedId());
}
}
use of org.talend.esb.sam.common.event.Event in project tesb-rt-se by Talend.
the class SamRestServiceImplTest method writeEventtoDb.
private Event writeEventtoDb(String flowId, EventTypeEnum eventType) {
Event e = new Event();
Date ts = new Date();
e.setTimestamp(ts);
e.setEventType(eventType);
Originator orig = new Originator("pid1", "127.0.0.1", "localhost", "custom_id1", "principal1");
e.setOriginator(orig);
MessageInfo mi = new MessageInfo("mid1", flowId, "portType_1", "seekBook", "HTTP");
e.setMessageInfo(mi);
e.setContentCut(false);
e.setContent("<seekBook>Survival in the Arctic</seekBook>");
e.getCustomInfo().put("key1", "value1");
e.getCustomInfo().put("key2", "value2");
eventRepository.writeEvent(e);
return e;
}
use of org.talend.esb.sam.common.event.Event in project tesb-rt-se by Talend.
the class MonitoringServiceImpl method putEvents.
/**
* Executes all event manipulating handler and writes the event with persist
* handler.
*
* @param events the events
*/
public void putEvents(List<Event> events) {
List<Event> filteredEvents = filterEvents(events);
executeHandlers(filteredEvents);
for (Event event : filteredEvents) {
persistenceHandler.writeEvent(event);
}
}
Aggregations