Bug-730: Utils' private constructor tests. 87/10987/1
authorMilos Fabian <milfabia@cisco.com>
Wed, 10 Sep 2014 07:32:11 +0000 (09:32 +0200)
committerMilos Fabian <milfabia@cisco.com>
Wed, 10 Sep 2014 11:02:42 +0000 (13:02 +0200)
Change-Id: I36b11c115fdf9496f23fba03d3108d5ac759085a
Signed-off-by: Milos Fabian <milfabia@cisco.com>
19 files changed:
bgp/concepts/src/test/java/org/opendaylight/bgp/concepts/NextHopUtilTest.java
bgp/linkstate/src/test/java/org/opendaylight/protocol/bgp/linkstate/TlvCodeTest.java [new file with mode: 0644]
bgp/parser-api/src/test/java/org/opendaylight/protocol/bgp/parser/APITest.java
bgp/parser-spi/src/test/java/org/opendaylight/protocol/bgp/parser/spi/UtilsTest.java
bgp/parser-spi/src/test/java/org/opendaylight/protocol/bgp/parser/spi/pojo/ServiceLoaderBGPExtensionProviderContextTest.java [new file with mode: 0644]
bgp/util/src/test/java/org/opendaylight/protocol/bgp/util/BGPBinaryFileParserTest.java
bgp/util/src/test/java/org/opendaylight/protocol/bgp/util/BGPHexFileParserTest.java
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/UtilTest.java [new file with mode: 0644]
pcep/pcc-mock/src/test/java/org/opendaylight/protocol/pcep/pcc/mock/PCCMockTest.java
pcep/segment-routing/src/main/java/org/opendaylight/protocol/pcep/segment/routing02/SrEroUtil.java
pcep/segment-routing/src/test/java/org/opendaylight/protocol/pcep/segment/routing02/SrEroUtilTest.java [new file with mode: 0644]
pcep/spi/src/test/java/org/opendaylight/protocol/pcep/spi/UtilsTest.java
programming/api/src/test/java/org/opendaylight/bgpcep/programming/NanotimeUtilTest.java
util/src/test/java/org/opendaylight/protocol/util/ByteArrayTest.java
util/src/test/java/org/opendaylight/protocol/util/ByteBufWriteUtilTest.java
util/src/test/java/org/opendaylight/protocol/util/IPAddressesAndPrefixesTest.java
util/src/test/java/org/opendaylight/protocol/util/NoopReferenceCacheTest.java [new file with mode: 0644]
util/src/test/java/org/opendaylight/protocol/util/PCEPHexDumpParserTest.java
util/src/test/java/org/opendaylight/protocol/util/ValuesTest.java [new file with mode: 0644]

index 1177875fdad72d45e5aa9389282914a7359f0d22..59ae824069b44a1a83d8c0fc7504291ac6093e35 100644 (file)
@@ -14,6 +14,8 @@ import static org.junit.Assert.fail;
 
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
 import org.junit.Test;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
@@ -109,4 +111,15 @@ public class NextHopUtilTest {
             assertEquals("Cannot parse NEXT_HOP attribute. Wrong bytes length: 3", e.getMessage());
         }
     }
+
+    @Test(expected=UnsupportedOperationException.class)
+    public void testPrivateConstructor() throws Throwable {
+        final Constructor<NextHopUtil> c = NextHopUtil.class.getDeclaredConstructor();
+        c.setAccessible(true);
+        try {
+            c.newInstance();
+        } catch (InvocationTargetException e) {
+            throw e.getCause();
+        }
+    }
 }
