use of org.apache.storm.generated.HBMessage in project storm by apache.
the class PacemakerTest method testServerExistsFalse.
@Test
public void testServerExistsFalse() {
Pacemaker handler = new Pacemaker(new ConcurrentHashMap());
messageWithRandId(HBServerMessageType.EXISTS, HBMessageData.path("/testpath"));
HBMessage badResponse = handler.handleMessage(hbMessage, false);
HBMessage goodResponse = handler.handleMessage(hbMessage, true);
Assert.assertEquals(mid, badResponse.get_message_id());
Assert.assertEquals(HBServerMessageType.NOT_AUTHORIZED, badResponse.get_type());
Assert.assertEquals(mid, goodResponse.get_message_id());
Assert.assertEquals(HBServerMessageType.EXISTS_RESPONSE, goodResponse.get_type());
Assert.assertFalse(goodResponse.get_data().get_boolval());
}
use of org.apache.storm.generated.HBMessage in project storm by apache.
the class PacemakerTest method testServerExistsTrue.
@Test
public void testServerExistsTrue() {
String path = "/exists_path";
String dataString = "pulse data";
Pacemaker handler = new Pacemaker(new ConcurrentHashMap());
HBPulse hbPulse = new HBPulse();
hbPulse.set_id(path);
hbPulse.set_details(Utils.javaSerialize(dataString));
messageWithRandId(HBServerMessageType.SEND_PULSE, HBMessageData.pulse(hbPulse));
handler.handleMessage(hbMessage, true);
messageWithRandId(HBServerMessageType.EXISTS, HBMessageData.path(path));
HBMessage badResponse = handler.handleMessage(hbMessage, false);
HBMessage goodResponse = handler.handleMessage(hbMessage, true);
Assert.assertEquals(mid, badResponse.get_message_id());
Assert.assertEquals(HBServerMessageType.NOT_AUTHORIZED, badResponse.get_type());
Assert.assertEquals(mid, goodResponse.get_message_id());
Assert.assertEquals(HBServerMessageType.EXISTS_RESPONSE, goodResponse.get_type());
Assert.assertTrue(goodResponse.get_data().get_boolval());
}
use of org.apache.storm.generated.HBMessage in project storm by apache.
the class PacemakerTest method testServerSendPulseGetPulse.
@Test
public void testServerSendPulseGetPulse() {
String path = "/pulsepath";
String dataString = "pulse data";
Pacemaker handler = new Pacemaker(new ConcurrentHashMap());
HBPulse hbPulse = new HBPulse();
hbPulse.set_id(path);
hbPulse.set_details(Utils.javaSerialize(dataString));
messageWithRandId(HBServerMessageType.SEND_PULSE, HBMessageData.pulse(hbPulse));
HBMessage sendResponse = handler.handleMessage(hbMessage, true);
Assert.assertEquals(mid, sendResponse.get_message_id());
Assert.assertEquals(HBServerMessageType.SEND_PULSE_RESPONSE, sendResponse.get_type());
Assert.assertNull(sendResponse.get_data());
messageWithRandId(HBServerMessageType.GET_PULSE, HBMessageData.path(path));
HBMessage response = handler.handleMessage(hbMessage, true);
Assert.assertEquals(mid, response.get_message_id());
Assert.assertEquals(HBServerMessageType.GET_PULSE_RESPONSE, response.get_type());
Assert.assertEquals(dataString, Utils.javaDeserialize(response.get_data().get_pulse().get_details(), String.class));
}
use of org.apache.storm.generated.HBMessage in project storm by apache.
the class PacemakerTest method testServerGetAllPulseForPath.
@Test
public void testServerGetAllPulseForPath() {
Pacemaker handler = new Pacemaker(new ConcurrentHashMap());
messageWithRandId(HBServerMessageType.GET_ALL_PULSE_FOR_PATH, HBMessageData.path("/testpath"));
HBMessage badResponse = handler.handleMessage(hbMessage, false);
HBMessage goodResponse = handler.handleMessage(hbMessage, true);
Assert.assertEquals(mid, badResponse.get_message_id());
Assert.assertEquals(HBServerMessageType.NOT_AUTHORIZED, badResponse.get_type());
Assert.assertEquals(mid, goodResponse.get_message_id());
Assert.assertEquals(HBServerMessageType.GET_ALL_PULSE_FOR_PATH_RESPONSE, goodResponse.get_type());
Assert.assertNull(goodResponse.get_data());
}
use of org.apache.storm.generated.HBMessage in project storm by apache.
the class PacemakerTest method makeNode.
private HBMessage makeNode(Pacemaker handler, String path) {
HBPulse hbPulse = new HBPulse();
hbPulse.set_id(path);
hbPulse.set_details(Utils.javaSerialize("nothing"));
HBMessage message = new HBMessage(HBServerMessageType.SEND_PULSE, HBMessageData.pulse(hbPulse));
return handler.handleMessage(message, true);
}
Aggregations