From e285eedb7cd7105d7157b183c949ed11e0db7061 Mon Sep 17 00:00:00 2001 From: Klaus Reimer Date: Thu, 18 Apr 2013 21:05:20 +0200 Subject: [PATCH] Ensure that DescriptorUtils has a private constructor --- .../usb4java/utils/DescriptorUtilsTest.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/test/java/de/ailis/usb4java/utils/DescriptorUtilsTest.java b/src/test/java/de/ailis/usb4java/utils/DescriptorUtilsTest.java index 5928ed6..14dacfe 100644 --- a/src/test/java/de/ailis/usb4java/utils/DescriptorUtilsTest.java +++ b/src/test/java/de/ailis/usb4java/utils/DescriptorUtilsTest.java @@ -7,6 +7,7 @@ package de.ailis.usb4java.utils; import static org.junit.Assert.assertEquals; +import java.lang.reflect.Constructor; import java.nio.ByteBuffer; import org.junit.Test; @@ -173,4 +174,19 @@ public class DescriptorUtilsTest DescriptorUtils.dump(new SimpleUsbEndpointDescriptor((byte) 0, (byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 5))); } + + /** + * Ensure constructor is private. + * + * @throws Exception + * When constructor test fails. + */ + @Test + public void testPrivateConstructor() throws Exception + { + assertEquals(0, DescriptorUtils.class.getConstructors().length); + Constructor c = DescriptorUtils.class.getDeclaredConstructor(); + c.setAccessible(true); + c.newInstance(); + } }