List of usage examples for java.rmi AccessException AccessException
public AccessException(String s, Exception ex)
AccessException
with the specified detail message and nested exception. From source file:org.slc.sli.ingestion.util.LogUtilTest.java
@Test public void testLogUtil() { // Log a nested exception. final Logger mockLogger = Mockito.mock(Logger.class); Mockito.when(mockLogger.isErrorEnabled()).thenReturn(true); try {/*from w w w. jav a 2 s . com*/ throw new RemoteException("*** EXCEPTION MESSAGE ONE!!! ***"); } catch (RemoteException re1) { try { throw new RuntimeException("*** EXCEPTION MESSAGE TWO!!! ***", re1); } catch (RuntimeException re2) { try { throw new AccessException("*** EXCEPTION MESSAGE THREE!!! ***", re2); } catch (AccessException ae) { String message = "This is a test of the LogUtil utility"; // Now test what would be logged. // First, without exception local message logging. LogUtil.setIncludeExceptionMessage(false); LogUtil.error(mockLogger, message, ae); Mockito.verify(mockLogger).error(Mockito.eq(message), Mockito.argThat(new IsCorrectException())); // Next, with exception local message logging. LogUtil.setIncludeExceptionMessage(true); LogUtil.error(mockLogger, message, ae); Mockito.verify(mockLogger).error(Mockito.eq(message), Mockito.argThat(new IsCorrectException())); } } } }