Skip to content

Commit

Permalink
Update private constructor test
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonlam604 committed Nov 11, 2016
1 parent f3e631a commit 5690c6b
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.jasonlam604.stocktechnicals.util;

import static org.junit.Assert.fail;

import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;

Expand Down Expand Up @@ -31,11 +33,9 @@ public void roundingWithIndicateDecimalPoints() {
Assert.assertEquals(1.196, NumberFormatter.round(1.19555555, 3), 0);
}

@Test
public void testPrivateConstructor() {
final Constructor<?>[] constructors = NumberFormatter.class.getDeclaredConstructors();
for (Constructor<?> constructor : constructors) {
Assert.assertTrue(Modifier.isPrivate(constructor.getModifiers()));
}
@Test(expected=IllegalAccessException.class)
public void testConstructorPrivate() throws Exception {
NumberFormatter.class.newInstance();
Assert.fail("class constructor should be private");
}
}

0 comments on commit 5690c6b

Please sign in to comment.