Created
October 2, 2014 14:41
-
-
Save mosheeshel/b095077e4d7673533aa8 to your computer and use it in GitHub Desktop.
Demo Integration test using RabbitDockerContainer @rule
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment