import org.opendaylight.protocol.pcep.PCEPTlv;
import org.opendaylight.protocol.pcep.concepts.LSPSymbolicName;
import org.opendaylight.protocol.pcep.concepts.UnnumberedInterfaceIdentifier;
-import org.opendaylight.protocol.pcep.impl.PCEPMessageFactory.PCEPMessageType;
import org.opendaylight.protocol.pcep.impl.message.PCEPRawMessage;
import org.opendaylight.protocol.pcep.impl.object.UnknownObject;
import org.opendaylight.protocol.pcep.message.PCCreateMessage;
private final PCEPEndPointsObject<IPv4Address> endPoints = new PCEPEndPointsObject<IPv4Address>(this.ip4addr, this.ip4addr);
- private final PCEPMessageFactory msgFactory = new PCEPMessageFactory();
+ private static final RawPCEPMessageFactory msgFactory = new RawPCEPMessageFactory();
// private final PCEPClassTypeObject classType = new
// PCEPClassTypeObject((short) 7);
// PCEPClassTypeObjectProvider((short) 7, true);
private static List<PCEPMessage> deserMsg(final String srcFile) throws IOException, DeserializerException, DocumentedException,
- PCEPDeserializerException {
+ PCEPDeserializerException {
final byte[] bytesFromFile = ByteArray.fileToBytes(srcFile);
- final PCEPRawMessage rawMessage = (PCEPRawMessage) new PCEPMessageFactory().parse(bytesFromFile);
+ final PCEPRawMessage rawMessage = (PCEPRawMessage) msgFactory.parse(bytesFromFile).get(0);
return PCEPMessageValidator.getValidator(rawMessage.getMsgType()).validate(rawMessage.getAllObjects());
}
@Test
public void testOpenMessageValidationFromBin() throws IOException, DeserializerException, DocumentedException,
- PCEPDeserializerException {
+ PCEPDeserializerException {
assertEquals(
deserMsg("src/test/resources/PCEPOpenMessage1.bin"),
asList(new PCEPOpenMessage(new PCEPOpenObject(30, 120, 1, asList(new PCEStatefulCapabilityTlv(false, true, true),
@Test
public void testKeepAliveMessageValidationFromBin() throws IOException, PCEPDeserializerException, PCEPDocumentedException,
- DeserializerException, DocumentedException {
+ DeserializerException, DocumentedException {
assertEquals(deserMsg("src/test/resources/PCEPKeepAliveMessage1.bin"), asList(new PCEPKeepAliveMessage()));
assertEquals(deserMsg("src/test/resources/Keepalive.1.bin"), asList(new PCEPKeepAliveMessage()));
}
@Test
public void testCloseMsg() throws PCEPDeserializerException, IOException, PCEPDocumentedException, DeserializerException,
- DocumentedException {
+ DocumentedException {
assertEquals(deserMsg("src/test/resources/PCEPCloseMessage1.bin"),
asList(new PCEPCloseMessage(new PCEPCloseObject(Reason.TOO_MANY_UNKNOWN_MSG))));
assertEquals(deserMsg("src/test/resources/Close.1.bin"), asList(new PCEPCloseMessage(new PCEPCloseObject(Reason.UNKNOWN))));
@Test
public void testRequestMessageValidationFromBin() throws IOException, PCEPDeserializerException, PCEPDocumentedException,
- DeserializerException, DocumentedException {
+ DeserializerException, DocumentedException {
List<CompositeRequestObject> requests = new ArrayList<CompositeRequestObject>();
final byte[] ipAdress = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
requests.add(new CompositeRequestObject(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 5, 0xDEADBEEFL, true, false), new PCEPEndPointsObject<IPv4Address>(new IPv4Address(ipAdress), new IPv4Address(ipAdress))));
@Test
public void testReplyMessageValidatorFromBin() throws IOException, PCEPDeserializerException, PCEPDocumentedException,
- DeserializerException, DocumentedException {
+ DeserializerException, DocumentedException {
List<PCEPReplyMessage> specMessages = new ArrayList<PCEPReplyMessage>();
specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 5, 0xDEADBEEFL, true, true)))));
@Test
public void testUpdMessageValidatorFromBin() throws IOException, PCEPDeserializerException, PCEPDocumentedException,
- DeserializerException, DocumentedException {
+ DeserializerException, DocumentedException {
List<PCEPMessage> specMessages = new ArrayList<PCEPMessage>();
List<CompositeUpdateRequestObject> requests = new ArrayList<CompositeUpdateRequestObject>();
@Test
public void testRptMessageValidatorFromBin() throws IOException, PCEPDeserializerException, PCEPDocumentedException,
- DeserializerException, DocumentedException {
+ DeserializerException, DocumentedException {
List<PCEPMessage> specMessages = new ArrayList<PCEPMessage>();
List<CompositeStateReportObject> reports = new ArrayList<CompositeStateReportObject>();
reports.add(new CompositeStateReportObject(new PCEPLspObject(1, true, false, true, true)));
final PCEPXRDeleteTunnelMessage dTunnel = new PCEPXRDeleteTunnelMessage(new PCEPLspObject(1, false, true, false, true));
final byte[] bytes = this.msgFactory.put(dTunnel);
- final PCEPRawMessage rawMessage = (PCEPRawMessage) this.msgFactory.parse(bytes);
+ final PCEPRawMessage rawMessage = (PCEPRawMessage) msgFactory.parse(bytes).get(0);
assertEquals(PCEPMessageValidator.getValidator(rawMessage.getMsgType()).validate(rawMessage.getAllObjects()),
asList((PCEPMessage) dTunnel));
final PCEPXRAddTunnelMessage addTunnel = new PCEPXRAddTunnelMessage(new PCEPLspObject(1, false, false, false, false), new PCEPEndPointsObject<IPv4Address>(IPv4.FAMILY.addressForString("127.0.0.2"), IPv4.FAMILY.addressForString("127.0.0.1")), new PCEPExplicitRouteObject(subs, true));
final byte[] bytes = this.msgFactory.put(addTunnel);
- final PCEPRawMessage rawMessage = (PCEPRawMessage) this.msgFactory.parse(bytes);
+ final PCEPRawMessage rawMessage = (PCEPRawMessage) msgFactory.parse(bytes).get(0);
assertEquals(PCEPMessageValidator.getValidator(rawMessage.getMsgType()).validate(rawMessage.getAllObjects()),
asList((PCEPMessage) addTunnel));
}
final byte[] bytes = this.msgFactory.put(msg);
// FIXME: need construct with invalid processed parameter
- final PCEPRawMessage rawMessage = (PCEPRawMessage) this.msgFactory.parse(bytes);
+ final PCEPRawMessage rawMessage = (PCEPRawMessage) msgFactory.parse(bytes).get(0);
assertEquals(PCEPMessageValidator.getValidator(rawMessage.getMsgType()).validate(rawMessage.getAllObjects()),
asList((PCEPMessage) msg));
@Test
public void testNotificationValidatorFromBin() throws IOException, PCEPDeserializerException, PCEPDocumentedException,
- DeserializerException, DocumentedException {
+ DeserializerException, DocumentedException {
List<CompositeNotifyObject> notifications = new ArrayList<CompositeNotifyObject>();
List<PCEPNotificationObject> notificationsList = new ArrayList<PCEPNotificationObject>();
notificationsList.add(new PCEPNotificationObject((short) 1, (short) 1));
@Test
public void testErrorMessageValidatoinFromBin() throws IOException, PCEPDeserializerException, PCEPDocumentedException,
- DeserializerException, DocumentedException {
+ DeserializerException, DocumentedException {
List<PCEPErrorObject> errorsList = new ArrayList<PCEPErrorObject>();
errorsList.add(new PCEPErrorObject(PCEPErrors.UNRECOGNIZED_OBJ_CLASS));