package org.skyscreamer.nevado.jms.connector.amazonaws;

import junit.framework.Assert;
import org.junit.Test;
import org.skyscreamer.nevado.jms.AbstractJMSTest;
import org.skyscreamer.nevado.jms.NevadoConnectionFactory;
import org.skyscreamer.nevado.jms.connector.amazonaws.AmazonAwsSQSConnector;
import org.skyscreamer.nevado.jms.util.RandomData;

import javax.jms.*;

/**
 * Test ResourceAllocationException
 *
 * @author Carter Page <carter@skyscreamer.org>
 */
public class ResourceAllocationExceptionTest extends AbstractJMSTest {
    @Test(expected = ResourceAllocationException.class)
    public void testSQSResourceAllocationException() throws JMSException {
        if (getConnection().getSQSConnector() instanceof AmazonAwsSQSConnector) {
            NevadoConnectionFactory connectionFactory = new NevadoConnectionFactory(_sqsConnectorFactory);
            connectionFactory.setAwsSQSEndpoint("a.deliberately.invalid.server");
            createConnection(connectionFactory);
        }
    }

    @Test(expected = ResourceAllocationException.class)
    public void testSNSResourceAllocationException() throws JMSException {
        if (getConnection().getSQSConnector() instanceof AmazonAwsSQSConnector) {
            NevadoConnectionFactory connectionFactory = new NevadoConnectionFactory(_sqsConnectorFactory);
            connectionFactory.setAwsSNSEndpoint("a.deliberately.invalid.server");
            createConnection(connectionFactory);
        }
    }
}

@@ -291,16 +291,83 @@
 nector;%0A
+import org.skyscreamer.nevado.jms.connector.mock.MockSQSConnector;%0A
 import o
@@ -409,16 +409,16 @@
 omData;%0A
-
 %0Aimport 
@@ -781,33 +781,28 @@
  instanceof 
-AmazonAws
+Mock
 SQSConnector
@@ -797,32 +797,131 @@
 SQSConnector) %7B%0A
+            throw new ResourceAllocationException(%22mock won't break on its own%22);%0A        %7D else %7B%0A
             Neva
@@ -1347,25 +1347,20 @@
 tanceof 
-AmazonAws
+Mock
 SQSConne
@@ -1359,32 +1359,131 @@
 SQSConnector) %7B%0A
+            throw new ResourceAllocationException(%22mock won't break on its own%22);%0A        %7D else %7B%0A
             Neva

Fix ResourceAllocationExceptionTest