diff --git a/bgp/linkstate/src/test/java/org/opendaylight/protocol/bgp/linkstate/TlvCodeTest.java b/bgp/linkstate/src/test/java/org/opendaylight/protocol/bgp/linkstate/TlvCodeTest.java
new file mode 100644 (file)
index 0000000..d91c28a
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.protocol.bgp.linkstate;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import org.junit.Test;
+
+public class TlvCodeTest {
+
+    @Test(expected=UnsupportedOperationException.class)
+    public void testPrivateConstructor() throws Throwable {
+        final Constructor<TlvCode> c = TlvCode.class.getDeclaredConstructor();
+        c.setAccessible(true);
+        try {
+            c.newInstance();
+        } catch (InvocationTargetException e) {
+            throw e.getCause();
+        }
+    }
+
+}
index f30fb8a0578f49e3452020601c575e4e77644cc2..0533a0d3850eddae7eeddd09763893a7e27ed54a 100644 (file)
@@ -9,9 +9,10 @@ package org.opendaylight.protocol.bgp.parser;
 
 import static org.junit.Assert.assertEquals;
 
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.List;
-
 import org.junit.Test;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
@@ -61,4 +62,15 @@ public class APITest {
         final Open open2 = new OpenBuilder().setMyAsNumber(10).build();
         assertEquals(10, AsNumberUtil.advertizedAsNumber(open2).getValue().intValue());
     }
+
+    @Test(expected=UnsupportedOperationException.class)
+    public void testAsNumberUtilPrivateConstructor() throws Throwable {
+        final Constructor<AsNumberUtil> c = AsNumberUtil.class.getDeclaredConstructor();
+        c.setAccessible(true);
+        try {
+            c.newInstance();
+        } catch (InvocationTargetException e) {
+            throw e.getCause();
+        }
+    }
 }
index 6d72e8b4420d17417e972294f1de0ca98771cc0a..f570de1a71e6c057153f82d8dd4a5ae26d405c9f 100644 (file)
@@ -10,12 +10,11 @@ package org.opendaylight.protocol.bgp.parser.spi;
 import static org.junit.Assert.assertArrayEquals;
 
 import com.google.common.primitives.UnsignedBytes;
-
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
-
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
 import java.util.Arrays;
-
 import org.junit.Test;
 import org.opendaylight.protocol.util.ByteArray;
 
@@ -68,4 +67,48 @@ public class UtilsTest {
         AttributeUtil.formatAttribute(AttributeUtil.TRANSITIVE , 3 , Unpooled.wrappedBuffer(value), aggregator);
         assertArrayEquals(result, ByteArray.getAllBytes(aggregator));
     }
+
+    @Test(expected=UnsupportedOperationException.class)
+    public void testAttributeUtilPrivateConstructor() throws Throwable {
+        final Constructor<AttributeUtil> c = AttributeUtil.class.getDeclaredConstructor();
+        c.setAccessible(true);
+        try {
+            c.newInstance();
+        } catch (InvocationTargetException e) {
+            throw e.getCause();
+        }
+    }
+
+    @Test(expected=UnsupportedOperationException.class)
+    public void testCapabilityUtilPrivateConstructor() throws Throwable {
+        final Constructor<CapabilityUtil> c = CapabilityUtil.class.getDeclaredConstructor();
+        c.setAccessible(true);
+        try {
+            c.newInstance();
+        } catch (InvocationTargetException e) {
+            throw e.getCause();
+        }
+    }
+
+    @Test(expected=UnsupportedOperationException.class)
+    public void testMessageUtilPrivateConstructor() throws Throwable {
+        final Constructor<MessageUtil> c = MessageUtil.class.getDeclaredConstructor();
+        c.setAccessible(true);
+        try {
+            c.newInstance();
+        } catch (InvocationTargetException e) {
+            throw e.getCause();
+        }
+    }
+
+    @Test(expected=UnsupportedOperationException.class)
+    public void testParameterUtilPrivateConstructor() throws Throwable {
+        final Constructor<ParameterUtil> c = ParameterUtil.class.getDeclaredConstructor();
+        c.setAccessible(true);
+        try {
+            c.newInstance();
+        } catch (InvocationTargetException e) {
+            throw e.getCause();
+        }
+    }
 }
