Example usage for java.lang Exception getClass

List of usage examples for java.lang Exception getClass

Introduction

In this page you can find the example usage for java.lang Exception getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:com.redhat.rhn.domain.rhnpackage.test.PackageEvrComparableTest.java

private void failure(String evr, Class excClass) {
    try {/*from   ww  w  .  j a va 2 s  . c o m*/
        compare(0, evr, evr);
        fail("Comparison of " + evr + " must fail");
    } catch (WrappedSQLException wse) {
        assertTrue(true);
    } catch (Exception e) {
        assertEquals(excClass, e.getClass());
    }
}

From source file:caillou.company.clonemanager.gui.service.task.impl.CloneManagerIOExceptionAdvice.java

@AfterThrowing(pointcut = "execution(* caillou.company.clonemanager.background.service.classifier.impl.Classifier.classify(..))", throwing = "e")
public void handleFileToTreat(Exception e) {
    if (CloneManagerIOException.class.isAssignableFrom(e.getClass())) {
        CloneManagerIOExceptionBean.getReadingErrors().add((CloneManagerIOException) e);
    }/*w w  w. j a va  2 s  .c  om*/
}

From source file:com.hillert.botanic.controller.BotanicControllerAdvice.java

@ExceptionHandler(value = Exception.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)/*from w w  w  . j  a v  a2s. co m*/
@ResponseBody
public ErrorMessage errorResponse(Exception e) {
    return new ErrorMessage(new Date(), HttpStatus.BAD_REQUEST.value(), e.getClass().getName(), e.getMessage());
}

From source file:in.mtap.iincube.mongoser.codec.crypto.Psyfer.java

/** @return base64 encoded format of AES encrypted form of the @param data */
public String encrypt(String data) {
    try {//from   w  ww .  j av  a  2s  . co m
        byte[] enc = eCipher.doFinal(data.getBytes("UTF-8"));
        return base64.encodeAsString(enc);
    } catch (Exception e) {
        throw new RuntimeException("[" + e.getClass().getSimpleName() + "] @ encrypt: " + e.getMessage());
    }
}

From source file:edu.fullerton.framemonitor.ChangeListener.java

protected void logError(Exception ex) {
    String ermsg = ex.getClass().getSimpleName() + " - " + ex.getLocalizedMessage();
    logit(ermsg);/*w  w w  . j a va2 s.  c  o  m*/
}

From source file:edu.vt.middleware.cas.authentication.handler.LdapAuthenticationHandlerTest.java

@Test
public void testAuthenticate() throws Exception {
    String[] values;/*from   w  w w .  j a v a  2  s  .co  m*/
    String password;
    String expected;
    for (String username : testCredentials.stringPropertyNames()) {
        values = testCredentials.get(username).toString().split("\\|");
        password = values[0];
        expected = values[1];
        if (Boolean.TRUE.toString().equalsIgnoreCase(expected)) {
            assertEquals(true, handler.authenticate(newCredentials(username, password)));
        } else {
            try {
                handler.authenticate(newCredentials(username, password));
                fail("Should have thrown " + expected);
            } catch (Exception e) {
                assertEquals(expected, e.getClass().getSimpleName());
            }
        }
    }
}

From source file:org.opendaylight.alto.manager.AltoCreateTest.java

@Test
public void testDoExecute() throws Exception {
    HttpResponse response = mock(HttpResponse.class);
    StatusLine statusLine = mock(StatusLine.class);
    doReturn(NETWORK_MAP).when(altoCreate).readFromFile("network-maps");
    doReturn(COST_MAP).when(altoCreate).readFromFile("cost-maps");
    doReturn(ENDPOINT_PROPERTY_MAP).when(altoCreate).readFromFile("endpoint-property-map");
    doReturn(response).when(httpClient).execute(any(HttpPut.class));
    doReturn(statusLine).when(response).getStatusLine();
    doReturn(200).when(statusLine).getStatusCode();

    altoCreate.resourceType = "network-map";
    altoCreate.resourceFile = "network-maps";
    altoCreate.doExecute();//from  w  ww.  ja v  a 2  s .  c om
    verify(httpClient, atLeastOnce()).execute(any(HttpPut.class));
    altoCreate.resourceType = "cost-map";
    altoCreate.resourceFile = "cost-maps";
    altoCreate.doExecute();
    verify(httpClient, atLeastOnce()).execute(any(HttpPut.class));
    altoCreate.resourceType = "endpoint-property-map";
    altoCreate.resourceFile = "endpoint-property-map";
    altoCreate.doExecute();
    verify(httpClient, atLeastOnce()).execute(any(HttpPut.class));
    altoCreate.resourceType = "otherwise";
    try {
        altoCreate.doExecute();
    } catch (Exception e) {
        Assert.assertEquals(e.getClass(), UnsupportedOperationException.class);
    }
}

From source file:de.adorsys.forge.plugins.ct.ContinuousTestingPlugin.java

private void handleError(ShellPrintWriter out, Exception ex) {
    ShellMessages.error(out, ex.getClass().getSimpleName() + ":\n" + ex.getMessage());
}

From source file:org.psidnell.omnifocus.integrationtest.SQLiteDAOTest.java

@Test
public void testDumpTables() throws SQLException, ClassNotFoundException {
    try (Connection c = sqliteDAO.getConnection()) {
        sqliteDAO.printTables(c);//w  w  w. j a v  a  2  s.c  om

    } catch (Exception e) {
        System.err.println(e.getClass().getName() + ": " + e.getMessage());
    }
}

From source file:org.opendaylight.alto.manager.AltoDeleteTest.java

@Test
public void testDoExecute() throws Exception {
    HttpResponse response = mock(HttpResponse.class);
    HttpEntity entity = EntityBuilder.create().setText(DEFAULT_NETWORK_MAP).build();
    StatusLine statusLine = mock(StatusLine.class);
    doReturn(response).when(httpClient).execute(any(HttpDelete.class));
    doReturn(statusLine).when(response).getStatusLine();
    doReturn(200).when(statusLine).getStatusCode();
    doReturn(response).when(altoDelete).httpGet(AltoManagerConstants.IRD_DEFAULT_NETWORK_MAP_URL);
    doReturn(entity).when(response).getEntity();

    altoDelete.resourceType = "network-map";
    altoDelete.resourceId = "my-default-network-map";
    altoDelete.doExecute();/* w  w  w  .  ja v a2  s  .  com*/
    verify(httpClient, atLeastOnce()).execute(any(HttpDelete.class));
    altoDelete.resourceType = "cost-map";
    altoDelete.resourceId = "my-default-network-map-routingcost-numerical";
    altoDelete.doExecute();
    verify(httpClient, atLeastOnce()).execute(any(HttpDelete.class));
    altoDelete.resourceType = "endpoint-property-map";
    altoDelete.resourceId = null;
    altoDelete.doExecute();
    verify(httpClient, atLeastOnce()).execute(any(HttpDelete.class));
    altoDelete.resourceType = "otherwise";
    altoDelete.resourceId = "";
    try {
        altoDelete.doExecute();
    } catch (Exception e) {
        Assert.assertEquals(e.getClass(), UnsupportedOperationException.class);
    }
}