|
|
@@ -0,0 +1,64 @@ |
|
|
package integration; |
|
|
|
|
|
import com.kenshoo.trackingfront.configuration.RabbitConfiguration; |
|
|
import com.kenshoo.trackingfront.rabbitmq.RabbitConnectionFactory; |
|
|
import com.rabbitmq.client.Connection; |
|
|
import com.rabbitmq.client.ConnectionFactory; |
|
|
import org.junit.*; |
|
|
import org.junit.rules.ExpectedException; |
|
|
|
|
|
import static org.mockito.Matchers.anyString; |
|
|
import static org.mockito.Mockito.mock; |
|
|
import static org.mockito.Mockito.when; |
|
|
|
|
|
/** |
|
|
* Created with IntelliJ IDEA. |
|
|
* User: moshe |
|
|
* Date: 9/23/14 |
|
|
* Time: 1:48 PM |
|
|
*/ |
|
|
public class RabbitIntegrationTest { |
|
|
|
|
|
@ClassRule |
|
|
public static RabbitContainerRule rabbitContainerRule = new RabbitContainerRule(); |
|
|
|
|
|
@Rule |
|
|
public ExpectedException expectedException = ExpectedException.none(); |
|
|
|
|
|
private RabbitConnectionFactory rabbitConnectionFactory; |
|
|
private RabbitConfiguration rabbitConfiguration; |
|
|
private ConnectionFactory connectionFactory; |
|
|
|
|
|
|
|
|
@Before |
|
|
public void setUp() throws Exception { |
|
|
connectionFactory = new ConnectionFactory(); |
|
|
rabbitConfiguration = mock(RabbitConfiguration.class); |
|
|
|
|
|
when(rabbitConfiguration.getExchange()).thenReturn("test.this.exchange"); |
|
|
when(rabbitConfiguration.getVirtualHost()).thenReturn("/"); |
|
|
when(rabbitConfiguration.getPassword()).thenReturn("guest"); |
|
|
when(rabbitConfiguration.getUserName()).thenReturn("guest"); |
|
|
when(rabbitConfiguration.getHosts()).thenReturn("127.0.0.1"); |
|
|
when(rabbitConfiguration.getPort()).thenReturn(Integer.valueOf(rabbitContainerRule.getRabbitServicePort())); |
|
|
|
|
|
rabbitConnectionFactory = new RabbitConnectionFactory(rabbitConfiguration); |
|
|
|
|
|
System.out.println("servicePort " + rabbitContainerRule.getRabbitServicePort()); |
|
|
System.out.println("managementPort " + rabbitContainerRule.getRabbitManagementPort()); |
|
|
} |
|
|
|
|
|
|
|
|
@After |
|
|
public void tearDown() throws Exception { |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
@Test |
|
|
public void testConnectsToDocker() throws Exception { |
|
|
Connection connection = rabbitConnectionFactory.getConnection(); |
|
|
System.out.println(connection.toString()); |
|
|
} |
|
|
|
|
|
} |