2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.protocol.pcep.pcc.mock;
11 import io.netty.buffer.Unpooled;
12 import java.lang.reflect.Constructor;
13 import java.lang.reflect.InvocationTargetException;
14 import org.junit.Assert;
15 import org.junit.Test;
16 import org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl;
17 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
18 import org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderContext;
19 import org.opendaylight.protocol.pcep.spi.pojo.ServiceLoaderPCEPExtensionProviderContext;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.SrpIdNumber;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.Srp;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.SrpBuilder;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.srp.TlvsBuilder;
27 public class PCCMockTest {
30 public void testSessionEstablishment() {
32 org.opendaylight.protocol.pcep.testtool.Main.main(new String[]{"-a", "127.0.1.0:4189", "-ka", "10", "-d", "0", "--stateful", "--active"});
33 Main.main(new String[] {"--address", "127.0.1.0", "--pcc", "1", "--lsp", "1"});
34 } catch (Exception e) {
40 public void testSrpObjectParser() throws PCEPDeserializerException {
41 final byte[] bytes = {
42 0x00, 0x00, 0x00, 0x00,
43 0x00, 0x00, 0x00, 0x00,
45 final PCEPExtensionProviderContext ctx = ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance();
46 final PCCSrpObjectParser parser = new PCCSrpObjectParser(ctx.getTlvHandlerRegistry(), ctx.getVendorInformationTlvRegistry());
47 final Srp srp = new SrpBuilder().setIgnore(true).setProcessingRule(true).setOperationId(new SrpIdNumber(0L)).setTlvs(new TlvsBuilder().build()).build();
48 Assert.assertEquals(srp, parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.wrappedBuffer(bytes)));
51 @Test(expected=UnsupportedOperationException.class)
52 public void testPrivateConstructor() throws Throwable {
53 final Constructor<MsgBuilderUtil> c = MsgBuilderUtil.class.getDeclaredConstructor();
54 c.setAccessible(true);
57 } catch (InvocationTargetException e) {