use of org.apache.cxf.jaxrs.PriorityCustomerParameterHandler in project cxf by apache.
the class ProviderFactoryTest method testParameterHandlerProviderWithPriority.
@Test
public void testParameterHandlerProviderWithPriority() throws Exception {
ProviderFactory pf = ServerProviderFactory.getInstance();
ParamConverterProvider h = new CustomerParameterHandler();
ParamConverterProvider hp = new PriorityCustomerParameterHandler();
pf.registerUserProvider(h);
pf.registerUserProvider(hp);
ParamConverter<Customer> h2 = pf.createParameterHandler(Customer.class, Customer.class, null, new MessageImpl());
assertSame(h2, hp);
}
use of org.apache.cxf.jaxrs.PriorityCustomerParameterHandler in project cxf by apache.
the class ProviderFactoryTest method testCustomProviderSortingParamConverterProvider.
@Test
public void testCustomProviderSortingParamConverterProvider() {
ParamConverterProvider h = new CustomerParameterHandler();
ParamConverterProvider hp = new PriorityCustomerParameterHandler();
ProviderFactory pf = ServerProviderFactory.getInstance();
pf.setUserProviders(Arrays.asList(h, hp));
Comparator<ProviderInfo<ParamConverterProvider>> comp = new Comparator<ProviderInfo<ParamConverterProvider>>() {
@Override
public int compare(ProviderInfo<ParamConverterProvider> o1, ProviderInfo<ParamConverterProvider> o2) {
ParamConverterProvider provider1 = o1.getProvider();
ParamConverterProvider provider2 = o2.getProvider();
return provider1.getClass().getName().compareTo(provider2.getClass().getName());
}
};
pf.setProviderComparator(comp);
ParamConverter<Customer> h2 = pf.createParameterHandler(Customer.class, Customer.class, null, new MessageImpl());
assertSame(h2, h);
}
Aggregations