Search in sources :

Example 21 with Message

use of org.openkilda.messaging.Message in project open-kilda by telstra.

the class AbstractSerializerTest method flowCreateRequestTest.

@Test
public void flowCreateRequestTest() throws IOException, ClassNotFoundException {
    FlowCreateRequest data = new FlowCreateRequest(flowModel);
    System.out.println(data);
    CommandMessage command = new CommandMessage(data, System.currentTimeMillis(), CORRELATION_ID, DESTINATION);
    serialize(command);
    Message message = (Message) deserialize();
    assertTrue(message instanceof CommandMessage);
    CommandMessage resultCommand = (CommandMessage) message;
    assertTrue(resultCommand.getData() instanceof FlowCreateRequest);
    FlowCreateRequest resultData = (FlowCreateRequest) resultCommand.getData();
    System.out.println(resultData);
    assertEquals(data, resultData);
    assertEquals(data.hashCode(), resultData.hashCode());
    assertEquals(flowModel.hashCode(), resultData.getPayload().hashCode());
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) CommandMessage(org.openkilda.messaging.command.CommandMessage) Test(org.junit.Test)

Example 22 with Message

use of org.openkilda.messaging.Message in project open-kilda by telstra.

the class AbstractSerializerTest method eventPathInfoTest.

@Test
public void eventPathInfoTest() throws IOException, ClassNotFoundException {
    PathInfoData data = new PathInfoData();
    System.out.println(data);
    InfoMessage info = new InfoMessage(data, System.currentTimeMillis(), CORRELATION_ID, DESTINATION);
    serialize(info);
    Message message = (Message) deserialize();
    assertTrue(message instanceof InfoMessage);
    InfoMessage resultInfo = (InfoMessage) message;
    assertTrue(resultInfo.getData() instanceof PathInfoData);
    PathInfoData resultData = (PathInfoData) resultInfo.getData();
    System.out.println(resultData);
    assertEquals(data, resultData);
    assertEquals(data.hashCode(), resultData.hashCode());
}
Also used : PathInfoData(org.openkilda.messaging.info.event.PathInfoData) InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) InfoMessage(org.openkilda.messaging.info.InfoMessage) Test(org.junit.Test)

Example 23 with Message

use of org.openkilda.messaging.Message in project open-kilda by telstra.

the class AbstractSerializerTest method flowUpdateRequestTest.

@Test
public void flowUpdateRequestTest() throws IOException, ClassNotFoundException {
    FlowUpdateRequest data = new FlowUpdateRequest(flowModel);
    System.out.println(data);
    CommandMessage command = new CommandMessage(data, System.currentTimeMillis(), CORRELATION_ID, DESTINATION);
    serialize(command);
    Message message = (Message) deserialize();
    assertTrue(message instanceof CommandMessage);
    CommandMessage resultCommand = (CommandMessage) message;
    assertTrue(resultCommand.getData() instanceof FlowUpdateRequest);
    FlowUpdateRequest resultData = (FlowUpdateRequest) resultCommand.getData();
    System.out.println(resultData);
    assertEquals(data, resultData);
    assertEquals(data.hashCode(), resultData.hashCode());
    assertEquals(flowModel.hashCode(), resultData.getPayload().hashCode());
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) CommandMessage(org.openkilda.messaging.command.CommandMessage) Test(org.junit.Test)

Example 24 with Message

use of org.openkilda.messaging.Message in project open-kilda by telstra.

the class AbstractSerializerTest method flowDeleteRequestTest.

@Test
public void flowDeleteRequestTest() throws IOException, ClassNotFoundException {
    Flow deleteFlow = new Flow();
    deleteFlow.setFlowId(flowName);
    FlowDeleteRequest data = new FlowDeleteRequest(deleteFlow);
    System.out.println(data);
    CommandMessage command = new CommandMessage(data, System.currentTimeMillis(), CORRELATION_ID, DESTINATION);
    serialize(command);
    Message message = (Message) deserialize();
    assertTrue(message instanceof CommandMessage);
    CommandMessage resultCommand = (CommandMessage) message;
    assertTrue(resultCommand.getData() instanceof FlowDeleteRequest);
    FlowDeleteRequest resultData = (FlowDeleteRequest) resultCommand.getData();
    System.out.println(resultData);
    assertEquals(data, resultData);
    assertEquals(data.hashCode(), resultData.hashCode());
    assertEquals(deleteFlow.hashCode(), resultData.getPayload().hashCode());
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) Flow(org.openkilda.messaging.model.Flow) CommandMessage(org.openkilda.messaging.command.CommandMessage) Test(org.junit.Test)

Example 25 with Message

use of org.openkilda.messaging.Message in project open-kilda by telstra.

the class AbstractSerializerTest method eventPortInfoTest.

@Test
public void eventPortInfoTest() throws IOException, ClassNotFoundException {
    PortInfoData data = new PortInfoData(SWITCH_ID, INPUT_PORT, 0, PORT_CHANGE);
    System.out.println(data);
    InfoMessage info = new InfoMessage(data, System.currentTimeMillis(), CORRELATION_ID, DESTINATION);
    serialize(info);
    Message message = (Message) deserialize();
    assertTrue(message instanceof InfoMessage);
    InfoMessage resultInfo = (InfoMessage) message;
    assertTrue(resultInfo.getData() instanceof PortInfoData);
    PortInfoData resultData = (PortInfoData) resultInfo.getData();
    System.out.println(resultData);
    assertEquals(data, resultData);
    assertEquals(data.hashCode(), resultData.hashCode());
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) InfoMessage(org.openkilda.messaging.info.InfoMessage) PortInfoData(org.openkilda.messaging.info.event.PortInfoData) Test(org.junit.Test)

Aggregations

Message (org.openkilda.messaging.Message)71 CommandMessage (org.openkilda.messaging.command.CommandMessage)55 InfoMessage (org.openkilda.messaging.info.InfoMessage)55 ErrorMessage (org.openkilda.messaging.error.ErrorMessage)29 Test (org.junit.Test)25 IOException (java.io.IOException)11 Values (org.apache.storm.tuple.Values)10 CtrlRequest (org.openkilda.messaging.ctrl.CtrlRequest)6 CtrlResponse (org.openkilda.messaging.ctrl.CtrlResponse)6 FlowIdStatusPayload (org.openkilda.messaging.payload.flow.FlowIdStatusPayload)6 CommandData (org.openkilda.messaging.command.CommandData)5 RequestData (org.openkilda.messaging.ctrl.RequestData)5 FlowResponse (org.openkilda.messaging.info.flow.FlowResponse)5 CommandWithReplyToMessage (org.openkilda.messaging.command.CommandWithReplyToMessage)4 DumpStateResponseData (org.openkilda.messaging.ctrl.DumpStateResponseData)4 IslInfoData (org.openkilda.messaging.info.event.IslInfoData)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 BaseInstallFlow (org.openkilda.messaging.command.flow.BaseInstallFlow)3 FlowCreateRequest (org.openkilda.messaging.command.flow.FlowCreateRequest)3 FlowGetRequest (org.openkilda.messaging.command.flow.FlowGetRequest)3