org.apache.cxf.transport.local.LocalTransportFactory Java Examples
The following examples show how to use
org.apache.cxf.transport.local.LocalTransportFactory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StaxDatabindingTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testCopy() throws Exception { String address = "local://foo"; ServerFactoryBean sf = new ServerFactoryBean(); sf.setServiceBean(new CopyService()); sf.setBus(getBus()); sf.setTransportId(LocalTransportFactory.TRANSPORT_ID); sf.setAddress(address); sf.setDataBinding(new StaxDataBinding()); sf.getFeatures().add(new StaxDataBindingFeature()); sf.create().start(); Node res = invoke(address, LocalTransportFactory.TRANSPORT_ID, "req.xml"); //DOMUtils.writeXml(res, System.out); addNamespace("a", "http://stax.service.cxf.apache.org/"); assertValid("//a:bleh", res); }
Example #2
Source File: ProviderServiceFactoryTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testSourceMessageProviderCodeFirst() throws Exception { JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean(); svrFactory.setServiceClass(SourceMessageProvider.class); svrFactory.setBus(getBus()); svrFactory.setServiceBean(new SourceMessageProvider()); String address = "local://localhost:9000/test"; svrFactory.setAddress(address); svrFactory.create(); Node res = invoke(address, LocalTransportFactory.TRANSPORT_ID, "/org/apache/cxf/jaxws/sayHi.xml"); addNamespace("j", "http://service.jaxws.cxf.apache.org/"); assertValid("/s:Envelope/s:Body/j:sayHi", res); }
Example #3
Source File: ProviderTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testInvocation() throws Exception { try (EndpointImpl ep = new EndpointImpl(getBus(), new PayloadProvider(), (String) null)) { ep.publish("local://localhost:9000/Provider"); Node response = invoke("local://localhost:9000/Provider", LocalTransportFactory.TRANSPORT_ID, "/org/apache/cxf/jaxws/sayHi.xml"); assertNotNull(response); assertNoFault(response); addNamespace("j", "http://service.jaxws.cxf.apache.org/"); assertValid("//s:Body/j:sayHi", response); } }
Example #4
Source File: ProviderTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testCXF1852() throws Exception { try (EndpointImpl ep = new EndpointImpl(getBus(), new PayloadProvider2(), (String) null)) { ep.publish("local://localhost:9001/Provider2"); Node response = invoke("local://localhost:9001/Provider2", LocalTransportFactory.TRANSPORT_ID, "/org/apache/cxf/jaxws/sayHi.xml"); assertNotNull(response); assertNoFault(response); addNamespace("j", "http://service.jaxws.cxf.apache.org/"); assertValid("//s:Body/j:sayHi", response); } }
Example #5
Source File: ProviderServiceFactoryTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testStreamSourceProviderCodeFirst() throws Exception { JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean(); svrFactory.setServiceClass(StreamSourcePayloadProvider.class); svrFactory.setBus(getBus()); svrFactory.setServiceBean(new StreamSourcePayloadProvider()); String address = "http://localhost:9000/test"; svrFactory.setAddress(address); svrFactory.setTransportId(LocalTransportFactory.TRANSPORT_ID); svrFactory.create(); Node res = invoke(address, LocalTransportFactory.TRANSPORT_ID, "/org/apache/cxf/jaxws/sayHi.xml"); addNamespace("j", "http://service.jaxws.cxf.apache.org/"); assertValid("/s:Envelope/s:Body/j:sayHi", res); }
Example #6
Source File: ConfiguredEndpointTest.java From cxf with Apache License 2.0 | 6 votes |
private void initializeBus() { Bus bus = BusFactory.getDefaultBus(); SoapBindingFactory bindingFactory = new SoapBindingFactory(); bus.getExtension(BindingFactoryManager.class) .registerBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/", bindingFactory); DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class); SoapTransportFactory soapDF = new SoapTransportFactory(); dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/", soapDF); dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/", soapDF); LocalTransportFactory localTransport = new LocalTransportFactory(); dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/http", localTransport); dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/http", localTransport); }
Example #7
Source File: DocLitBareTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testNamespaceCrash() { ServerFactoryBean svrFactory = new ServerFactoryBean(); svrFactory.setServiceClass(University.class); svrFactory.setTransportId(LocalTransportFactory.TRANSPORT_ID); svrFactory.setAddress("local://dlbTest"); svrFactory.setServiceBean(new UniversityImpl()); svrFactory.getServiceFactory().setDataBinding(new AegisDatabinding()); svrFactory.create(); ClientProxyFactoryBean factory = new ClientProxyFactoryBean(); factory.getServiceFactory().setDataBinding(new AegisDatabinding()); factory.setServiceClass(University.class); factory.setTransportId(LocalTransportFactory.TRANSPORT_ID); factory.setAddress("local://dlbTest"); University client = (University) factory.create(); Teacher tr = client.getTeacher(new Course(40, "Intro to CS", "Introductory Comp Sci")); assertNotNull(tr); assertEquals(52, tr.getAge()); assertEquals("Mr. Tom", tr.getName()); }
Example #8
Source File: StaxDatabindingTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testCallback() throws Exception { String address = "local://foo"; ServerFactoryBean sf = new ServerFactoryBean(); sf.setServiceBean(new CallbackService()); sf.setTransportId(LocalTransportFactory.TRANSPORT_ID); sf.setAddress(address); sf.setDataBinding(new StaxDataBinding()); sf.getFeatures().add(new StaxDataBindingFeature()); sf.setBus(getBus()); sf.create(); Node res = invoke(address, LocalTransportFactory.TRANSPORT_ID, "req.xml"); assertValid("//bleh", res); }
Example #9
Source File: JAXRSLocalTransportTest.java From cxf with Apache License 2.0 | 6 votes |
@Before public void setUp() { JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); sf.setResourceClasses(BookStore.class, BookStoreSpring.class); sf.setResourceProvider(BookStore.class, new SingletonResourceProvider(new BookStore(), true)); sf.setResourceProvider(BookStoreSpring.class, new SingletonResourceProvider(new BookStoreSpring(), true)); sf.setProvider(new JacksonJsonProvider()); List<Interceptor<? extends Message>> outInts = new ArrayList<>(); outInts.add(new CustomOutInterceptor()); sf.setOutInterceptors(outInts); List<Interceptor<? extends Message>> inInts = new ArrayList<>(); inInts.add(new CustomInFaultyInterceptor()); sf.setInInterceptors(inInts); sf.setTransportId(LocalTransportFactory.TRANSPORT_ID); sf.setAddress("local://books"); localServer = sf.create(); }
Example #10
Source File: AbstractCXFTest.java From sakai with Educational Community License v2.0 | 6 votes |
/** * This is a utility method that contains some mocks that are required for cxf local testing. * It adds the <code>HTTP.REQUEST</code> to the request context. * @param client the cxf client from the test */ protected void addCXFClientMocks(WebClient client) { Map<String, Object> requestContext = WebClient.getConfig(client).getRequestContext(); requestContext.put(LocalConduit.DIRECT_DISPATCH, Boolean.TRUE); // cxf workaround for using a HttpServletRequest in a local:// call HashSet<String> include = new HashSet<>(); include.add(AbstractHTTPDestination.HTTP_REQUEST); requestContext.put(LocalTransportFactory.MESSAGE_INCLUDE_PROPERTIES, include); HttpServletRequest mockRequest = mock(HttpServletRequest.class); when(mockRequest.getRemoteAddr()).thenReturn("127.0.0.1"); when(mockRequest.getRequestURL()).thenReturn(new StringBuffer()); when(mockRequest.getPathInfo()).thenReturn(""); when(mockRequest.getContextPath()).thenReturn(""); when(mockRequest.getServletPath()).thenReturn(""); requestContext.put(AbstractHTTPDestination.HTTP_REQUEST, mockRequest); }
Example #11
Source File: AbstractCXFTest.java From sakai with Educational Community License v2.0 | 6 votes |
/** * This is a utility method that contains some mocks that are required for cxf local testing. * It adds the <code>HTTP.REQUEST</code> to the request context. * @param client the cxf client from the test */ protected void addCXFClientMocks(WebClient client) { Map<String, Object> requestContext = WebClient.getConfig(client).getRequestContext(); requestContext.put(LocalConduit.DIRECT_DISPATCH, Boolean.TRUE); // cxf workaround for using a HttpServletRequest in a local:// call HashSet<String> include = new HashSet<>(); include.add(AbstractHTTPDestination.HTTP_REQUEST); requestContext.put(LocalTransportFactory.MESSAGE_INCLUDE_PROPERTIES, include); HttpServletRequest mockRequest = mock(HttpServletRequest.class); when(mockRequest.getRemoteAddr()).thenReturn("127.0.0.1"); when(mockRequest.getRequestURL()).thenReturn(new StringBuffer()); when(mockRequest.getPathInfo()).thenReturn(""); when(mockRequest.getContextPath()).thenReturn(""); when(mockRequest.getServletPath()).thenReturn(""); requestContext.put(AbstractHTTPDestination.HTTP_REQUEST, mockRequest); }
Example #12
Source File: JAXWSEnvironmentTest.java From dropwizard-jaxws with Apache License 2.0 | 6 votes |
@Test public void publishEndpointWithHibernateInvoker() throws Exception { jaxwsEnvironment.publishEndpoint( new EndpointBuilder("local://path", service) .sessionFactory(mock(SessionFactory.class))); verify(mockInvokerBuilder).create(any(), any(Invoker.class)); verify(mockUnitOfWorkInvokerBuilder).create(any(), any(Invoker.class), any(SessionFactory.class)); Node soapResponse = testutils.invoke("local://path", LocalTransportFactory.TRANSPORT_ID, soapRequest.getBytes()); verify(mockInvoker).invoke(any(Exchange.class), any()); testutils.assertValid("/soap:Envelope/soap:Body/a:fooResponse", soapResponse); }
Example #13
Source File: JAXWSEnvironmentTest.java From dropwizard-jaxws with Apache License 2.0 | 6 votes |
@Test public void publishEndpointWithMtom() throws Exception { jaxwsEnvironment.publishEndpoint( new EndpointBuilder("local://path", service) .enableMtom()); verify(mockInvokerBuilder).create(any(), any(Invoker.class)); byte[] response = testutils.invokeBytes("local://path", LocalTransportFactory.TRANSPORT_ID, soapRequest.getBytes()); verify(mockInvoker).invoke(any(Exchange.class), any()); MimeMultipart mimeMultipart = new MimeMultipart(new ByteArrayDataSource(response, "application/xop+xml; charset=UTF-8; type=\"text/xml\"")); assertThat(mimeMultipart.getCount(), equalTo(1)); testutils.assertValid("/soap:Envelope/soap:Body/a:fooResponse", StaxUtils.read(mimeMultipart.getBodyPart(0).getInputStream())); }
Example #14
Source File: JAXWSEnvironmentTest.java From dropwizard-jaxws with Apache License 2.0 | 6 votes |
@Test public void publishEndpointWithProperties() throws Exception { HashMap<String, Object> props = new HashMap<>(); props.put("key", "value"); Endpoint e = jaxwsEnvironment.publishEndpoint( new EndpointBuilder("local://path", service) .properties(props)); assertThat(e, is(notNullValue())); assertThat(e.getProperties().get("key"), equalTo("value")); verify(mockInvokerBuilder).create(any(), any(Invoker.class)); verifyZeroInteractions(mockUnitOfWorkInvokerBuilder); Node soapResponse = testutils.invoke("local://path", LocalTransportFactory.TRANSPORT_ID, soapRequest.getBytes()); verify(mockInvoker).invoke(any(Exchange.class), any()); testutils.assertValid("/soap:Envelope/soap:Body/a:fooResponse", soapResponse); }
Example #15
Source File: JAXWSEnvironmentTest.java From dropwizard-jaxws with Apache License 2.0 | 5 votes |
@Test public void publishEndpointWithCxfInterceptors() throws Exception { TestInterceptor inInterceptor = new TestInterceptor(Phase.UNMARSHAL); TestInterceptor inInterceptor2 = new TestInterceptor(Phase.PRE_INVOKE); TestInterceptor outInterceptor = new TestInterceptor(Phase.MARSHAL); jaxwsEnvironment.publishEndpoint( new EndpointBuilder("local://path", service) .cxfInInterceptors(inInterceptor, inInterceptor2) .cxfOutInterceptors(outInterceptor)); verify(mockInvokerBuilder).create(any(), any(Invoker.class)); Node soapResponse = testutils.invoke("local://path", LocalTransportFactory.TRANSPORT_ID, soapRequest.getBytes()); verify(mockInvoker).invoke(any(Exchange.class), any()); assertThat(inInterceptor.getInvocationCount(), equalTo(1)); assertThat(inInterceptor2.getInvocationCount(), equalTo(1)); assertThat(outInterceptor.getInvocationCount(), equalTo(1)); testutils.assertValid("/soap:Envelope/soap:Body/a:fooResponse", soapResponse); soapResponse = testutils.invoke("local://path", LocalTransportFactory.TRANSPORT_ID, soapRequest.getBytes()); verify(mockInvoker, times(2)).invoke(any(Exchange.class), any()); assertThat(inInterceptor.getInvocationCount(), equalTo(2)); assertThat(inInterceptor2.getInvocationCount(), equalTo(2)); assertThat(outInterceptor.getInvocationCount(), equalTo(2)); testutils.assertValid("/soap:Envelope/soap:Body/a:fooResponse", soapResponse); }
Example #16
Source File: StaxToDOMSignatureIdentifierTest.java From cxf with Apache License 2.0 | 5 votes |
private Echo createClientProxy() { JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean(); proxyFac.setServiceClass(Echo.class); proxyFac.setAddress("local://Echo"); proxyFac.getClientFactoryBean().setTransportId(LocalTransportFactory.TRANSPORT_ID); return (Echo)proxyFac.create(); }
Example #17
Source File: RESTLoggingTest.java From cxf with Apache License 2.0 | 5 votes |
private WebClient createClient(String serviceURI, LoggingFeature loggingFeature) { JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); bean.setAddress(serviceURI); bean.setFeatures(Collections.singletonList(loggingFeature)); bean.setTransportId(LocalTransportFactory.TRANSPORT_ID); return bean.createWebClient().path("test1"); }
Example #18
Source File: ClientCacheTest.java From cxf with Apache License 2.0 | 5 votes |
@BeforeClass public static void bind() throws Exception { final JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); sf.setResourceClasses(TheServer.class); sf.setResourceProvider(TheServer.class, new SingletonResourceProvider(new TheServer(), false)); sf.setTransportId(LocalTransportFactory.TRANSPORT_ID); sf.setAddress(ADDRESS); server = sf.create(); }
Example #19
Source File: StaxToDOMSignatureIdentifierTest.java From cxf with Apache License 2.0 | 5 votes |
private Service createService() { // Create the Service JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean(); factory.setServiceBean(new EchoImpl()); factory.setAddress("local://Echo"); factory.setTransportId(LocalTransportFactory.TRANSPORT_ID); Server server = factory.create(); Service service = server.getEndpoint().getService(); service.getInInterceptors().add(new LoggingInInterceptor()); service.getOutInterceptors().add(new LoggingOutInterceptor()); return service; }
Example #20
Source File: RESTLoggingTest.java From cxf with Apache License 2.0 | 5 votes |
private Server createService(String serviceURI, Object serviceImpl, LoggingFeature loggingFeature) { JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean(); factory.setAddress(serviceURI); factory.setFeatures(Collections.singletonList(loggingFeature)); factory.setServiceBean(serviceImpl); factory.setTransportId(LocalTransportFactory.TRANSPORT_ID); return factory.create(); }
Example #21
Source File: DOMToStaxSignatureIdentifierTest.java From cxf with Apache License 2.0 | 5 votes |
private Echo createClientProxy() { JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean(); proxyFac.setServiceClass(Echo.class); proxyFac.setAddress("local://Echo"); proxyFac.getClientFactoryBean().setTransportId(LocalTransportFactory.TRANSPORT_ID); return (Echo)proxyFac.create(); }
Example #22
Source File: StaxCryptoCoverageCheckerTest.java From cxf with Apache License 2.0 | 5 votes |
private Echo createClientProxy() { JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean(); proxyFac.setServiceClass(Echo.class); proxyFac.setAddress("local://Echo"); proxyFac.getClientFactoryBean().setTransportId(LocalTransportFactory.TRANSPORT_ID); return (Echo)proxyFac.create(); }
Example #23
Source File: DOMToStaxSignatureIdentifierTest.java From cxf with Apache License 2.0 | 5 votes |
private Service createService() { // Create the Service JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean(); factory.setServiceBean(new EchoImpl()); factory.setAddress("local://Echo"); factory.setTransportId(LocalTransportFactory.TRANSPORT_ID); Server server = factory.create(); Service service = server.getEndpoint().getService(); service.getInInterceptors().add(new LoggingInInterceptor()); service.getOutInterceptors().add(new LoggingOutInterceptor()); return service; }
Example #24
Source File: StaxToDOMSamlTest.java From cxf with Apache License 2.0 | 5 votes |
private Echo createClientProxy() { JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean(); proxyFac.setServiceClass(Echo.class); proxyFac.setAddress("local://Echo"); proxyFac.getClientFactoryBean().setTransportId(LocalTransportFactory.TRANSPORT_ID); return (Echo)proxyFac.create(); }
Example #25
Source File: StaxToDOMSamlTest.java From cxf with Apache License 2.0 | 5 votes |
private Service createService() { // Create the Service JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean(); factory.setServiceBean(new EchoImpl()); factory.setAddress("local://Echo"); factory.setTransportId(LocalTransportFactory.TRANSPORT_ID); Server server = factory.create(); Service service = server.getEndpoint().getService(); service.getInInterceptors().add(new LoggingInInterceptor()); service.getOutInterceptors().add(new LoggingOutInterceptor()); return service; }
Example #26
Source File: DOMToStaxSamlTest.java From cxf with Apache License 2.0 | 5 votes |
private Echo createClientProxy() { JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean(); proxyFac.setServiceClass(Echo.class); proxyFac.setAddress("local://Echo"); proxyFac.getClientFactoryBean().setTransportId(LocalTransportFactory.TRANSPORT_ID); return (Echo)proxyFac.create(); }
Example #27
Source File: DOMToStaxSamlTest.java From cxf with Apache License 2.0 | 5 votes |
private Service createService() { // Create the Service JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean(); factory.setServiceBean(new EchoImpl()); factory.setAddress("local://Echo"); factory.setTransportId(LocalTransportFactory.TRANSPORT_ID); Server server = factory.create(); Service service = server.getEndpoint().getService(); service.getInInterceptors().add(new LoggingInInterceptor()); service.getOutInterceptors().add(new LoggingOutInterceptor()); return service; }
Example #28
Source File: StaxRoundTripTest.java From cxf with Apache License 2.0 | 5 votes |
private Echo createClientProxy() { JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean(); proxyFac.setServiceClass(Echo.class); proxyFac.setAddress("local://Echo"); proxyFac.getClientFactoryBean().setTransportId(LocalTransportFactory.TRANSPORT_ID); return (Echo)proxyFac.create(); }
Example #29
Source File: StaxRoundTripTest.java From cxf with Apache License 2.0 | 5 votes |
private Service createService() { // Create the Service JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean(); factory.setServiceBean(new EchoImpl()); factory.setAddress("local://Echo"); factory.setTransportId(LocalTransportFactory.TRANSPORT_ID); Server server = factory.create(); Service service = server.getEndpoint().getService(); service.getInInterceptors().add(new LoggingInInterceptor()); service.getOutInterceptors().add(new LoggingOutInterceptor()); return service; }
Example #30
Source File: AbstractSimpleFrontendTest.java From cxf with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { super.setUpBus(); Bus bus = getBus(); SoapBindingFactory bindingFactory = new SoapBindingFactory(); bus.getExtension(BindingFactoryManager.class) .registerBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/", bindingFactory); DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class); SoapTransportFactory soapTF = new SoapTransportFactory(); dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/", soapTF); dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/", soapTF); LocalTransportFactory localTransport = new LocalTransportFactory(); localTransport.getUriPrefixes().add("http"); dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/http", localTransport); dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/http", localTransport); ConduitInitiatorManager extension = bus.getExtension(ConduitInitiatorManager.class); extension.registerConduitInitiator(LocalTransportFactory.TRANSPORT_ID, localTransport); extension.registerConduitInitiator("http://schemas.xmlsoap.org/wsdl/soap/http", localTransport); extension.registerConduitInitiator("http://schemas.xmlsoap.org/soap/http", localTransport); extension.registerConduitInitiator("http://schemas.xmlsoap.org/wsdl/soap/", soapTF); }