Search in sources :

Example 1 with File

use of java.io.File in project camel by apache.

the class CometdProducerConsumerInOutInteractiveMain method createRouteBuilder.

private RouteBuilder createRouteBuilder() {
    return new RouteBuilder() {

        public void configure() {
            CometdComponent component = (CometdComponent) context.getComponent("cometds");
            component.setSslPassword(pwd);
            component.setSslKeyPassword(pwd);
            File file = new File("./src/test/resources/jsse/localhost.ks");
            URI keyStoreUrl = file.toURI();
            component.setSslKeystore(keyStoreUrl.getPath());
            from(URI, URIS).setExchangePattern(ExchangePattern.InOut).process(new Processor() {

                public void process(Exchange exchange) throws Exception {
                    Message out = new DefaultMessage();
                    out.setBody("reply: " + exchange.getIn().getBody());
                    exchange.setOut(out);
                }
            });
        }
    };
}
Also used : Exchange(org.apache.camel.Exchange) DefaultMessage(org.apache.camel.impl.DefaultMessage) Processor(org.apache.camel.Processor) RouteBuilder(org.apache.camel.builder.RouteBuilder) Message(org.apache.camel.Message) DefaultMessage(org.apache.camel.impl.DefaultMessage) File(java.io.File) URI(java.net.URI)

Example 2 with File

use of java.io.File in project camel by apache.

the class CometdProducerConsumerInteractiveAuthenticatedMain method createRouteBuilder.

private RouteBuilder createRouteBuilder() {
    return new RouteBuilder() {

        public void configure() {
            CometdComponent component = (CometdComponent) context.getComponent("cometds");
            component.setSslPassword(pwd);
            component.setSslKeyPassword(pwd);
            CometdComponent component2 = (CometdComponent) context.getComponent("cometd");
            BayeuxAuthenticator bayeuxAuthenticator = new BayeuxAuthenticator();
            component2.setSecurityPolicy(bayeuxAuthenticator);
            component2.addExtension(bayeuxAuthenticator);
            File file = new File("./src/test/resources/jsse/localhost.ks");
            URI keyStoreUrl = file.toURI();
            component.setSslKeystore(keyStoreUrl.getPath());
            from("stream:in").to(URI).to(URIS);
        }
    };
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) File(java.io.File) URI(java.net.URI)

Example 3 with File

use of java.io.File in project camel by apache.

the class CometdProducerConsumerInteractiveExtensionMain method createRouteBuilder.

private RouteBuilder createRouteBuilder() {
    return new RouteBuilder() {

        public void configure() {
            CometdComponent component = (CometdComponent) context.getComponent("cometds");
            component.setSslPassword(pwd);
            component.setSslKeyPassword(pwd);
            CometdComponent component2 = (CometdComponent) context.getComponent("cometd");
            Censor bayeuxAuthenticator = new Censor();
            component2.addExtension(bayeuxAuthenticator);
            File file = new File("./src/test/resources/jsse/localhost.ks");
            URI keyStoreUrl = file.toURI();
            component.setSslKeystore(keyStoreUrl.getPath());
            from("stream:in").to(URI).to(URIS);
        }
    };
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) File(java.io.File) URI(java.net.URI)

Example 4 with File

use of java.io.File in project camel by apache.

the class CometdProducerConsumerInteractiveMain method createRouteBuilder.

private RouteBuilder createRouteBuilder() {
    return new RouteBuilder() {

        public void configure() {
            CometdComponent component = (CometdComponent) context.getComponent("cometds");
            component.setSslPassword(pwd);
            component.setSslKeyPassword(pwd);
            File file = new File("./src/test/resources/jsse/localhost.ks");
            URI keyStoreUrl = file.toURI();
            component.setSslKeystore(keyStoreUrl.getPath());
            from("stream:in").to(URI).to(URIS);
        }
    };
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) File(java.io.File) URI(java.net.URI)

Example 5 with File

use of java.io.File in project camel by apache.

the class CsvUnmarshalStreamTest method testCsvUnMarshalWithFile.

@SuppressWarnings("unchecked")
@Test
public void testCsvUnMarshalWithFile() throws Exception {
    result.reset();
    result.expectedMessageCount(EXPECTED_COUNT);
    template.sendBody("direct:start", new MyFileInputStream(new File("src/test/resources/data.csv")));
    assertMockEndpointsSatisfied();
    for (int i = 0; i < EXPECTED_COUNT; ++i) {
        List<String> body = result.getReceivedExchanges().get(i).getIn().getBody(List.class);
        assertEquals(2, body.size());
        assertEquals(String.valueOf(i), body.get(0));
        assertEquals(String.format("%d%s%d", i, LS, i), body.get(1));
    }
}
Also used : File(java.io.File) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Aggregations

File (java.io.File)45560 IOException (java.io.IOException)9550 Test (org.junit.Test)9009 FileOutputStream (java.io.FileOutputStream)3388 ArrayList (java.util.ArrayList)3273 FileInputStream (java.io.FileInputStream)2915 InputStream (java.io.InputStream)1783 FileNotFoundException (java.io.FileNotFoundException)1743 URL (java.net.URL)1649 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1478 Test (org.testng.annotations.Test)1411 HashMap (java.util.HashMap)1404 RandomAccessFile (java.io.RandomAccessFile)1154 FileWriter (java.io.FileWriter)1081 Properties (java.util.Properties)1019 ZipFile (java.util.zip.ZipFile)959 JarFile (java.util.jar.JarFile)866 List (java.util.List)850 BufferedReader (java.io.BufferedReader)840 OutputStream (java.io.OutputStream)811