Search in sources :

Example 56 with Message

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

the class AbstractSerializerTest method flowsGetRequestTest.

@Test
public void flowsGetRequestTest() throws IOException, ClassNotFoundException {
    FlowsGetRequest data = new FlowsGetRequest(flowsIdStatusRequest);
    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 FlowsGetRequest);
    FlowsGetRequest resultData = (FlowsGetRequest) resultCommand.getData();
    System.out.println(resultData);
    assertEquals(data, resultData);
    assertEquals(data.hashCode(), resultData.hashCode());
    assertEquals(flowsIdStatusRequest.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 57 with Message

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

the class AbstractSerializerTest method eventSwitchInfoTest.

@Test
public void eventSwitchInfoTest() throws IOException, ClassNotFoundException {
    SwitchInfoData data = new SwitchInfoData(SWITCH_ID, SWITCH_EVENT, "127.0.0.1", "localhost", "sw", "controller");
    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 SwitchInfoData);
    SwitchInfoData resultData = (SwitchInfoData) 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) SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData) Test(org.junit.Test)

Example 58 with Message

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

the class AbstractSerializerTest method removeCommandTest.

@Test
public void removeCommandTest() throws IOException, ClassNotFoundException {
    RemoveFlow data = new RemoveFlow(TIMESTAMP, FLOW_NAME, COOKIE, SWITCH_ID, METER_ID);
    System.out.println(data);
    CommandMessage command = new CommandMessage(data, System.currentTimeMillis(), CORRELATION_ID, DESTINATION);
    command.setData(data);
    serialize(command);
    Message message = (Message) deserialize();
    assertTrue(message instanceof CommandMessage);
    CommandMessage resultCommand = (CommandMessage) message;
    assertTrue(resultCommand.getData() != null);
    RemoveFlow resultData = (RemoveFlow) resultCommand.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) CommandMessage(org.openkilda.messaging.command.CommandMessage) Test(org.junit.Test)

Example 59 with Message

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

the class AbstractSerializerTest method flowResponseTest.

@Test
public void flowResponseTest() throws IOException, ClassNotFoundException {
    FlowResponse data = new FlowResponse(flowModel);
    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 FlowResponse);
    FlowResponse resultData = (FlowResponse) resultInfo.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) InfoMessage(org.openkilda.messaging.info.InfoMessage) FlowResponse(org.openkilda.messaging.info.flow.FlowResponse) Test(org.junit.Test)

Example 60 with Message

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

the class AbstractSerializerTest method dumpNetworkResponseTest.

@Test
public void dumpNetworkResponseTest() throws IOException, ClassNotFoundException {
    NetworkInfoData data = new NetworkInfoData(requester, new HashSet<>(Arrays.asList(sw1, sw2)), new HashSet<>(), Collections.singleton(isl), Collections.singleton(new ImmutablePair<>(flowModel, flowModel)));
    System.out.println(data);
    InfoMessage info = new InfoMessage(data, System.currentTimeMillis(), CORRELATION_ID, DESTINATION);
    info.setData(data);
    serialize(info);
    Message message = (Message) deserialize();
    assertTrue(message instanceof InfoMessage);
    InfoMessage resultInfo = (InfoMessage) message;
    assertTrue(resultInfo.getData() != null);
    NetworkInfoData resultData = (NetworkInfoData) resultInfo.getData();
    System.out.println(resultData);
    assertEquals(data, resultData);
    assertEquals(data.hashCode(), resultData.hashCode());
}
Also used : NetworkInfoData(org.openkilda.messaging.info.discovery.NetworkInfoData) ImmutablePair(org.openkilda.messaging.model.ImmutablePair) 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)

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