Java Code Examples for org.apache.qpid.proton.amqp.transport.AmqpError#INTERNAL_ERROR

The following examples show how to use org.apache.qpid.proton.amqp.transport.AmqpError#INTERNAL_ERROR . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AmqpSupportTest.java    From qpid-jms with Apache License 2.0 6 votes vote down vote up
@Test
public void testCreateRedirectionExceptionWithNoNetworkHost() throws URISyntaxException {
    AmqpProvider mockProvider = Mockito.mock(AmqpProvider.class);
    Mockito.when(mockProvider.getRemoteURI()).thenReturn(new URI("amqp://localhost:5672"));

    ErrorCondition condition = new ErrorCondition();

    Map<Symbol, Object> info = new HashMap<>();
    info.put(AmqpSupport.PORT, "5672");
    info.put(AmqpSupport.OPEN_HOSTNAME, "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);
}
 
Example 2
Source File: AmqpSupportTest.java    From qpid-jms with Apache License 2.0 6 votes vote down vote up
@Test
public void testCreateRedirectionExceptionWithEmptyNetworkHost() throws URISyntaxException {
    AmqpProvider mockProvider = Mockito.mock(AmqpProvider.class);
    Mockito.when(mockProvider.getRemoteURI()).thenReturn(new URI("amqp://localhost:5672"));

    ErrorCondition condition = new ErrorCondition();

    Map<Symbol, Object> info = new HashMap<>();
    info.put(AmqpSupport.PORT, "5672");
    info.put(AmqpSupport.NETWORK_HOST, "");
    info.put(AmqpSupport.OPEN_HOSTNAME, "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);
}
 
Example 3
Source File: AmqpSupportTest.java    From qpid-jms with Apache License 2.0 6 votes vote down vote up
@Test
public void testCreateRedirectionExceptionWithInvalidPort() throws URISyntaxException {
    AmqpProvider mockProvider = Mockito.mock(AmqpProvider.class);
    Mockito.when(mockProvider.getRemoteURI()).thenReturn(new URI("amqp://localhost:5672"));

    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);
}
 
Example 4
Source File: AmqpSupportTest.java    From qpid-jms with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateRedirectionException() throws URISyntaxException {
    ErrorCondition condition = new ErrorCondition();

    AmqpProvider mockProvider = Mockito.mock(AmqpProvider.class);
    Mockito.when(mockProvider.getRemoteURI()).thenReturn(new URI("amqp://localhost:5672"));

    Map<Symbol, Object> info = new HashMap<>();
    info.put(AmqpSupport.PORT, "5672");
    info.put(AmqpSupport.OPEN_HOSTNAME, "localhost.localdomain");
    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);
    assertTrue(result instanceof ProviderConnectionRedirectedException);

    ProviderConnectionRedirectedException pre = (ProviderConnectionRedirectedException) result;

    URI redirection = pre.getRedirectionURI();

    assertEquals(5672, redirection.getPort());
    assertTrue("localhost.localdomain", redirection.getQuery().contains("amqp.vhost=localhost.localdomain"));
    assertEquals("localhost", redirection.getHost());
    assertEquals("amqp", redirection.getScheme());
    assertEquals("/websocket", redirection.getPath());
}
 
Example 5
Source File: AmqpSupportTest.java    From qpid-jms with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateRedirectionExceptionWithNoRedirectInfo() throws URISyntaxException {
    AmqpProvider mockProvider = Mockito.mock(AmqpProvider.class);
    Mockito.when(mockProvider.getRemoteURI()).thenReturn(new URI("amqp://localhost:5672"));

    ErrorCondition condition = new ErrorCondition();
    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);
}
 
Example 6
Source File: ActiveMQAMQPInvalidContentTypeException.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
public ActiveMQAMQPInvalidContentTypeException(String message) {
   super(AmqpError.INTERNAL_ERROR, message, ActiveMQExceptionType.INTERNAL_ERROR);
}
 
Example 7
Source File: ActiveMQAMQPInternalErrorException.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
public ActiveMQAMQPInternalErrorException(String message, Throwable e) {
   super(AmqpError.INTERNAL_ERROR, message, e, ActiveMQExceptionType.INTERNAL_ERROR);
}
 
Example 8
Source File: ActiveMQAMQPInternalErrorException.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
public ActiveMQAMQPInternalErrorException(String message) {
   super(AmqpError.INTERNAL_ERROR, message, ActiveMQExceptionType.INTERNAL_ERROR);
}