diff --git a/bgp/parser-spi/src/test/java/org/opendaylight/protocol/bgp/parser/spi/pojo/ServiceLoaderBGPExtensionProviderContextTest.java b/bgp/parser-spi/src/test/java/org/opendaylight/protocol/bgp/parser/spi/pojo/ServiceLoaderBGPExtensionProviderContextTest.java
new file mode 100644 (file)
index 0000000..4ea8112
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.protocol.bgp.parser.spi.pojo;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import org.junit.Test;
+
+public class ServiceLoaderBGPExtensionProviderContextTest {
+
+    @Test(expected=UnsupportedOperationException.class)
+    public void testPrivateConstructor() throws Throwable {
+        final Constructor<ServiceLoaderBGPExtensionProviderContext> c = ServiceLoaderBGPExtensionProviderContext.class.getDeclaredConstructor();
+        c.setAccessible(true);
+        try {
+            c.newInstance();
+        } catch (InvocationTargetException e) {
+            throw e.getCause();
+        }
+    }
+}
index 4f010b7af767ffdd88c231079da6261c771659f7..ee0703b336a51c41aa0f8b2816d6fdd5bac2dfa2 100644 (file)
@@ -15,8 +15,9 @@ import static org.junit.Assert.assertThat;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
 import java.util.List;
-
 import org.junit.Test;
 
 public class BGPBinaryFileParserTest {
@@ -80,4 +81,15 @@ public class BGPBinaryFileParserTest {
         assertEquals(42, parsedMessages.size());
     }
 
+    @Test(expected=UnsupportedOperationException.class)
+    public void testPrivateConstructor() throws Throwable {
+        final Constructor<BinaryBGPDumpFileParser> c = BinaryBGPDumpFileParser.class.getDeclaredConstructor();
+        c.setAccessible(true);
+        try {
+            c.newInstance();
+        } catch (InvocationTargetException e) {
+            throw e.getCause();
+        }
+    }
+
 }
index e8c4105bbae8878b8ad3442bf6d61a7794243c64..ae4e0a71f8e6bac9140ddd096482c72e743ef3dd 100644 (file)
@@ -14,6 +14,8 @@ import static org.junit.matchers.JUnitMatchers.containsString;
 
 import java.io.File;
 import java.io.FileNotFoundException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
 import java.util.List;
 import org.junit.Test;
 
@@ -56,4 +58,15 @@ public class BGPHexFileParserTest {
         }
     }
 
+    @Test(expected=UnsupportedOperationException.class)
+    public void testPrivateConstructor() throws Throwable {
+        final Constructor<HexDumpBGPFileParser> c = HexDumpBGPFileParser.class.getDeclaredConstructor();
+        c.setAccessible(true);
+        try {
+            c.newInstance();
+        } catch (InvocationTargetException e) {
+            throw e.getCause();
+        }
+    }
+
 }
diff --git a/pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/UtilTest.java b/pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/UtilTest.java
new file mode 100644 (file)
index 0000000..4798320
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.protocol.pcep.impl;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.protocol.pcep.spi.PCEPErrors;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Pcerr;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcep.error.object.ErrorObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.error.type.SessionCase;
+
+public class UtilTest {
+
+    private static final Open OPEN = new OpenBuilder().build();
+
+    @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());
+    }
+
+    @Test
+    public void testCreateErrorMessage() {
+        final Message msg = Util.createErrorMessage(PCEPErrors.BAD_LABEL_VALUE, null);
+        Assert.assertTrue(msg instanceof Pcerr);
+        final Pcerr errMsg = (Pcerr) msg;
+        Assert.assertNull(errMsg.getPcerrMessage().getErrorType());
+        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());
+    }
+
+    @Test(expected=UnsupportedOperationException.class)
+    public void testPrivateConstructor() throws Throwable {
+        final Constructor<Util> c = Util.class.getDeclaredConstructor();
+        c.setAccessible(true);
+        try {
+            c.newInstance();
+        } catch (InvocationTargetException e) {
+            throw e.getCause();
+        }
+    }
+
+}
index 7937654025bd0d570583f3261416c4cb1cab1b19..7fb0b8629e41bc7dbc0ae33374a86cadcfd693df 100644 (file)
@@ -1,6 +1,16 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
 package org.opendaylight.protocol.pcep.pcc.mock;
 
 import io.netty.buffer.Unpooled;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
 import junit.framework.Assert;
 import org.junit.Test;
 import org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl;
