List of usage examples for java.lang IllegalStateException getMessage
public String getMessage()
From source file:com.twinsoft.convertigo.eclipse.ConvertigoPlugin.java
public void addListeners() { try {/*from ww w . ja va 2 s .c o m*/ IWorkbench workbench = PlatformUI.getWorkbench(); // Add a WorkbenchListener workbenchListener = new ConvertigoWorkbenchListener(); workbench.addWorkbenchListener(workbenchListener); // Add a WindowListener windowListener = new ConvertigoWindowListener(); workbench.addWindowListener(windowListener); IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow(); if (activeWorkbenchWindow != null) { // Add a PerspectiveListener if (perspectiveListener == null) { perspectiveListener = new ConvertigoPerspectiveListener(); activeWorkbenchWindow.addPerspectiveListener(perspectiveListener); } // Add a PartListener if (partListener == null) { partListener = new ConvertigoPartListener(); IPartService partService = activeWorkbenchWindow.getPartService(); partService.addPartListener(partListener); } } } catch (IllegalStateException e) { studioLog.error("Could not add listeners to plugin." + e.getMessage()); } }
From source file:com.morphoss.acal.service.connector.AcalRequestor.java
public JSONObject doJsonRequest(String method, String requestPath, Header[] headers, String xml) throws SSLHandshakeException { InputStream responseStream = null; try {/*from w w w. j a v a2 s . c om*/ responseStream = doRequest(method, requestPath, headers, xml); if (statusCode == 404 || statusCode == 401) { if (Constants.LOG_DEBUG) Log.e(TAG, "Status '" + statusCode + "' for " + fullUrl()); return new JSONObject(); } try { return new JSONObject(convertStreamToString(responseStream)); } catch (IllegalStateException e) { if (Constants.LOG_DEBUG) Log.e(TAG, "Error Sending Request: ", e); return new JSONObject(); } catch (IOException e) { if (Constants.LOG_DEBUG) Log.e(TAG, "IOException in request to '" + fullUrl() + "'", e); return new JSONObject(); } catch (NullPointerException e) { if (Constants.LOG_DEBUG) Log.e(TAG, "NullPointerException in request to '" + fullUrl() + "'", e); return new JSONObject(); } } catch (SSLHandshakeException e) { throw e; } catch (Exception e) { Log.i(TAG, e.getMessage(), e); return new JSONObject(); } finally { if (responseStream != null) try { responseStream.close(); } catch (IOException e) { } } }
From source file:net.officefloor.plugin.web.http.application.WebApplicationAutoWireOfficeFloorSourceTest.java
/** * Ensure issue if attempt to add more than one HTTP template for a URI. *//* w w w .jav a 2 s. co m*/ public void testMultipleTemplatesWithSameUri() throws Exception { final String TEMPLATE_URI = "template"; // Add HTTP template this.source.addHttpTemplate(TEMPLATE_URI, this.getClassPath("template.ofp"), MockTemplateLogic.class); // Ensure indicates template already registered for URI try { this.source.addHttpTemplate(TEMPLATE_URI, this.getClassPath("template.ofp"), MockTemplateLogic.class); fail("Should not successfully add template for duplicate URI"); } catch (IllegalStateException ex) { assertEquals("Incorrect cause", "HTTP Template already added for URI '/" + TEMPLATE_URI + "'", ex.getMessage()); } // Ensure indicates template already registered for canonical URI try { this.source.addHttpTemplate("/" + TEMPLATE_URI, this.getClassPath("template.ofp"), MockTemplateLogic.class); fail("Should not successfully add template for duplicate URI"); } catch (IllegalStateException ex) { assertEquals("Incorrect cause", "HTTP Template already added for URI '/" + TEMPLATE_URI + "'", ex.getMessage()); } }
From source file:io.realm.RealmTest.java
public void testNestedTransaction() { testRealm.beginTransaction();// ww w.j av a 2s. co m try { testRealm.beginTransaction(); fail(); } catch (IllegalStateException e) { assertEquals( "Nested transactions are not allowed. Use commitTransaction() after each beginTransaction().", e.getMessage()); } testRealm.commitTransaction(); }
From source file:net.sf.ehcache.CacheTest.java
License:asdf
/** * Test using a cache which has been removed and replaced. *///from w ww. jav a 2s . c o m public void testStaleCacheReference() throws CacheException { manager.addCache("test"); Ehcache cache = manager.getCache("test"); assertNotNull(cache); cache.put(new Element("key1", "value1")); assertEquals("value1", cache.get("key1").getObjectValue()); manager.removeCache("test"); manager.addCache("test"); try { cache.get("key1"); fail(); } catch (IllegalStateException e) { assertEquals("The test Cache is not alive.", e.getMessage()); } }
From source file:net.sf.ehcache.CacheTest.java
License:asdf
/** * Checks we cannot use a cache outside the manager */// w w w. j av a2 s. co m public void testUseCacheOutsideManager() throws CacheException { //Not put into manager. Cache cache = new Cache("testCache", 1, true, false, 5, 2); Element element = new Element("key", "value"); try { cache.getSize(); fail(); } catch (IllegalStateException e) { assertEquals("The testCache Cache is not alive.", e.getMessage()); } try { cache.put(element); fail(); } catch (IllegalStateException e) { assertEquals("The testCache Cache is not alive.", e.getMessage()); } try { cache.get("key"); fail(); } catch (IllegalStateException e) { assertEquals("The testCache Cache is not alive.", e.getMessage()); } //ok to get stats cache.getHitCount(); cache.getMemoryStoreHitCount(); cache.getDiskStoreHitCount(); cache.getMissCountExpired(); cache.getMissCountNotFound(); }
From source file:net.sf.ehcache.CacheTest.java
License:asdf
/** * Checks we cannot use a cache after shutdown *//*from w w w . j av a2 s . co m*/ public void testUseCacheAfterManagerShutdown() throws CacheException { Ehcache cache = getSampleCache1(); manager.shutdown(); Element element = new Element("key", "value"); try { cache.getSize(); fail(); } catch (IllegalStateException e) { assertEquals("The sampleCache1 Cache is not alive.", e.getMessage()); } try { cache.put(element); fail(); } catch (IllegalStateException e) { assertEquals("The sampleCache1 Cache is not alive.", e.getMessage()); } try { cache.get("key"); fail(); } catch (IllegalStateException e) { assertEquals("The sampleCache1 Cache is not alive.", e.getMessage()); } if (cache instanceof Cache) { Cache castCache = (Cache) cache; //ok to get stats castCache.getHitCount(); castCache.getMemoryStoreHitCount(); castCache.getDiskStoreHitCount(); castCache.getMissCountExpired(); castCache.getMissCountNotFound(); } }
From source file:org.finra.herd.service.BusinessObjectDataServiceCreateBusinessObjectDataTest.java
@Test public void testCreateBusinessObjectDataInvalidValidationBooleanValue() { // Create an S3 storage entity. List<Attribute> attributes = new ArrayList<>(); attributes.add(new Attribute( configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), S3_BUCKET_NAME)); attributes.add(new Attribute( configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_VALIDATE_FILE_EXISTENCE), INVALID_BOOLEAN_VALUE));/* w ww.ja v a2 s .c o m*/ storageDaoTestHelper.createStorageEntity(STORAGE_NAME, StoragePlatformEntity.S3, attributes); // Create relative database entities. businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, FORMAT_DESCRIPTION, FORMAT_DOCUMENT_SCHEMA, FORMAT_DOCUMENT_SCHEMA_URL, true, PARTITION_KEY); businessObjectDataStatusDaoTestHelper.createBusinessObjectDataStatusEntity(BDATA_STATUS); // Build a list of storage files. List<StorageFile> storageFiles = businessObjectDataServiceTestHelper.getTestStorageFiles(testS3KeyPrefix, SORTED_LOCAL_FILES); // Build a new business object data create request. BusinessObjectDataCreateRequest request = businessObjectDataServiceTestHelper .createBusinessObjectDataCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_KEY, PARTITION_VALUE, BDATA_STATUS, STORAGE_NAME, testS3KeyPrefix, storageFiles); try { // Try to create a business object data instance. businessObjectDataService.createBusinessObjectData(request); fail("Should throw an IllegalStateException when a validation boolean value is invalid."); } catch (IllegalStateException e) { assertEquals( String.format("Attribute \"%s\" for \"%s\" storage has an invalid boolean value: " + "\"%s\".", ConfigurationValue.S3_ATTRIBUTE_NAME_VALIDATE_FILE_EXISTENCE.getDefaultValue(), STORAGE_NAME, INVALID_BOOLEAN_VALUE), e.getMessage()); } }
From source file:com.ah.ui.actions.LoginAction.java
@Override public void prepare() throws Exception { // if (HAMonitorUtil.isSlave()) { // log.info("prepare", "Currently HM is in HA Slave mode."); // return; // }//from ww w.j a v a2 s . c om try { versionInfo = getSessionVersionInfo(); if (null == versionInfo) { versionInfo = NmsUtil.getVersionInfo(); if (null != versionInfo) { setSessionVersionInfo(versionInfo); } } } catch (IllegalStateException ise) { log.error("prepare()", ise.getMessage()); } }