use of org.talend.esb.sam._2011._03.common.CustomInfoType in project tesb-rt-se by Talend.
the class EventTypeMapperTest method testEmpty.
/**
* Test with empty eventType parts to check for Nullpointer exceptions
*/
@Test
public void testEmpty() {
EventType eventType = new EventType();
EventTypeMapper.map(eventType);
eventType.setCustomInfo(new CustomInfoType());
EventTypeMapper.map(eventType);
eventType.setMessageInfo(new MessageInfoType());
EventTypeMapper.map(eventType);
eventType.setOriginator(new OriginatorType());
EventTypeMapper.map(eventType);
}
use of org.talend.esb.sam._2011._03.common.CustomInfoType 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._2011._03.common.CustomInfoType in project tesb-rt-se by Talend.
the class AgentActivator method createEventType.
/**
* Creates the event type.
*
* @param type the EventEnumType
* @return the event type
*/
private EventType createEventType(EventEnumType type) {
EventType eventType = new EventType();
eventType.setTimestamp(Converter.convertDate(new Date()));
eventType.setEventType(type);
OriginatorType origType = new OriginatorType();
origType.setProcessId(Converter.getPID());
try {
InetAddress inetAddress = InetAddress.getLocalHost();
origType.setIp(inetAddress.getHostAddress());
origType.setHostname(inetAddress.getHostName());
} catch (UnknownHostException e) {
origType.setHostname("Unknown hostname");
origType.setIp("Unknown ip address");
}
eventType.setOriginator(origType);
String path = System.getProperty("karaf.home");
CustomInfoType ciType = new CustomInfoType();
CustomInfoType.Item cItem = new CustomInfoType.Item();
cItem.setKey("path");
cItem.setValue(path);
ciType.getItem().add(cItem);
eventType.setCustomInfo(ciType);
return eventType;
}
use of org.talend.esb.sam._2011._03.common.CustomInfoType in project tesb-rt-se by Talend.
the class EventMapper method convertCustomInfo.
/**
* Convert custom info.
*
* @param customInfo the custom info map
* @return the custom info type
*/
private static CustomInfoType convertCustomInfo(Map<String, String> customInfo) {
if (customInfo == null) {
return null;
}
CustomInfoType ciType = new CustomInfoType();
for (Entry<String, String> entry : customInfo.entrySet()) {
CustomInfoType.Item cItem = new CustomInfoType.Item();
cItem.setKey(entry.getKey());
cItem.setValue(entry.getValue());
ciType.getItem().add(cItem);
}
return ciType;
}
Aggregations