@@ -38,4 +48,15 @@ public class PCCMockTest {
         Assert.assertEquals(srp, parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.wrappedBuffer(bytes)));
     }
 
+    @Test(expected=UnsupportedOperationException.class)
+    public void testPrivateConstructor() throws Throwable {
+        final Constructor<MsgBuilderUtil> c = MsgBuilderUtil.class.getDeclaredConstructor();
+        c.setAccessible(true);
+        try {
+            c.newInstance();
+        } catch (InvocationTargetException e) {
+            throw e.getCause();
+        }
+    }
+
 }
index 41d31a694f7ca955c15ab5a3dc5f44e595d7cc76..0ad19fac3074b8a423373e510c880c6979315637 100644 (file)
@@ -63,7 +63,7 @@ public final class SrEroUtil {
     }
 
     protected static Srp addSRPathSetupTypeTlv(final Srp srp) {
-        return new SrpBuilder(srp).setTlvs(new TlvsBuilder(srp.getTlvs()).addAugmentation(Tlvs5.class,
+        return new SrpBuilder(srp).setTlvs(new TlvsBuilder(srp.getTlvs() != null ? srp.getTlvs() : new TlvsBuilder().build()).addAugmentation(Tlvs5.class,
                 new Tlvs5Builder().setPathSetupType(new PathSetupTypeBuilder().setPst(true).build()).build()).build()).build();
     }
 
diff --git a/pcep/segment-routing/src/test/java/org/opendaylight/protocol/pcep/segment/routing02/SrEroUtilTest.java b/pcep/segment-routing/src/test/java/org/opendaylight/protocol/pcep/segment/routing02/SrEroUtilTest.java
new file mode 100644 (file)
index 0000000..416e58f
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.protocol.pcep.segment.routing02;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import junit.framework.Assert;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.Srp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.SrpBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs5;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs5Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.path.setup.type.tlv.PathSetupTypeBuilder;
+
+public class SrEroUtilTest {
+
+    @Test(expected=UnsupportedOperationException.class)
+    public void testPrivateConstructor() throws Throwable {
+        final Constructor<SrEroUtil> c = SrEroUtil.class.getDeclaredConstructor();
+        c.setAccessible(true);
+        try {
+            c.newInstance();
+        } catch (InvocationTargetException e) {
+            throw e.getCause();
+        }
+    }
+
+    @Test
+    public void testAddSRPathSetupTypeTlv() {
+        final SrpBuilder srpBuilder = new SrpBuilder();
+        final Srp srp = SrEroUtil.addSRPathSetupTypeTlv(srpBuilder.build());
+        Assert.assertTrue(srp.getTlvs().getAugmentation(Tlvs5.class).getPathSetupType().isPst());
+    }
+
+    @Test
+    public void testIsPst() {
+        Assert.assertTrue(SrEroUtil.isPst(new Tlvs5Builder().setPathSetupType(new PathSetupTypeBuilder().setPst(true).build()).build()));
+        Assert.assertFalse(SrEroUtil.isPst(new Tlvs5Builder().setPathSetupType(new PathSetupTypeBuilder().setPst(false).build()).build()));
+        Assert.assertFalse(SrEroUtil.isPst(null));
+        Assert.assertFalse(SrEroUtil.isPst(new Tlvs5Builder().build()));
+    }
+}
index db37a86affd0199f69c245682821b5113395b592..ad05acf8623b92dd967928e3e45ccdfa4f9f4ae7 100644 (file)
@@ -13,6 +13,8 @@ import static org.junit.Assert.assertTrue;
 
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
 import org.junit.Test;
 import org.opendaylight.protocol.util.ByteArray;
 
@@ -120,4 +122,103 @@ public class UtilsTest {
         assertFalse(VendorInformationUtil.isVendorInformationObject(VendorInformationUtil.VENDOR_INFORMATION_TLV_TYPE, VendorInformationUtil.VENDOR_INFORMATION_OBJECT_TYPE));
         assertFalse(VendorInformationUtil.isVendorInformationObject(VendorInformationUtil.VENDOR_INFORMATION_OBJECT_TYPE, VendorInformationUtil.VENDOR_INFORMATION_OBJECT_CLASS));
     }
+
+    @Test(expected=UnsupportedOperationException.class)
+    public void testVendorInformationUtilPrivateConstructor() throws Throwable {
+        final Constructor<VendorInformationUtil> c = VendorInformationUtil.class.getDeclaredConstructor();
+        c.setAccessible(true);
+        try {
+            c.newInstance();
+        } catch (InvocationTargetException e) {
+            throw e.getCause();
+        }
+    }
+
+    @Test(expected=UnsupportedOperationException.class)
+    public void testEROSubobjectUtilPrivateConstructor() throws Throwable {
+        final Constructor<EROSubobjectUtil> c = EROSubobjectUtil.class.getDeclaredConstructor();
+        c.setAccessible(true);
+        try {
+            c.newInstance();
+        } catch (InvocationTargetException e) {
+            throw e.getCause();
+        }
+    }
+
+    @Test(expected=UnsupportedOperationException.class)
+    public void testRROSubobjectUtilPrivateConstructor() throws Throwable {
+        final Constructor<RROSubobjectUtil> c = RROSubobjectUtil.class.getDeclaredConstructor();
+        c.setAccessible(true);
+        try {
+            c.newInstance();
+        } catch (InvocationTargetException e) {
+            throw e.getCause();
+        }
+    }
+
+    @Test(expected=UnsupportedOperationException.class)
+    public void testTlvUtilPrivateConstructor() throws Throwable {
+        final Constructor<TlvUtil> c = TlvUtil.class.getDeclaredConstructor();
+        c.setAccessible(true);
+        try {
+            c.newInstance();
+        } catch (InvocationTargetException e) {
+            throw e.getCause();
+        }
+    }
+
+    @Test(expected=UnsupportedOperationException.class)
+    public void testXROSubobjectUtilPrivateConstructor() throws Throwable {
+        final Constructor<XROSubobjectUtil> c = XROSubobjectUtil.class.getDeclaredConstructor();
+        c.setAccessible(true);
+        try {
+            c.newInstance();
+        } catch (InvocationTargetException e) {
+            throw e.getCause();
+        }
+    }
+
+    @Test(expected=UnsupportedOperationException.class)
+    public void testObjectUtilPrivateConstructor() throws Throwable {
+        final Constructor<ObjectUtil> c = ObjectUtil.class.getDeclaredConstructor();
+        c.setAccessible(true);
+        try {
+            c.newInstance();
+        } catch (InvocationTargetException e) {
+            throw e.getCause();
+        }
+    }
+
+    @Test(expected=UnsupportedOperationException.class)
+    public void testMessageUtilPrivateConstructor() throws Throwable {
+        final Constructor<MessageUtil> c = MessageUtil.class.getDeclaredConstructor();
+        c.setAccessible(true);
+        try {
+            c.newInstance();
+        } catch (InvocationTargetException e) {
+            throw e.getCause();
+        }
+    }
+
+    @Test(expected=UnsupportedOperationException.class)
+    public void testLabelUtilPrivateConstructor() throws Throwable {
+        final Constructor<LabelUtil> c = LabelUtil.class.getDeclaredConstructor();
+        c.setAccessible(true);
+        try {
+            c.newInstance();
+        } catch (InvocationTargetException e) {
+            throw e.getCause();
+        }
+    }
+
+    @Test(expected=UnsupportedOperationException.class)
+    public void testPCEPMessageConstantsPrivateConstructor() throws Throwable {
+        final Constructor<PCEPMessageConstants> c = PCEPMessageConstants.class.getDeclaredConstructor();
+        c.setAccessible(true);
+        try {
+            c.newInstance();
+        } catch (InvocationTargetException e) {
+            throw e.getCause();
+        }
+    }
 }
index 9956983749bcff0c4e49ad7322ada4e5add8bff6..8a83d5b024ced6f6085c3fd31391d9938fa5cac5 100644 (file)
@@ -9,8 +9,9 @@ package org.opendaylight.bgpcep.programming;
 
 import static org.junit.Assert.assertTrue;
 
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
 import java.math.BigInteger;
-
 import org.junit.Test;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev130930.Nanotime;
 import org.slf4j.Logger;
@@ -34,4 +35,15 @@ public class NanotimeUtilTest {
         LOG.debug("Times: {} {}", nt1, nt2);
         assertTrue(nt1.getValue().compareTo(nt2.getValue()) < 0);
     }
+
+    @Test(expected=UnsupportedOperationException.class)
+    public void testPrivateConstructor() throws Throwable {
+        final Constructor<NanotimeUtil> c = NanotimeUtil.class.getDeclaredConstructor();
+        c.setAccessible(true);
+        try {
+            c.newInstance();
+        } catch (InvocationTargetException e) {
+            throw e.getCause();
+        }
+    }
 }
