use of org.eclipse.bpmn2.Message in project bgpcep by opendaylight.
the class UtilTest method testCreateErrorMessageWithOpen.
@Test
public void testCreateErrorMessageWithOpen() {
final Message msg = Util.createErrorMessage(PCEPErrors.BAD_LABEL_VALUE, OPEN);
Assert.assertTrue(msg instanceof Pcerr);
final Pcerr errMsg = (Pcerr) msg;
Assert.assertTrue(errMsg.getPcerrMessage().getErrorType() instanceof SessionCase);
final SessionCase sessionCase = (SessionCase) errMsg.getPcerrMessage().getErrorType();
Assert.assertEquals(OPEN, sessionCase.getSession().getOpen());
final ErrorObject errorObject = errMsg.getPcerrMessage().getErrors().get(0).getErrorObject();
Assert.assertEquals(PCEPErrors.BAD_LABEL_VALUE.getErrorType(), errorObject.getType().shortValue());
Assert.assertEquals(PCEPErrors.BAD_LABEL_VALUE.getErrorValue(), errorObject.getValue().shortValue());
}
use of org.eclipse.bpmn2.Message in project bgpcep by opendaylight.
the class PCCMockCommon method checkResyncSession.
static void checkResyncSession(final Optional<Integer> startAtNumberLsp, final int expectedNumberOfLsp, final int expectedTotalMessages, final BigInteger startingDBVersion, final BigInteger expectedDBVersion, final TestingSessionListener pceSessionListener) throws Exception {
assertNotNull(pceSessionListener.getSession());
assertTrue(pceSessionListener.isUp());
final List<Message> messages;
checkReceivedMessages(pceSessionListener, expectedTotalMessages);
if (startAtNumberLsp.isPresent()) {
messages = pceSessionListener.messages().subList(startAtNumberLsp.get(), startAtNumberLsp.get() + expectedNumberOfLsp);
} else {
messages = pceSessionListener.messages();
}
checkEquals(() -> checkSequequenceDBVersionSync(pceSessionListener, expectedDBVersion));
assertEquals(expectedNumberOfLsp, messages.size());
final PCEPSession session = pceSessionListener.getSession();
checkSession(session, DEAD_TIMER, KEEP_ALIVE);
assertTrue(session.getRemoteTlvs().getAugmentation(Tlvs1.class).getStateful().getAugmentation(Stateful1.class).isInitiation());
final BigInteger pceDBVersion = session.getLocalTlvs().getAugmentation(Tlvs3.class).getLspDbVersion().getLspDbVersionValue();
assertEquals(startingDBVersion, pceDBVersion);
}
use of org.eclipse.bpmn2.Message in project bgpcep by opendaylight.
the class Stateful07TopologySessionListenerTest method testOnErrorMessage.
@Test
public void testOnErrorMessage() throws InterruptedException, ExecutionException {
final Message errorMsg = MsgBuilderUtil.createErrorMsg(PCEPErrors.NON_ZERO_PLSPID, 1L);
this.listener.onSessionUp(this.session);
final Future<RpcResult<AddLspOutput>> futureOutput = this.topologyRpcs.addLsp(createAddLspInput());
this.listener.onMessage(this.session, errorMsg);
final AddLspOutput output = futureOutput.get().getResult();
assertEquals(FailureType.Failed, output.getFailure());
assertEquals(1, output.getError().size());
final ErrorObject err = output.getError().get(0).getErrorObject();
assertEquals(PCEPErrors.NON_ZERO_PLSPID.getErrorType(), err.getType().shortValue());
assertEquals(PCEPErrors.NON_ZERO_PLSPID.getErrorValue(), err.getValue().shortValue());
}
use of org.eclipse.bpmn2.Message in project bgpcep by opendaylight.
the class Stateful07TopologySessionListenerTest method testOnUnhandledErrorMessage.
@Test
public void testOnUnhandledErrorMessage() {
final Message errorMsg = AbstractMessageParser.createErrorMsg(PCEPErrors.NON_ZERO_PLSPID, Optional.absent());
this.listener.onSessionUp(this.session);
assertTrue(this.listener.onMessage(Optional.<AbstractTopologySessionListener.MessageContext>absent().orNull(), errorMsg));
}
use of org.eclipse.bpmn2.Message in project bgpcep by opendaylight.
the class AbstractMessageParserTest method testParseVendorInformationObject.
@Test
public void testParseVendorInformationObject() throws PCEPDeserializerException {
final Abs parser = new Abs(this.registry);
final ByteBuf buffer = Unpooled.buffer();
parser.serializeVendorInformationObjects(Lists.newArrayList(this.viObject), buffer);
Mockito.verify(this.registry, Mockito.only()).serializeVendorInformationObject(Mockito.any(VendorInformationObject.class), Mockito.any(ByteBuf.class));
final Message msg = parser.parseMessage(Unpooled.wrappedBuffer(new byte[] { 0x22, 0x13, 0x00, 0x08, 0, 0, 0, 0 }), Collections.emptyList());
assertEquals(this.viObject, ((Pcrep) msg).getPcrepMessage().getReplies().get(0).getVendorInformationObject().get(0));
}
Aggregations