Search in sources :

Example 16 with Before

use of org.junit.Before in project camel by apache.

the class SqsProducerTest method setup.

@Before
public void setup() throws Exception {
    underTest = new SqsProducer(sqsEndpoint);
    sendMessageResult = new SendMessageResult().withMD5OfMessageBody(MESSAGE_MD5).withMessageId(MESSAGE_ID);
    sqsConfiguration = new SqsConfiguration();
    HeaderFilterStrategy headerFilterStrategy = new SqsHeaderFilterStrategy();
    sqsConfiguration.setDelaySeconds(Integer.valueOf(0));
    when(sqsEndpoint.getClient()).thenReturn(amazonSQSClient);
    when(sqsEndpoint.getConfiguration()).thenReturn(sqsConfiguration);
    when(amazonSQSClient.sendMessage(any(SendMessageRequest.class))).thenReturn(sendMessageResult);
    when(exchange.getOut()).thenReturn(outMessage);
    when(exchange.getIn()).thenReturn(inMessage);
    when(exchange.getPattern()).thenReturn(ExchangePattern.InOnly);
    when(inMessage.getBody(String.class)).thenReturn(SAMPLE_MESSAGE_BODY);
    when(sqsEndpoint.getQueueUrl()).thenReturn(QUEUE_URL);
    when(sqsEndpoint.getHeaderFilterStrategy()).thenReturn(headerFilterStrategy);
}
Also used : HeaderFilterStrategy(org.apache.camel.spi.HeaderFilterStrategy) SendMessageResult(com.amazonaws.services.sqs.model.SendMessageResult) SendMessageRequest(com.amazonaws.services.sqs.model.SendMessageRequest) Before(org.junit.Before)

Example 17 with Before

use of org.junit.Before in project camel by apache.

the class SqsEndpointTest method setUp.

@Before
public void setUp() throws Exception {
    amazonSQSClient = EasyMock.createMock(AmazonSQSClient.class);
    SqsConfiguration config = new SqsConfiguration();
    config.setQueueName("test-queue");
    config.setAmazonSQSClient(amazonSQSClient);
    endpoint = new SqsEndpoint("aws-sqs://test-queue", new SqsComponent(new DefaultCamelContext()), config);
}
Also used : AmazonSQSClient(com.amazonaws.services.sqs.AmazonSQSClient) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Before(org.junit.Before)

Example 18 with Before

use of org.junit.Before in project camel by apache.

the class BonitaAuthFilterConnectionTest method setup.

@Before
public void setup() {
    Mockito.when(requestContext.getCookies()).thenReturn(new HashMap<String, Cookie>());
    Mockito.when(requestContext.getHeaders()).thenReturn(new MultivaluedHashMap());
}
Also used : Cookie(javax.ws.rs.core.Cookie) MultivaluedHashMap(javax.ws.rs.core.MultivaluedHashMap) Before(org.junit.Before)

Example 19 with Before

use of org.junit.Before in project camel by apache.

the class SftpServerTestSupport method setUp.

@Override
@Before
public void setUp() throws Exception {
    deleteDirectory(FTP_ROOT_DIR);
    oldUserHome = System.getProperty("user.home");
    System.setProperty("user.home", "target/user-home");
    String simulatedUserHome = "target/user-home";
    String simulatedUserSsh = "target/user-home/.ssh";
    deleteDirectory(simulatedUserHome);
    createDirectory(simulatedUserHome);
    createDirectory(simulatedUserSsh);
    FileUtils.copyInputStreamToFile(getClass().getClassLoader().getResourceAsStream("known_hosts"), new File(simulatedUserSsh + "/known_hosts"));
    super.setUp();
    setUpServer();
}
Also used : File(java.io.File) Before(org.junit.Before)

Example 20 with Before

use of org.junit.Before in project camel by apache.

the class FtpServerTestSupport method setUp.

@Override
@Before
public void setUp() throws Exception {
    deleteDirectory(FTP_ROOT_DIR);
    canTest = false;
    FtpServerFactory factory = createFtpServerFactory();
    if (factory != null) {
        ftpServer = factory.createServer();
        if (ftpServer != null) {
            ftpServer.start();
            canTest = true;
        }
    }
    try {
        super.setUp();
    } catch (Exception e) {
        // ignore if algorithm is not on the OS
        NoSuchAlgorithmException nsae = ObjectHelper.getException(NoSuchAlgorithmException.class, e);
        if (nsae != null) {
            canTest = false;
            String name = System.getProperty("os.name");
            String message = nsae.getMessage();
            log.warn("SunX509 is not avail on this platform [{}] Testing is skipped! Real cause: {}", name, message);
        } else {
            // some other error then throw it so the test can fail
            throw e;
        }
    }
}
Also used : FtpServerFactory(org.apache.ftpserver.FtpServerFactory) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)8594 File (java.io.File)733 Properties (java.util.Properties)270 Configuration (org.apache.hadoop.conf.Configuration)266 TreeMap (java.util.TreeMap)247 ArrayList (java.util.ArrayList)228 HashMap (java.util.HashMap)162 IOException (java.io.IOException)159 URL (java.net.URL)137 Path (org.apache.hadoop.fs.Path)130 Config (com.hazelcast.config.Config)115 HazelcastInstance (com.hazelcast.core.HazelcastInstance)111 InputStream (java.io.InputStream)109 Date (java.util.Date)96 InvocationOnMock (org.mockito.invocation.InvocationOnMock)96 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)92 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)90 ByteArrayOutputStream (java.io.ByteArrayOutputStream)83 Connection (java.sql.Connection)78 Random (java.util.Random)75