index 04637bde91f68dea196bb62cec3e86a064e95e32..046785c76ac1250b80a4b09987217ef9d54d345c 100644 (file)
@@ -12,16 +12,17 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotSame;
 import static org.junit.Assert.assertTrue;
+
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
-
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
 import java.util.Arrays;
 import java.util.BitSet;
-
 import org.junit.Before;
 import org.junit.Test;
 
@@ -405,4 +406,15 @@ public class ByteArrayTest {
         assertArrayEquals(new byte[] { (byte) 0xAC, (byte) 0x80, 0, 0 }, ByteArray.maskBytes(bytes, 10));
     }
 
+    @Test(expected=UnsupportedOperationException.class)
+    public void testPrivateConstructor() throws Throwable {
+        final Constructor<ByteArray> c = ByteArray.class.getDeclaredConstructor();
+        c.setAccessible(true);
+        try {
+            c.newInstance();
+        } catch (InvocationTargetException e) {
+            throw e.getCause();
+        }
+    }
+
 }
index d7b98c8f13cb638b712cf973078d2f8faf66696c..1a662bc81c6f11eed5215f0e70604dd5b05524cd 100644 (file)
@@ -27,6 +27,8 @@ import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedShort
 
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
 import java.math.BigInteger;
 import java.util.BitSet;
 import org.junit.Test;
