Search in sources :

Example 1 with CustomInfoType

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);
}
Also used : CustomInfoType(org.talend.esb.sam._2011._03.common.CustomInfoType) EventType(org.talend.esb.sam._2011._03.common.EventType) OriginatorType(org.talend.esb.sam._2011._03.common.OriginatorType) MessageInfoType(org.talend.esb.sam._2011._03.common.MessageInfoType) Test(org.junit.Test)

Example 2 with CustomInfoType

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"));
}
Also used : EventType(org.talend.esb.sam._2011._03.common.EventType) ArrayList(java.util.ArrayList) DataHandler(javax.activation.DataHandler) URL(java.net.URL) HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) CustomInfoType(org.talend.esb.sam._2011._03.common.CustomInfoType) HTTPClientPolicy(org.apache.cxf.transports.http.configuration.HTTPClientPolicy) Event(org.talend.esb.sam.common.event.Event) Client(org.apache.cxf.endpoint.Client) MessageInfoType(org.talend.esb.sam._2011._03.common.MessageInfoType) Test(org.junit.Test)

Example 3 with CustomInfoType

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;
}
Also used : UnknownHostException(java.net.UnknownHostException) CustomInfoType(org.talend.esb.sam._2011._03.common.CustomInfoType) EventType(org.talend.esb.sam._2011._03.common.EventType) OriginatorType(org.talend.esb.sam._2011._03.common.OriginatorType) InetAddress(java.net.InetAddress) Date(java.util.Date)

Example 4 with CustomInfoType

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;
}
Also used : CustomInfoType(org.talend.esb.sam._2011._03.common.CustomInfoType)

Aggregations

CustomInfoType (org.talend.esb.sam._2011._03.common.CustomInfoType)4 EventType (org.talend.esb.sam._2011._03.common.EventType)3 Test (org.junit.Test)2 MessageInfoType (org.talend.esb.sam._2011._03.common.MessageInfoType)2 OriginatorType (org.talend.esb.sam._2011._03.common.OriginatorType)2 InetAddress (java.net.InetAddress)1 URL (java.net.URL)1 UnknownHostException (java.net.UnknownHostException)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 DataHandler (javax.activation.DataHandler)1 Client (org.apache.cxf.endpoint.Client)1 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)1 HTTPClientPolicy (org.apache.cxf.transports.http.configuration.HTTPClientPolicy)1 Event (org.talend.esb.sam.common.event.Event)1