use of org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean in project tesb-rt-se by Talend.
the class SAMLRESTUtilsTest method configureServerTest.
@Test
public void configureServerTest() throws Exception {
AbstractJAXRSFactoryBean serverFactory = createMock(AbstractJAXRSFactoryBean.class);
Map<String, Object> properties = new HashMap<String, Object>();
expect(serverFactory.getProperties(true)).andReturn(properties).anyTimes();
Map<String, Object> securityProps = new HashMap<String, Object>();
serverFactory.setProvider(EasyMock.<Object>anyObject());
EasyMock.expectLastCall().once();
replay(serverFactory);
SAMLRESTUtils.configureServer(serverFactory, securityProps);
assertTrue(properties.containsKey(SecurityConstants.SIGNATURE_PROPERTIES));
assertTrue(properties.containsKey(SecurityConstants.CALLBACK_HANDLER));
assertTrue(properties.containsKey(SecurityConstants.SIGNATURE_USERNAME));
EasyMock.verify(serverFactory);
}
use of org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean in project camel by apache.
the class CxfRsComponent method createEndpoint.
@Override
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
CxfRsEndpoint answer;
Object value = parameters.remove("setDefaultBus");
if (value != null) {
LOG.warn("The option setDefaultBus is @deprecated, use name defaultBus instead");
if (!parameters.containsKey("defaultBus")) {
parameters.put("defaultBus", value);
}
}
if (remaining.startsWith(CxfConstants.SPRING_CONTEXT_ENDPOINT)) {
// Get the bean from the Spring context
String beanId = remaining.substring(CxfConstants.SPRING_CONTEXT_ENDPOINT.length());
if (beanId.startsWith("//")) {
beanId = beanId.substring(2);
}
AbstractJAXRSFactoryBean bean = CamelContextHelper.mandatoryLookup(getCamelContext(), beanId, AbstractJAXRSFactoryBean.class);
if (bean instanceof BlueprintSupport) {
answer = new CxfRsBlueprintEndpoint(this, remaining, bean);
} else {
answer = new CxfRsSpringEndpoint(this, remaining, bean);
}
// with to apply properties defined by URI query.
if (bean.getProperties() != null) {
Map<String, Object> copy = new HashMap<String, Object>();
copy.putAll(bean.getProperties());
setProperties(answer, copy);
}
// setup the skipFaultLogging
answer.setBeanId(beanId);
} else {
// endpoint URI does not specify a bean
answer = new CxfRsEndpoint(remaining, this);
}
String resourceClass = getAndRemoveParameter(parameters, "resourceClass", String.class);
if (resourceClass != null) {
Class<?> clazz = getCamelContext().getClassResolver().resolveMandatoryClass(resourceClass);
answer.addResourceClass(clazz);
}
String resourceClasses = getAndRemoveParameter(parameters, "resourceClasses", String.class);
Iterator<?> it = ObjectHelper.createIterator(resourceClasses);
while (it.hasNext()) {
String name = (String) it.next();
Class<?> clazz = getCamelContext().getClassResolver().resolveMandatoryClass(name);
answer.addResourceClass(clazz);
}
setProperties(answer, parameters);
Map<String, String> params = CastUtils.cast(parameters);
answer.setParameters(params);
setEndpointHeaderFilterStrategy(answer);
return answer;
}
use of org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean in project tesb-rt-se by Talend.
the class SAMLRESTUtilsTest method configureClientTest.
@Test
public void configureClientTest() throws Exception {
AbstractJAXRSFactoryBean clientFactory = createMock(AbstractJAXRSFactoryBean.class);
STSClient stsClient = createMock(STSClient.class);
List<Interceptor<? extends Message>> interceptors = new ArrayList<Interceptor<? extends Message>>();
expect(clientFactory.getOutInterceptors()).andReturn(interceptors).anyTimes();
replay(clientFactory);
SAMLRESTUtils.configureClient(clientFactory, stsClient);
assertFalse(interceptors.isEmpty());
for (Interceptor<? extends Message> i : interceptors) {
if (i instanceof STSRESTOutInterceptor) {
assertSame(((STSRESTOutInterceptor) i).getStsClient(), stsClient);
}
}
EasyMock.verify(clientFactory);
}
Aggregations