@@ -233,4 +235,15 @@ public class ByteBufWriteUtilTest {
         writeBitSet(null, 1, output);
         assertArrayEquals(ONE_BYTE_ZERO, output.array());
     }
+
+    @Test(expected=UnsupportedOperationException.class)
+    public void testPrivateConstructor() throws Throwable {
+        final Constructor<ByteBufWriteUtil> c = ByteBufWriteUtil.class.getDeclaredConstructor();
+        c.setAccessible(true);
+        try {
+            c.newInstance();
+        } catch (InvocationTargetException e) {
+            throw e.getCause();
+        }
+    }
 }
index 5866c6c48d7b626ecd774a4dd8309a71d095e872..95cca2e26d937fc1abc6f4ae544604e211dba7cf 100644 (file)
@@ -15,6 +15,8 @@ import static org.junit.Assert.fail;
 import com.google.common.collect.Lists;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
 import java.net.UnknownHostException;
 import java.util.List;
 import org.junit.Test;
@@ -144,4 +146,26 @@ public class IPAddressesAndPrefixesTest {
         final List<Ipv6Prefix> prefs = Ipv6Util.prefixListForBytes(bytes);
         assertEquals(prefs, Lists.newArrayList(new Ipv6Prefix("2001:db8:1:2::/64"), new Ipv6Prefix("2001:db8:1:1::/64")));
     }
