File tree Expand file tree Collapse file tree 1 file changed +23
-5
lines changed
geo/src/test/java/com/github/davidmoten/geo Expand file tree Collapse file tree 1 file changed +23
-5
lines changed Original file line number Diff line number Diff line change 55import java .lang .reflect .InvocationTargetException ;
66import java .lang .reflect .Modifier ;
77
8+ import static org .junit .jupiter .api .Assertions .assertTrue ;
9+
810/**
911 * Utility methods for unit tests.
1012 *
@@ -20,10 +22,26 @@ public class TestingUtil {
2022 * @param cls
2123 */
2224 public static <T > void callConstructorAndCheckIsPrivate (Class <T > cls ) {
23-
25+ Constructor <T > constructor ;
26+ try {
27+ constructor = cls .getDeclaredConstructor ();
28+ } catch (NoSuchMethodException e1 ) {
29+ throw new RuntimeException (e1 );
30+ } catch (SecurityException e1 ) {
31+ throw new RuntimeException (e1 );
32+ }
33+ assertTrue (Modifier .isPrivate (constructor .getModifiers ()));
34+ constructor .setAccessible (true );
35+ try {
36+ constructor .newInstance ();
37+ } catch (InstantiationException e ) {
38+ throw new RuntimeException (e );
39+ } catch (IllegalAccessException e ) {
40+ throw new RuntimeException (e );
41+ } catch (IllegalArgumentException e ) {
42+ throw new RuntimeException (e );
43+ } catch (InvocationTargetException e ) {
44+ throw new RuntimeException (e );
45+ }
2446 }
25-
26- private static void assertTrue (boolean aPrivate ) {
27- }
28-
2947}
You can’t perform that action at this time.
0 commit comments