List of usage examples for java.lang Exception getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:net.sourceforge.floggy.persistence.fr2852335.perclass.FR2852335MigrationTest.java
/** * DOCUMENT ME!/*from ww w. j a v a 2s.c o m*/ */ public void testFindUpdatedToAbstractJoinedClass() { PersistableMetadata rmsBasedMetadata = PersistableMetadataManager .getRMSBasedMetadata(CSCOfAbstractJoinedStrategy.class.getName()); PersistableMetadata classBasedMetadata = PersistableMetadataManager .getClassBasedMetadata(CSCOfAbstractJoinedStrategy.class.getName()); assertEquals(PersistableMetadata.JOINED_STRATEGY, rmsBasedMetadata.getPersistableStrategy()); assertEquals(PersistableMetadata.PER_CLASS_STRATEGY, classBasedMetadata.getPersistableStrategy()); try { manager.find(CSCOfAbstractJoinedStrategy.class, null, null); fail("Must throw a FloggyException because now the class implements the PerClassStrategy startegy"); } catch (Exception ex) { assertEquals(FloggyException.class, ex.getClass()); } }
From source file:net.sourceforge.floggy.persistence.fr2852335.perclass.FR2852335MigrationTest.java
/** * DOCUMENT ME!//from ww w . ja v a 2 s . c o m */ public void testFindUpdatedToConcreteJoinedClass() { PersistableMetadata rmsBasedMetadata = PersistableMetadataManager .getRMSBasedMetadata(CSCOfConcreteJoinedStrategy.class.getName()); PersistableMetadata classBasedMetadata = PersistableMetadataManager .getClassBasedMetadata(CSCOfConcreteJoinedStrategy.class.getName()); assertEquals(PersistableMetadata.JOINED_STRATEGY, rmsBasedMetadata.getPersistableStrategy()); assertEquals(PersistableMetadata.PER_CLASS_STRATEGY, classBasedMetadata.getPersistableStrategy()); try { manager.find(CSCOfConcreteJoinedStrategy.class, null, null); fail("Must throw a FloggyException because now the class implements the PerClassStrategy startegy"); } catch (Exception ex) { assertEquals(FloggyException.class, ex.getClass()); } }
From source file:org.terracotta.management.model.cluster.ClusterTest.java
@Test public void test_add_remove_connection() { Client client = cluster1.getClient("12345@127.0.0.1:ehcache:uid").get(); assertEquals(2, client.getConnections().size()); try {/*from w w w . j a v a 2s.com*/ client.addConnection( Connection.create("uid", cluster1.getStripe("stripe-1").get().getServerByName("server-1").get(), Endpoint.create("10.10.10.10", 3456))); fail(); } catch (Exception e) { assertEquals(IllegalArgumentException.class, e.getClass()); } assertEquals(2, client.getConnections().size()); client.addConnection( Connection.create("uid", cluster1.getStripe("stripe-1").get().getServerByName("server-1").get(), Endpoint.create("10.10.10.10", 3458))); assertEquals(3, client.getConnections().size()); assertTrue(client.removeConnection("uid:stripe-1:server-1:10.10.10.10:3458").isPresent()); assertFalse(client.getConnection("uid:stripe-1:server-1:10.10.10.10:3458").isPresent()); assertEquals(2, client.getConnections().size()); }
From source file:tv.arte.resteventapi.web.errors.GlobalDefaultExceptionHandler.java
/** * Handle all exceptions thrown by Controller's layer and that have not been already handled * // ww w.ja va2 s. co m * @param response The HttpServletResponse * @param e Thrown exception * @return * @throws Exception */ @ExceptionHandler(value = Exception.class) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) public ModelAndView defaultErrorHandler(HttpServletResponse response, Exception e) throws Exception { if (AnnotationUtils.findAnnotation(e.getClass(), ResponseStatus.class) != null) { throw e; } RestEventApiStandardResponse<RestEventApiMessage> restEventApiStandardResponse = new RestEventApiStandardResponse<RestEventApiMessage>(); restEventApiStandardResponse.addError(RestEventApiError.PRE_DEFINED.RIA_ERR_G_UNKNOWN); if (e instanceof NullPointerException) { //Log full stacktrace in case of NullPointer logger.error(ExceptionUtils.getFullStackTrace(e)); } ModelAndView mav = new ModelAndView(); mav.addObject(restEventApiStandardResponse); mav.setView(restEventApiDefaultErrorView); return mav; }
From source file:com.adaptris.security.TestCompositeKeystore.java
public void testImportCertificateChain() throws Exception { CompositeKeystore ksp = new CompositeKeystore(keystoreLocationList); ksp.load();//from ww w .j av a2 s . c o m try { ksp.importCertificateChain("", "".toCharArray(), ""); fail("Import successful"); } catch (Exception e) { assertEquals(KeystoreException.class, e.getClass()); assertTrue(e.getMessage().matches(".*is implicitly read-only.*")); } try { ksp.importCertificateChain("", "".toCharArray(), (InputStream) null); fail("Import successful"); } catch (Exception e) { assertEquals(KeystoreException.class, e.getClass()); assertTrue(e.getMessage().matches(".*is implicitly read-only.*")); } try { ksp.importCertificateChain("", "".toCharArray(), (File) null); fail("Import successful"); } catch (Exception e) { assertEquals(KeystoreException.class, e.getClass()); assertTrue(e.getMessage().matches(".*is implicitly read-only.*")); } }
From source file:com.adaptris.security.TestCompositeKeystore.java
public void testImportPrivateKey() throws Exception { CompositeKeystore ksp = new CompositeKeystore(keystoreLocationList); ksp.load();/*from ww w . ja va 2s . c om*/ try { ksp.importPrivateKey("", "".toCharArray(), "", "".toCharArray()); fail("Import successful"); } catch (Exception e) { assertEquals(KeystoreException.class, e.getClass()); assertTrue(e.getMessage().matches(".*is implicitly read-only.*")); } try { ksp.importPrivateKey("", "".toCharArray(), (InputStream) null, "".toCharArray()); fail("Import successful"); } catch (Exception e) { assertEquals(KeystoreException.class, e.getClass()); assertTrue(e.getMessage().matches(".*is implicitly read-only.*")); } try { ksp.importPrivateKey("", "".toCharArray(), (File) null, "".toCharArray()); fail("Import successful"); } catch (Exception e) { assertEquals(KeystoreException.class, e.getClass()); assertTrue(e.getMessage().matches(".*is implicitly read-only.*")); } }
From source file:org.terracotta.management.model.cluster.ClusterTest.java
@Test public void test_add_remove_server_entity() { System.out.println(ClientIdentifier.discoverHostName()); Server server = cluster1.stripeStream().findFirst().get().getActiveServer().get(); assertEquals(1, server.getServerEntityCount()); try {/*from w w w. j a v a2s . c om*/ server.addServerEntity(ServerEntity.create(serverContextContainer.getValue(), "org.ehcache.clustered.client.internal.EhcacheClientEntity", 1)); fail(); } catch (Exception e) { assertEquals(IllegalArgumentException.class, e.getClass()); } assertEquals(1, server.getServerEntityCount()); server.addServerEntity( ServerEntity.create("other-cm-4", "org.ehcache.clustered.client.internal.EhcacheClientEntity", 1)); server.addServerEntity(ServerEntity.create("name", "OTHER_TYPE", 2)); assertEquals(3, server.getServerEntityCount()); assertTrue(server .removeServerEntity("other-cm-4:" + "org.ehcache.clustered.client.internal.EhcacheClientEntity") .isPresent()); assertFalse( server.getServerEntity("other-cm-4:" + "org.ehcache.clustered.client.internal.EhcacheClientEntity") .isPresent()); assertEquals(2, server.getServerEntityCount()); }
From source file:com.transcend.rds.worker.DescribeDBSnapshotsActionWorker.java
@Override protected DescribeDBSnapshotsActionResultMessage doWork0(DescribeDBSnapshotsActionRequestMessage req, ServiceRequestContext context) throws Exception { /*/*from w ww.j a v a2s . c o m*/ * RDSImpl impl = new RDSImpl(); DescribeDBSnapshotsResult result = * impl.describeDBSnapshots(request, getAwsAccessKeyId(), * getRequestId()); */ DescribeDBSnapshotsActionResultMessage.Builder resp = null; String msg = ""; final Session sess = HibernateUtil.newSession(); try { sess.beginTransaction(); String instID = null; String snapshotID = null; final AccountBean ac = context.getAccountBean(); final long userID = ac.getId(); if (!"".equals(req.getDbInstanceIdentifier())) instID = req.getDbInstanceIdentifier(); if (!"".equals(req.getDbSnapshotIdentifier())) snapshotID = req.getDbSnapshotIdentifier(); final String marker = req.getMarker(); int maxRec = req.getMaxRecords(); if (maxRec == 0) { // set the default value for MaxRecords parameter maxRec = 20; } final int maxRecords = ValidationManager.validateMaxRecords(maxRec, false); logger.info("DescribeDBSnapshots: UserID = " + userID + " SnapshotID = " + snapshotID + " Marker = " + marker + " MaxRecords = " + maxRecords); final List<RdsSnapshot> snpList = SnapshotEntity.selectSnapshots(sess, instID, snapshotID, userID); // return DBSnapshotNotFound message only if user asked for a // specific DBSnapshot // IMPORTANT!!!! These three lines below are disabled because AWS // RDS does not return this exception even when no DBSnapshot is // found for the target DBSnapshotIdentifier /* * if ((snpList == null || snpList.size() == 0) && snapshotID != * null) { throw RDSQueryFaults.DBSnapshotNotFound(); } */ if ((snpList == null || snpList.size() == 0) && snapshotID != null && !("".equals(snapshotID))) { throw RDSQueryFaults.DBSnapshotNotFound("There is no DBSnapshot taken from " + snapshotID + "."); } // build response document resp = DescribeDBSnapshotsActionResultMessage.newBuilder(); final List<DBSnapshot> dl = new ArrayList<DBSnapshot>(); for (final RdsSnapshot snp : snpList) { dl.add(toDBSnapshot(snp)); } resp.addAllDbSnapshots(dl); sess.getTransaction().commit(); } catch (final ErrorResponse rde) { sess.getTransaction().rollback(); throw rde; } catch (final Exception e) { e.printStackTrace(); sess.getTransaction().rollback(); msg = "DescribeSnapshots: Class: " + e.getClass() + "Msg:" + e.getMessage(); logger.error(msg); throw RDSQueryFaults.InternalFailure(); } finally { sess.close(); } return resp.buildPartial(); }
From source file:com.amalto.service.calltransformer.CallTransformerServiceBean.java
public Serializable fetchFromOutbound(String command, String parameters, String schedulePlanID) throws XtentisException { try {/*from w w w. j a v a 2 s .c o m*/ // parse input parameter if (parameters == null || parameters.length() == 0) { throw new XtentisException("Parameters can not be empty! "); } Document paramDoc = Util.parse(parameters); String transformerName = Util.getFirstTextNode(paramDoc, "//" + Param_Transformer_Name); String typedContentType = Util.getFirstTextNode(paramDoc, "//typedContent/type"); String typedContentValue = Util.getFirstTextNode(paramDoc, "//typedContent/value"); typedContentValue = StringEscapeUtils.unescapeXml(typedContentValue); // execute main process if (transformerName == null || "".equals(transformerName)) { LOGGER.debug("Service CallTransformer - mandatory parameter transformer name is missing"); throw new XtentisException( "Service CallTransformer - mandatory parameter transformer name is missing"); } Transformer tctrl = Util.getTransformerV2CtrlLocal(); if (tctrl.existsTransformer(new TransformerV2POJOPK(transformerName)) == null) { LOGGER.debug("Service CallTransformer is unable to call transformer " + transformerName + " - transformer doesn't exist"); throw new XtentisException("Unable to find the transformer " + transformerName); } TransformerContext context = new TransformerContext(new TransformerV2POJOPK(transformerName)); context.putInPipeline(Transformer.DEFAULT_VARIABLE, new TypedContent(typedContentValue.getBytes(), typedContentType)); tctrl.executeUntilDone(context); return "OK"; } catch (Exception e) { String err = "Unable to fetchFromOutbound of the Call Transformer Service" + ": " + e.getClass().getName() + ": " + e.getLocalizedMessage(); LOGGER.error(err); throw new XtentisException(err, e); } }