47 lines
1.3 KiB
Java
47 lines
1.3 KiB
Java
package jmri.server.json.layoutblock;
|
|
|
|
import java.lang.reflect.Constructor;
|
|
import java.lang.reflect.InvocationTargetException;
|
|
|
|
import jmri.util.JUnitUtil;
|
|
|
|
import org.junit.jupiter.api.*;
|
|
|
|
/**
|
|
*
|
|
* @author Randall Wood Copyright 2018
|
|
*/
|
|
public class JsonLayoutBlockTest {
|
|
|
|
@BeforeEach
|
|
public void setUp() {
|
|
JUnitUtil.setUp();
|
|
}
|
|
|
|
@AfterEach
|
|
public void tearDown() {
|
|
JUnitUtil.tearDown();
|
|
}
|
|
|
|
@Test
|
|
public void testConstructor() {
|
|
|
|
// because the constructor throws UnsupportedOperationException, and
|
|
// that is thrown by newInstance() into an InvocationTargetException
|
|
// we pass an InvocationTargetException that is caused by an
|
|
// UnsupportedOperationException and fail everything else.
|
|
|
|
InvocationTargetException ex = Assertions.assertThrows( InvocationTargetException.class, () -> {
|
|
Constructor<JsonLayoutBlock> constructor;
|
|
constructor = JsonLayoutBlock.class.getDeclaredConstructor();
|
|
constructor.setAccessible(true);
|
|
constructor.newInstance();
|
|
Assertions.fail("Instance of JsonLayoutBlock created");
|
|
});
|
|
UnsupportedOperationException cause = Assertions.assertInstanceOf(
|
|
UnsupportedOperationException.class, ex.getCause());
|
|
Assertions.assertNotNull(cause);
|
|
}
|
|
|
|
}
|