Search in sources :

Example 16 with URL

use of java.net.URL in project camel by apache.

the class CxfMtomRouterCxfMessageModeTest method getPort.

@Override
protected Hello getPort() {
    URL wsdl = getClass().getResource("/mtom.wsdl");
    assertNotNull("WSDL is null", wsdl);
    HelloService service = new HelloService(wsdl, HelloService.SERVICE);
    assertNotNull("Service is null ", service);
    Hello port = service.getHelloPort();
    ((BindingProvider) port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + port1 + "/CxfMtomRouterCxfMessageModeTest/jaxws-mtom/hello");
    return port;
}
Also used : Hello(org.apache.camel.cxf.mtom_feature.Hello) HelloService(org.apache.camel.cxf.mtom_feature.HelloService) URL(java.net.URL)

Example 17 with URL

use of java.net.URL in project camel by apache.

the class CxfRsConsumerTest method testGetWrongCustomer.

@Test
public void testGetWrongCustomer() throws Exception {
    URL url = new URL("http://localhost:" + CXT + "/rest/customerservice/customers/456");
    try {
        url.openStream();
        fail("Expect to get exception here");
    } catch (FileNotFoundException exception) {
    // do nothing here
    }
    url = new URL("http://localhost:" + CXT + "/rest/customerservice/customers/234");
    try {
        url.openStream();
        fail("Expect to get exception here");
    } catch (FileNotFoundException exception) {
    // do nothing here
    }
    url = new URL("http://localhost:" + CXT + "/rest/customerservice/customers/256");
    try {
        url.openStream();
        fail("Expect to get exception here");
    } catch (IOException exception) {
    // expect the Internal error exception
    }
}
Also used : FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) URL(java.net.URL) Test(org.junit.Test)

Example 18 with URL

use of java.net.URL in project camel by apache.

the class WSRMTest method testWSAddressing.

@Test
public void testWSAddressing() throws Exception {
    JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean();
    ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
    clientBean.setAddress(getClientAddress());
    clientBean.setServiceClass(HelloWorld.class);
    clientBean.setWsdlURL(WSRMTest.class.getResource("/HelloWorld.wsdl").toString());
    SpringBusFactory bf = new SpringBusFactory();
    URL cxfConfig = null;
    if (getCxfClientConfig() != null) {
        cxfConfig = ClassLoaderUtils.getResource(getCxfClientConfig(), this.getClass());
    }
    proxyFactory.setBus(bf.createBus(cxfConfig));
    proxyFactory.getOutInterceptors().add(new MessageLossSimulator());
    HelloWorld client = (HelloWorld) proxyFactory.create();
    String result = client.sayHi("world!");
    assertEquals("Get a wrong response", "Hello world!", result);
}
Also used : SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) ClientFactoryBean(org.apache.cxf.frontend.ClientFactoryBean) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) URL(java.net.URL) Test(org.junit.Test)

Example 19 with URL

use of java.net.URL in project camel by apache.

the class WSSecurityRouteTest method testSignature.

@Test
public void testSignature() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = WSSecurityRouteTest.class.getResource("../client/wssec.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    GreeterService gs = new GreeterService();
    Greeter greeter = gs.getGreeterSignaturePort();
    ((BindingProvider) greeter).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + CXFTestSupport.getPort2() + "/WSSecurityRouteTest/GreeterSignaturePort");
    assertEquals("Get a wrong response", "Hello Security", greeter.greetMe("Security"));
}
Also used : Bus(org.apache.cxf.Bus) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) Greeter(org.apache.camel.hello_world_soap_http.Greeter) GreeterService(org.apache.camel.hello_world_soap_http.GreeterService) URL(java.net.URL) Test(org.junit.Test)

Example 20 with URL

use of java.net.URL in project camel by apache.

the class WSSecurityRouteTest method testEncryption.

@Test
public void testEncryption() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = WSSecurityRouteTest.class.getResource("../client/wssec.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    GreeterService gs = new GreeterService();
    Greeter greeter = gs.getGreeterEncryptionPort();
    ((BindingProvider) greeter).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + CXFTestSupport.getPort2() + "/WSSecurityRouteTest/GreeterEncryptionPort");
    assertEquals("Get a wrong response", "Hello Security", greeter.greetMe("Security"));
}
Also used : Bus(org.apache.cxf.Bus) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) Greeter(org.apache.camel.hello_world_soap_http.Greeter) GreeterService(org.apache.camel.hello_world_soap_http.GreeterService) URL(java.net.URL) Test(org.junit.Test)

Aggregations

URL (java.net.URL)8112 IOException (java.io.IOException)2006 Test (org.junit.Test)1653 File (java.io.File)1638 MalformedURLException (java.net.MalformedURLException)1165 HttpURLConnection (java.net.HttpURLConnection)1030 InputStream (java.io.InputStream)1028 ArrayList (java.util.ArrayList)633 URLConnection (java.net.URLConnection)515 InputStreamReader (java.io.InputStreamReader)473 URLClassLoader (java.net.URLClassLoader)451 BufferedReader (java.io.BufferedReader)390 HashMap (java.util.HashMap)361 URISyntaxException (java.net.URISyntaxException)286 URI (java.net.URI)269 Map (java.util.Map)259 FileInputStream (java.io.FileInputStream)227 List (java.util.List)205 FileOutputStream (java.io.FileOutputStream)194 OutputStream (java.io.OutputStream)194