List of usage examples for java.lang IllegalStateException getMessage
public String getMessage()
From source file:org.finra.herd.service.helper.notification.BusinessObjectDataStatusChangeMessageBuilderTest.java
@Test public void testBuildBusinessObjectDataStatusChangeMessagesJsonPayloadInvalidMessageType() throws Exception { // Create a business object data entity. BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataServiceTestHelper .createTestValidBusinessObjectData(SUBPARTITION_VALUES, NO_ATTRIBUTE_DEFINITIONS, NO_ATTRIBUTES); // Get a business object data key. BusinessObjectDataKey businessObjectDataKey = businessObjectDataHelper .getBusinessObjectDataKey(businessObjectDataEntity); // Override configuration. ConfigurationEntity configurationEntity = new ConfigurationEntity(); configurationEntity//from w w w. j av a 2 s . c o m .setKey(ConfigurationValue.HERD_NOTIFICATION_BUSINESS_OBJECT_DATA_STATUS_CHANGE_MESSAGE_DEFINITIONS .getKey()); configurationEntity.setValueClob(xmlHelper.objectToXml(new NotificationMessageDefinitions( Collections.singletonList(new NotificationMessageDefinition(INVALID_VALUE, MESSAGE_DESTINATION, BUSINESS_OBJECT_DATA_STATUS_CHANGE_NOTIFICATION_MESSAGE_VELOCITY_TEMPLATE_JSON, NO_MESSAGE_HEADER_DEFINITIONS))))); configurationDao.saveAndRefresh(configurationEntity); // Try to build a notification message. try { businessObjectDataStatusChangeMessageBuilder.buildNotificationMessages( new BusinessObjectDataStatusChangeNotificationEvent(businessObjectDataKey, BDATA_STATUS, BDATA_STATUS_2)); fail(); } catch (IllegalStateException e) { assertEquals(String.format( "Only \"%s\" notification message type is supported. Please update \"%s\" configuration entry.", MESSAGE_TYPE_SNS, ConfigurationValue.HERD_NOTIFICATION_BUSINESS_OBJECT_DATA_STATUS_CHANGE_MESSAGE_DEFINITIONS .getKey()), e.getMessage()); } }
From source file:com.evolveum.midpoint.model.common.mapping.Mapping.java
@Override public PrismValueDeltaSetTriple<V> getOutputTriple() { if (outputTriple != null && InternalsConfig.consistencyChecks) { try {/* w w w. j a va 2 s . c o m*/ outputTriple.checkNoParent(); } catch (IllegalStateException e) { throw new IllegalStateException(e.getMessage() + " in output triple in " + getContextDescription(), e); } } return outputTriple; }
From source file:jp.terasoluna.fw.util.GenericPropertyUtilTest.java
/** * testResolveTypeObjectStringClassint14() <br> * <br>/* ww w .ja va2 s . c o m*/ * <br> * G <br> * <br> * () bean:?int integer????getter??<br> * () name:"integer"<br> * () genericClass:int.class<br> * () index:1<br> * <br> * () :IllegalStateException<br> * "No parameterizedType was detected."<br> * <br> * ?????? IllegalStateException?????? <br> * @throws Exception ????? */ @Test public void testResolveTypeObjectStringClassint14() throws Exception { try { // GenericPropertyUtil.resolveType(new GenericPropertyUtil_Stub01(), "integer", int.class, 1); // fail("???????"); } catch (IllegalStateException e) { assertEquals("No parameterizedType was detected.", e.getMessage()); assertEquals(IllegalStateException.class.getName(), e.getClass().getName()); } }
From source file:jp.terasoluna.fw.util.GenericPropertyUtilTest.java
/** * testResolveTypeObjectStringClassint15() <br> * <br>/*from w w w. ja v a 2 s . c om*/ * <br> * G <br> * <br> * () bean:?Object object????getter??<br> * () name:"object"<br> * () genericClass:Object.class<br> * () index:1<br> * <br> * () :IllegalStateException<br> * "No parameterizedType was detected."<br> * <br> * ?????? IllegalStateException?????? <br> * @throws Exception ????? */ @Test public void testResolveTypeObjectStringClassint15() throws Exception { try { // GenericPropertyUtil.resolveType(new GenericPropertyUtil_Stub01(), "object", Object.class, 1); // fail("???????"); } catch (IllegalStateException e) { assertEquals("No parameterizedType was detected.", e.getMessage()); assertEquals(IllegalStateException.class.getName(), e.getClass().getName()); } }
From source file:org.restcomm.connect.telephony.ua.UserAgentManager.java
private void register(final Object message) throws Exception { final SipServletRequest request = (SipServletRequest) message; final Address contact = request.getAddressHeader("Contact"); // Get the expiration time. int ttl = contact.getExpires(); if (ttl == -1) { final String expires = request.getHeader("Expires"); if (expires != null) { ttl = parseInt(expires);/*from ww w. j a v a 2 s . co m*/ } else { ttl = 3600; } } // Make sure registrations don't last more than 1 hour. if (ttl > 3600) { ttl = 3600; } if (logger.isDebugEnabled()) { logger.debug("Register request received for contact: " + contact + ", and ttl: " + ttl); } // Get the rest of the information needed for a registration record. String name = contact.getDisplayName(); String ua = request.getHeader("User-Agent"); final SipURI to = (SipURI) request.getTo().getURI(); final String aor = to.toString(); final String user = to.getUser().trim(); final SipURI uri = (SipURI) contact.getURI(); final String ip = request.getInitialRemoteAddr(); final int port = request.getInitialRemotePort(); String transport = (uri.getTransportParam() == null ? request.getParameter("transport") : uri.getTransportParam()); //Issue #935, take transport of initial request-uri if contact-uri has no transport parameter //If RURI is secure (SIPS) then pick TLS for transport - https://github.com/RestComm/Restcomm-Connect/issues/1956 if (((SipURI) request.getRequestURI()).isSecure()) { transport = "tls"; } if (transport == null && !request.getInitialTransport().equalsIgnoreCase("udp")) { //Issue1068, if Contact header or RURI doesn't specify transport, check InitialTransport from transport = request.getInitialTransport(); } boolean isLBPresent = false; //Issue 306: https://telestax.atlassian.net/browse/RESTCOMM-306 final String initialIpBeforeLB = request.getHeader("X-Sip-Balancer-InitialRemoteAddr"); final String initialPortBeforeLB = request.getHeader("X-Sip-Balancer-InitialRemotePort"); if (initialIpBeforeLB != null && !initialIpBeforeLB.isEmpty() && initialPortBeforeLB != null && !initialPortBeforeLB.isEmpty()) { if (logger.isInfoEnabled()) { logger.info("Client in front of LB. Patching URI: " + uri.toString() + " with IP: " + initialIpBeforeLB + " and PORT: " + initialPortBeforeLB + " for USER: " + user); } patch(uri, initialIpBeforeLB, Integer.valueOf(initialPortBeforeLB)); isLBPresent = true; } else { if (logger.isInfoEnabled()) { logger.info("Patching URI: " + uri.toString() + " with IP: " + ip + " and PORT: " + port + " for USER: " + user); } patch(uri, ip, port); } final StringBuffer buffer = new StringBuffer(); if (((SipURI) request.getRequestURI()).isSecure()) { buffer.append("sips:"); } else { buffer.append("sip:"); } buffer.append(normalize(user)).append("@").append(uri.getHost()).append(":").append(uri.getPort()); // https://bitbucket.org/telestax/telscale-restcomm/issue/142/restcomm-support-for-other-transports-than if (transport != null) { buffer.append(";transport=").append(transport); } Iterator<String> extraParameterNames = uri.getParameterNames(); while (extraParameterNames.hasNext()) { String paramName = extraParameterNames.next(); if (!paramName.equalsIgnoreCase("transport")) { String paramValue = uri.getParameter(paramName); buffer.append(";"); buffer.append(paramName); buffer.append("="); buffer.append(paramValue); } } final String address = buffer.toString(); // Prepare the response. final SipServletResponse response = request.createResponse(SC_OK); // Update the data store. final Sid sid = Sid.generate(Sid.Type.REGISTRATION); final DateTime now = DateTime.now(); // Issue 87 // (http://www.google.com/url?q=https://bitbucket.org/telestax/telscale-restcomm/issue/87/verb-and-not-working-for-end-to-end-calls%23comment-5855486&usd=2&usg=ALhdy2_mIt4FU4Yb_EL-s0GZCpBG9BB8eQ) // if display name or UA are null, the hasRegistration returns 0 even if there is a registration if (name == null) name = user; if (ua == null) ua = "GenericUA"; boolean webRTC = isWebRTC(transport, ua); final Registration registration = new Registration(sid, instanceId, now, now, aor, name, user, ua, ttl, address, webRTC, isLBPresent); final RegistrationsDao registrations = storage.getRegistrationsDao(); if (ttl == 0) { // Remove Registration if ttl=0 registrations.removeRegistration(registration); response.setHeader("Expires", "0"); monitoringService.tell(new UserRegistration(user, address, false), self()); if (logger.isInfoEnabled()) { logger.info("The user agent manager unregistered " + user + " at address " + address + ":" + port); } } else { monitoringService.tell(new UserRegistration(user, address, true), self()); if (registrations.hasRegistration(registration)) { // Update Registration if exists registrations.updateRegistration(registration); if (logger.isInfoEnabled()) { logger.info("The user agent manager updated " + user + " at address " + address + ":" + port); } } else { // Add registration since it doesn't exists on the DB registrations.addRegistration(registration); if (logger.isInfoEnabled()) { logger.info( "The user agent manager registered " + user + " at address " + address + ":" + port); } } response.setHeader("Contact", contact(uri, ttl)); } // Success response.send(); // Cleanup // if(request.getSession().isValid()) { // request.getSession().invalidate(); // } try { if (request != null) { if (request.getApplicationSession() != null) { if (request.getApplicationSession().isValid()) { try { request.getApplicationSession().setInvalidateWhenReady(true); } catch (IllegalStateException exception) { logger.warning( "Illegal State: while trying to setInvalidateWhenReady(true) for application session, message: " + exception.getMessage()); } } } else { if (logger.isInfoEnabled()) { logger.info("After sent response: " + response.toString() + " for Register request, application session is NULL!"); } } } else { if (logger.isInfoEnabled()) { logger.info("After sent response: " + response.toString() + " for Register request, request is NULL!"); } } } catch (Exception e) { logger.error("Exception while trying to setInvalidateWhenReady(true) after sent response to register : " + response.toString() + " exception: " + e); } }
From source file:org.finra.herd.service.MessageNotificationEventServiceTest.java
@Test public void testProcessBusinessObjectDataStatusChangeNotificationEventNoMessageType() throws Exception { // Create a business object data entity. BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataServiceTestHelper .createTestValidBusinessObjectData(); // Get a business object data key. BusinessObjectDataKey businessObjectDataKey = businessObjectDataHelper .getBusinessObjectDataKey(businessObjectDataEntity); // Override configuration, so there will be no message type specified in the relative notification message definition. ConfigurationEntity configurationEntity = new ConfigurationEntity(); configurationEntity//w w w . jav a2s. c om .setKey(ConfigurationValue.HERD_NOTIFICATION_BUSINESS_OBJECT_DATA_STATUS_CHANGE_MESSAGE_DEFINITIONS .getKey()); configurationEntity.setValueClob(xmlHelper.objectToXml(new NotificationMessageDefinitions( Collections.singletonList(new NotificationMessageDefinition(NO_MESSAGE_TYPE, MESSAGE_DESTINATION, MESSAGE_TEXT, Collections.singletonList(new MessageHeaderDefinition(KEY, VALUE))))))); configurationDao.saveAndRefresh(configurationEntity); // Try to trigger the notification. try { messageNotificationEventService.processBusinessObjectDataStatusChangeNotificationEvent( businessObjectDataKey, BusinessObjectDataStatusEntity.VALID, BusinessObjectDataStatusEntity.UPLOADING); fail(); } catch (IllegalStateException e) { assertEquals(String.format( "Notification message type must be specified. Please update \"%s\" configuration entry.", ConfigurationValue.HERD_NOTIFICATION_BUSINESS_OBJECT_DATA_STATUS_CHANGE_MESSAGE_DEFINITIONS .getKey()), e.getMessage()); } }
From source file:org.finra.herd.service.MessageNotificationEventServiceTest.java
@Test public void testProcessUserNamespaceAuthorizationChangeNotificationEventNoMessageType() throws Exception { // Create a user namespace authorization key. UserNamespaceAuthorizationKey userNamespaceAuthorizationKey = new UserNamespaceAuthorizationKey(USER_ID, NAMESPACE);// www . j a v a2s. c o m // Create and persist the relative database entities. namespaceDaoTestHelper.createNamespaceEntity(userNamespaceAuthorizationKey.getNamespace()); userNamespaceAuthorizationDaoTestHelper.createUserNamespaceAuthorizationEntity( userNamespaceAuthorizationKey, SUPPORTED_NAMESPACE_PERMISSIONS); // Override configuration, so there will be no message type specified in the relative notification message definition. ConfigurationEntity configurationEntity = new ConfigurationEntity(); configurationEntity .setKey(ConfigurationValue.HERD_NOTIFICATION_USER_NAMESPACE_AUTHORIZATION_CHANGE_MESSAGE_DEFINITIONS .getKey()); configurationEntity.setValueClob(xmlHelper.objectToXml(new NotificationMessageDefinitions( Collections.singletonList(new NotificationMessageDefinition(NO_MESSAGE_TYPE, MESSAGE_DESTINATION, MESSAGE_TEXT, Collections.singletonList(new MessageHeaderDefinition(KEY, VALUE))))))); configurationDao.saveAndRefresh(configurationEntity); // Try to trigger the notification. try { // Trigger the notification. messageNotificationEventService .processUserNamespaceAuthorizationChangeNotificationEvent(userNamespaceAuthorizationKey); fail(); } catch (IllegalStateException e) { assertEquals(String.format( "Notification message type must be specified. Please update \"%s\" configuration entry.", ConfigurationValue.HERD_NOTIFICATION_USER_NAMESPACE_AUTHORIZATION_CHANGE_MESSAGE_DEFINITIONS .getKey()), e.getMessage()); } }
From source file:org.elasticsearch.client.RequestTests.java
public void testUpdateWithDifferentContentTypes() throws IOException { IllegalStateException exception = expectThrows(IllegalStateException.class, () -> { UpdateRequest updateRequest = new UpdateRequest(); updateRequest.doc(new IndexRequest().source(singletonMap("field", "doc"), XContentType.JSON)); updateRequest.upsert(new IndexRequest().source(singletonMap("field", "upsert"), XContentType.YAML)); Request.update(updateRequest); });/*from w ww. j ava 2 s . co m*/ assertEquals( "Update request cannot have different content types for doc [JSON] and upsert [YAML] documents", exception.getMessage()); }
From source file:org.finra.herd.service.MessageNotificationEventServiceTest.java
@Test public void testProcessBusinessObjectDataStatusChangeNotificationEventNoMessageDestination() throws Exception { // Create a business object data entity. BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataServiceTestHelper .createTestValidBusinessObjectData(); // Get a business object data key. BusinessObjectDataKey businessObjectDataKey = businessObjectDataHelper .getBusinessObjectDataKey(businessObjectDataEntity); // Override configuration, so there will be no message definition specified in the relative notification message definition. ConfigurationEntity configurationEntity = new ConfigurationEntity(); configurationEntity// w ww . j a v a 2s.co m .setKey(ConfigurationValue.HERD_NOTIFICATION_BUSINESS_OBJECT_DATA_STATUS_CHANGE_MESSAGE_DEFINITIONS .getKey()); configurationEntity.setValueClob(xmlHelper.objectToXml(new NotificationMessageDefinitions(Collections .singletonList(new NotificationMessageDefinition(MESSAGE_TYPE_SNS, NO_MESSAGE_DESTINATION, MESSAGE_TEXT, Collections.singletonList(new MessageHeaderDefinition(KEY, VALUE))))))); configurationDao.saveAndRefresh(configurationEntity); // Try to trigger the notification. try { messageNotificationEventService.processBusinessObjectDataStatusChangeNotificationEvent( businessObjectDataKey, BusinessObjectDataStatusEntity.VALID, BusinessObjectDataStatusEntity.UPLOADING); fail(); } catch (IllegalStateException e) { assertEquals(String.format( "Notification message destination must be specified. Please update \"%s\" configuration entry.", ConfigurationValue.HERD_NOTIFICATION_BUSINESS_OBJECT_DATA_STATUS_CHANGE_MESSAGE_DEFINITIONS .getKey()), e.getMessage()); } }
From source file:org.finra.herd.service.MessageNotificationEventServiceTest.java
@Test public void testProcessBusinessObjectFormatVersionChangeNotificationEventNoMessageType() throws Exception { // Create a business object format entity. BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest( BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, StorageEntity.MANAGED_STORAGE); BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatServiceTestHelper .createBusinessObjectFormat(request); // Get a business object data key. BusinessObjectFormatKey businessObjectFormatKey = businessObjectFormatHelper .getBusinessObjectFormatKey(businessObjectFormatEntity); // Override configuration, so there will be no message type specified in the relative notification message definition. ConfigurationEntity configurationEntity = new ConfigurationEntity(); configurationEntity.setKey(/*ww w .ja v a2 s . co m*/ ConfigurationValue.HERD_NOTIFICATION_BUSINESS_OBJECT_FORMAT_VERSION_CHANGE_MESSAGE_DEFINITIONS .getKey()); configurationEntity.setValueClob(xmlHelper.objectToXml(new NotificationMessageDefinitions( Collections.singletonList(new NotificationMessageDefinition(NO_MESSAGE_TYPE, MESSAGE_DESTINATION, MESSAGE_TEXT, Collections.singletonList(new MessageHeaderDefinition(KEY, VALUE))))))); configurationDao.saveAndRefresh(configurationEntity); // Try to trigger the notification. try { // Trigger the notification. messageNotificationEventService.processBusinessObjectFormatVersionChangeNotificationEvent( businessObjectFormatKey, NO_OLD_BUSINESS_OBJECT_FORMAT_VERSION); fail(); } catch (IllegalStateException e) { assertEquals(String.format( "Notification message type must be specified. Please update \"%s\" configuration entry.", ConfigurationValue.HERD_NOTIFICATION_BUSINESS_OBJECT_FORMAT_VERSION_CHANGE_MESSAGE_DEFINITIONS .getKey()), e.getMessage()); } }