+
+    @Test(expected=UnsupportedOperationException.class)
+    public void testIpv4UtilPrivateConstructor() throws Throwable {
+        final Constructor<Ipv4Util> c = Ipv4Util.class.getDeclaredConstructor();
+        c.setAccessible(true);
+        try {
+            c.newInstance();
+        } catch (InvocationTargetException e) {
+            throw e.getCause();
+        }
+    }
+
+    @Test(expected=UnsupportedOperationException.class)
+    public void testIpv6UtilPrivateConstructor() throws Throwable {
+        final Constructor<Ipv6Util> c = Ipv6Util.class.getDeclaredConstructor();
+        c.setAccessible(true);
+        try {
+            c.newInstance();
+        } catch (InvocationTargetException e) {
+            throw e.getCause();
+        }
+    }
 }
diff --git a/util/src/test/java/org/opendaylight/protocol/util/NoopReferenceCacheTest.java b/util/src/test/java/org/opendaylight/protocol/util/NoopReferenceCacheTest.java
new file mode 100644 (file)
index 0000000..038d143
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.protocol.util;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class NoopReferenceCacheTest {
+
+    private static final Object OBJ = new Object();
+
+    @Test
+    public void testSharedReference() {
+        Assert.assertEquals(OBJ, NoopReferenceCache.getInstance().getSharedReference(OBJ));
+    }
+}
index 7e0084a20692edabc56e861779101d95e646098f..23de4015053811255273053f9e8369cda3fb80c1 100644 (file)
@@ -14,6 +14,8 @@ import static org.junit.matchers.JUnitMatchers.containsString;
 
 import java.io.File;
 import java.io.FileNotFoundException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
 import java.util.List;
 import org.junit.Test;
 
@@ -26,10 +28,10 @@ public class PCEPHexDumpParserTest {
     public void testParsing() throws Exception {
         final List<byte[]> result = PCEPHexDumpParser.parseMessages(getClass().getClassLoader().getResourceAsStream(
             PCEPHexDumpParserTest.hexDumpFileName));
-        assertEquals(this.expectedSize, result.size());
+        assertEquals(expectedSize, result.size());
         final List<byte[]> result1 = PCEPHexDumpParser.parseMessages(new File(getClass().getClassLoader().getResource(
             PCEPHexDumpParserTest.hexDumpFileName).toURI()));
-        assertEquals(this.expectedSize, result1.size());
+        assertEquals(expectedSize, result1.size());
     }
 
     @Test
@@ -41,4 +43,15 @@ public class PCEPHexDumpParserTest {
             assertThat(e.getMessage(), containsString("bad file name"));
         }
     }
+
+    @Test(expected=UnsupportedOperationException.class)
+    public void testPrivateConstructor() throws Throwable {
+        final Constructor<PCEPHexDumpParser> c = PCEPHexDumpParser.class.getDeclaredConstructor();
+        c.setAccessible(true);
+        try {
+            c.newInstance();
+        } catch (InvocationTargetException e) {
+            throw e.getCause();
+        }
+    }
 }
diff --git a/util/src/test/java/org/opendaylight/protocol/util/ValuesTest.java b/util/src/test/java/org/opendaylight/protocol/util/ValuesTest.java
new file mode 100644 (file)
index 0000000..a911dff
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.protocol.util;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import org.junit.Test;
+
+public class ValuesTest {
+
+    @Test(expected=UnsupportedOperationException.class)
+    public void testPrivateConstructor() throws Throwable {
+        final Constructor<Values> c = Values.class.getDeclaredConstructor();
+        c.setAccessible(true);
+        try {
+            c.newInstance();
+        } catch (InvocationTargetException e) {
+            throw e.getCause();
+        }
+    }
+}