use of org.apache.cxf.message.Message in project cxf by apache.
the class EHCacheTokenStoreTest method init.
@BeforeClass
public static void init() {
TokenStoreFactory tokenStoreFactory = new EHCacheTokenStoreFactory();
Message message = new MessageImpl();
message.put(SecurityConstants.CACHE_CONFIG_FILE, ClassLoaderUtils.getResource("cxf-ehcache.xml", EHCacheTokenStoreTest.class));
message.setExchange(new ExchangeImpl());
store = tokenStoreFactory.newTokenStore(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE, message);
}
use of org.apache.cxf.message.Message in project cxf by apache.
the class MemoryTokenStoreTest method init.
@BeforeClass
public static void init() {
TokenStoreFactory tokenStoreFactory = new MemoryTokenStoreFactory();
Message message = new MessageImpl();
store = tokenStoreFactory.newTokenStore(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE, message);
}
use of org.apache.cxf.message.Message in project fabric8 by jboss-fuse.
the class FailOverClientServerTest method testClientServer.
@Test
public void testClientServer() throws Exception {
assertNotNull(bus);
// The bus is load the feature
JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
factory.setServiceBean(new HelloImpl());
factory.setAddress("http://localhost:9000/fail/server");
factory.setBus(bus);
factory.create();
factory = new JaxWsServerFactoryBean();
factory.setServiceBean(new HelloImpl());
factory.setAddress("http://localhost:9000/simple/server");
factory.setBus(bus);
factory.create();
// sleep a while to let the service be published
for (int i = 0; i < 100; i++) {
if (!feature.getLoadBalanceStrategy().getAlternateAddressList().isEmpty()) {
break;
}
Thread.sleep(100);
}
JaxWsProxyFactoryBean clientFactory = new JaxWsProxyFactoryBean();
clientFactory.setServiceClass(Hello.class);
// The address is not the actual address that the client will access
clientFactory.setAddress("http://someotherplace");
List<AbstractFeature> features = new ArrayList<AbstractFeature>();
// add the instance of FabricLoadBalancerFeature into features list
features.add(feature);
// we need to setup the feature on the clientfactory
clientFactory.setFeatures(features);
// set this interceptor to simulate the Transport level exception
List<Interceptor<? extends Message>> outInterceptor = new ArrayList<Interceptor<? extends Message>>();
outInterceptor.add(new TransportFailureInterceptor());
clientFactory.setOutInterceptors(outInterceptor);
Hello hello = clientFactory.create(Hello.class);
String response = hello.sayHello();
assertEquals("Get a wrong response", "Hello", response);
response = hello.sayHello();
assertEquals("Get a wrong response", "Hello", response);
}
use of org.apache.cxf.message.Message in project wildfly-camel by wildfly-extras.
the class CXFWSJAASAuthenticationIntegrationTest method configureCamelContext.
private CamelContext configureCamelContext(String password) throws Exception {
CamelContext camelctx = new DefaultCamelContext();
CxfComponent component = new CxfComponent(camelctx);
CxfEndpoint consumerEndpoint = new CxfEndpoint("http://localhost:8080/webservices/greeting", component);
consumerEndpoint.setServiceClass(Endpoint.class);
List<Interceptor<? extends Message>> inInterceptors = consumerEndpoint.getInInterceptors();
JAASLoginInterceptor interceptor = new JAASLoginInterceptor();
interceptor.setContextName("other");
inInterceptors.add(interceptor);
CxfEndpoint producerEndpoint = new CxfEndpoint("http://localhost:8080/webservices/greeting", component);
producerEndpoint.setServiceClass(Endpoint.class);
producerEndpoint.setUsername("user1");
producerEndpoint.setPassword(password);
Map<String, Object> properties = producerEndpoint.getProperties();
if (properties == null) {
producerEndpoint.setProperties(new HashMap<>());
}
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").to(producerEndpoint);
from(consumerEndpoint).process(exchange -> {
Object[] args = exchange.getIn().getBody(Object[].class);
exchange.getOut().setBody("Hello " + args[0]);
});
}
});
return camelctx;
}
use of org.apache.cxf.message.Message in project wildfly-camel by wildfly-extras.
the class CXFWSInterceptorTest method testCXFInterceptor.
@Test
public void testCXFInterceptor() throws Exception {
CountDownLatch latch = new CountDownLatch(1);
CamelContext camelctx = new DefaultCamelContext();
CxfComponent component = new CxfComponent(camelctx);
CxfEndpoint cxfEndpoint = new CxfEndpoint("http://localhost:8080/EndpointService/EndpointPort", component);
cxfEndpoint.setServiceClass(Endpoint.class);
List<Interceptor<? extends Message>> inInterceptors = cxfEndpoint.getInInterceptors();
inInterceptors.add(new CountDownInterceptor(latch));
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from(cxfEndpoint).setBody(constant("Hello ${body}"));
}
});
camelctx.start();
try {
QName qname = new QName("http://wildfly.camel.test.cxf", "EndpointService");
Service service = Service.create(new URL("http://localhost:8080/EndpointService/EndpointPort?wsdl"), qname);
Endpoint endpoint = service.getPort(Endpoint.class);
endpoint.echo("Kermit");
Assert.assertTrue("Gave up waiting for CXF interceptor handleMessage", latch.await(5, TimeUnit.SECONDS));
} finally {
camelctx.stop();
}
}
Aggregations