Replaced reference from deprecated junit.framework.Assert to org.junit.Assert
[bgpcep.git] / pcep / pcc-mock / src / test / java / org / opendaylight / protocol / pcep / pcc / mock / PCCMockTest.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.protocol.pcep.pcc.mock;
10
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;
24
25
26
27 public class PCCMockTest {
28
29     @Test
30     public void testSessionEstablishment() {
31         try {
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) {
35             Assert.fail();
36         }
37     }
38
39     @Test
40     public void testSrpObjectParser() throws PCEPDeserializerException {
41         final byte[] bytes = {
42             0x00, 0x00, 0x00, 0x00,
43             0x00, 0x00, 0x00, 0x00,
44         };
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)));
49     }
50
51     @Test(expected=UnsupportedOperationException.class)
52     public void testPrivateConstructor() throws Throwable {
53         final Constructor<MsgBuilderUtil> c = MsgBuilderUtil.class.getDeclaredConstructor();
54         c.setAccessible(true);
55         try {
56             c.newInstance();
57         } catch (InvocationTargetException e) {
58             throw e.getCause();
59         }
60     }
61
62 }