@Test public void testCreateRedirectionExceptionWithInvalidPort() throws URISyntaxException { AmqpProvider mockProvider = Mockito.mock(AmqpProvider.class); Mockito.when(mockProvider.getRemoteURI()).thenReturn(new URI("amqp: ErrorCondition condition = new ErrorCondition(); Map<Symbol, Object> info = new HashMap<>(); info.put(AmqpSupport.PORT, "L5672"); info.put(AmqpSupport.OPEN_HOSTNAME, "localhost"); info.put(AmqpSupport.NETWORK_HOST, "localhost"); info.put(AmqpSupport.SCHEME, "amqp"); info.put(AmqpSupport.PATH, "websocket"); condition.setInfo(info); Symbol error = AmqpError.INTERNAL_ERROR; String message = "Failed to connect"; Exception result = AmqpSupport.createRedirectException(mockProvider, error, message, condition); assertNotNull(result); assertFalse(result instanceof ProviderConnectionRedirectedException); assertTrue(result instanceof ProviderException); }
public static ProviderConnectionRemotelyClosedException createRedirectException(AmqpProvider provider, Symbol error, String message, ErrorCondition condition) { ProviderConnectionRemotelyClosedException result = null; Map<?, ?> info = condition.getInfo(); if (info == null) { result = new ProviderConnectionRemotelyClosedException(message + " : Redirection information not set."); } else { @SuppressWarnings("unchecked") AmqpRedirect redirect = new AmqpRedirect((Map<Symbol, Object>) info, provider); try { result = new ProviderConnectionRedirectedException(message, redirect.validate().toURI()); } catch (Exception ex) { result = new ProviderConnectionRemotelyClosedException(message + " : " + ex.getMessage()); } } return result; }
AmqpSupport { public static ProviderConnectionRemotelyClosedException createRedirectException(AmqpProvider provider, Symbol error, String message, ErrorCondition condition) { ProviderConnectionRemotelyClosedException result = null; Map<?, ?> info = condition.getInfo(); if (info == null) { result = new ProviderConnectionRemotelyClosedException(message + " : Redirection information not set."); } else { @SuppressWarnings("unchecked") AmqpRedirect redirect = new AmqpRedirect((Map<Symbol, Object>) info, provider); try { result = new ProviderConnectionRedirectedException(message, redirect.validate().toURI()); } catch (Exception ex) { result = new ProviderConnectionRemotelyClosedException(message + " : " + ex.getMessage()); } } return result; } }
AmqpSupport { public static ProviderConnectionRemotelyClosedException createRedirectException(AmqpProvider provider, Symbol error, String message, ErrorCondition condition) { ProviderConnectionRemotelyClosedException result = null; Map<?, ?> info = condition.getInfo(); if (info == null) { result = new ProviderConnectionRemotelyClosedException(message + " : Redirection information not set."); } else { @SuppressWarnings("unchecked") AmqpRedirect redirect = new AmqpRedirect((Map<Symbol, Object>) info, provider); try { result = new ProviderConnectionRedirectedException(message, redirect.validate().toURI()); } catch (Exception ex) { result = new ProviderConnectionRemotelyClosedException(message + " : " + ex.getMessage()); } } return result; }  }
AmqpSupport { public static ProviderConnectionRemotelyClosedException createRedirectException(AmqpProvider provider, Symbol error, String message, ErrorCondition condition) { ProviderConnectionRemotelyClosedException result = null; Map<?, ?> info = condition.getInfo(); if (info == null) { result = new ProviderConnectionRemotelyClosedException(message + " : Redirection information not set."); } else { @SuppressWarnings("unchecked") AmqpRedirect redirect = new AmqpRedirect((Map<Symbol, Object>) info, provider); try { result = new ProviderConnectionRedirectedException(message, redirect.validate().toURI()); } catch (Exception ex) { result = new ProviderConnectionRemotelyClosedException(message + " : " + ex.getMessage()); } } return result; }  static ProviderConnectionRemotelyClosedException convertToConnectionClosedException(AmqpProvider provider, Endpoint endpoint, ErrorCondition errorCondition); static ProviderException convertToNonFatalException(AmqpProvider provider, Endpoint endpoint, ErrorCondition errorCondition); static String extractErrorMessage(ErrorCondition errorCondition); static ProviderConnectionRemotelyClosedException createRedirectException(AmqpProvider provider, Symbol error, String message, ErrorCondition condition); }
AmqpSupport { public static ProviderConnectionRemotelyClosedException createRedirectException(AmqpProvider provider, Symbol error, String message, ErrorCondition condition) { ProviderConnectionRemotelyClosedException result = null; Map<?, ?> info = condition.getInfo(); if (info == null) { result = new ProviderConnectionRemotelyClosedException(message + " : Redirection information not set."); } else { @SuppressWarnings("unchecked") AmqpRedirect redirect = new AmqpRedirect((Map<Symbol, Object>) info, provider); try { result = new ProviderConnectionRedirectedException(message, redirect.validate().toURI()); } catch (Exception ex) { result = new ProviderConnectionRemotelyClosedException(message + " : " + ex.getMessage()); } } return result; }  static ProviderConnectionRemotelyClosedException convertToConnectionClosedException(AmqpProvider provider, Endpoint endpoint, ErrorCondition errorCondition); static ProviderException convertToNonFatalException(AmqpProvider provider, Endpoint endpoint, ErrorCondition errorCondition); static String extractErrorMessage(ErrorCondition errorCondition); static ProviderConnectionRemotelyClosedException createRedirectException(AmqpProvider provider, Symbol error, String message, ErrorCondition condition); static final Symbol SOLE_CONNECTION_CAPABILITY; static final Symbol ANONYMOUS_RELAY; static final Symbol DELAYED_DELIVERY; static final Symbol SHARED_SUBS; static final Symbol CONNECTION_OPEN_FAILED; static final Symbol INVALID_FIELD; static final Symbol CONTAINER_ID; static final Symbol FAILOVER_SERVER_LIST; static final Symbol PATH; static final Symbol SCHEME; static final Symbol PORT; static final Symbol NETWORK_HOST; static final Symbol OPEN_HOSTNAME; static final Symbol QUEUE_PREFIX; static final Symbol TOPIC_PREFIX; static final Symbol PRODUCT; static final Symbol VERSION; static final Symbol PLATFORM; static final Symbol COPY; static final Symbol JMS_NO_LOCAL_SYMBOL; static final Symbol JMS_SELECTOR_SYMBOL; static final Symbol SHARED; static final Symbol GLOBAL; static final Rejected REJECTED; static final Modified MODIFIED_FAILED; static final Modified MODIFIED_FAILED_UNDELIVERABLE; static final Symbol DYNAMIC_NODE_LIFETIME_POLICY; static final String TEMP_QUEUE_CREATOR; static final String TEMP_TOPIC_CREATOR; static final String SUB_NAME_DELIMITER; }