use of org.apache.cxf.jaxrs.CustomerApplication in project cxf by apache.
the class JAXRSUtilsTest method testInjectApplicationInPerRequestResource.
@Test
public void testInjectApplicationInPerRequestResource() throws Exception {
CustomerApplication app = new CustomerApplication();
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setServiceClass(Customer.class);
sf.setApplication(app);
sf.setStart(false);
Server server = sf.create();
@SuppressWarnings("unchecked") ThreadLocalProxy<UriInfo> proxy = (ThreadLocalProxy<UriInfo>) app.getUriInfo();
assertNotNull(proxy);
ClassResourceInfo cri = sf.getServiceFactory().getClassResourceInfo().get(0);
Customer customer = (Customer) cri.getResourceProvider().getInstance(createMessage());
assertNull(customer.getApplication1());
assertNull(customer.getApplication2());
invokeCustomerMethod(cri, customer, server);
assertSame(app, customer.getApplication1());
assertSame(app, customer.getApplication2());
assertTrue(proxy.get() instanceof UriInfo);
}
use of org.apache.cxf.jaxrs.CustomerApplication in project cxf by apache.
the class JAXRSUtilsTest method testInjectApplicationInSingleton.
@Test
public void testInjectApplicationInSingleton() throws Exception {
CustomerApplication app = new CustomerApplication();
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
Customer customer = new Customer();
sf.setServiceBeanObjects(customer);
sf.setApplication(app);
sf.setStart(false);
Server server = sf.create();
assertSame(app, customer.getApplication1());
assertSame(app, customer.getApplication2());
@SuppressWarnings("unchecked") ThreadLocalProxy<UriInfo> proxy = (ThreadLocalProxy<UriInfo>) app.getUriInfo();
assertNotNull(proxy);
invokeCustomerMethod(sf.getServiceFactory().getClassResourceInfo().get(0), customer, server);
assertSame(app, customer.getApplication2());
assertTrue(proxy.get() instanceof UriInfo);
}
Aggregations