use of org.apache.cxf.jaxrs.Customer.CustomerContext in project cxf by apache.
the class JAXRSUtilsTest method testInjectCustomContext.
@Test
public void testInjectCustomContext() throws Exception {
final CustomerContext contextImpl = new CustomerContext() {
public String get() {
return "customerContext";
}
};
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
Customer customer = new Customer();
sf.setServiceBeanObjects(customer);
sf.setProvider(new ContextProvider<CustomerContext>() {
public CustomerContext createContext(Message message) {
return contextImpl;
}
});
sf.setStart(false);
Server s = sf.create();
assertTrue(customer.getCustomerContext() instanceof ThreadLocalProxy<?>);
invokeCustomerMethod(sf.getServiceFactory().getClassResourceInfo().get(0), customer, s);
CustomerContext context = customer.getCustomerContext();
assertEquals("customerContext", context.get());
}
Aggregations