Search in sources :

Example 1 with PriorityCustomerParameterHandler

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);
}
Also used : PriorityCustomerParameterHandler(org.apache.cxf.jaxrs.PriorityCustomerParameterHandler) Customer(org.apache.cxf.jaxrs.Customer) ParamConverterProvider(javax.ws.rs.ext.ParamConverterProvider) MessageImpl(org.apache.cxf.message.MessageImpl) PriorityCustomerParameterHandler(org.apache.cxf.jaxrs.PriorityCustomerParameterHandler) CustomerParameterHandler(org.apache.cxf.jaxrs.CustomerParameterHandler) Test(org.junit.Test)

Example 2 with PriorityCustomerParameterHandler

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);
}
Also used : PriorityCustomerParameterHandler(org.apache.cxf.jaxrs.PriorityCustomerParameterHandler) ProviderInfo(org.apache.cxf.jaxrs.model.ProviderInfo) Customer(org.apache.cxf.jaxrs.Customer) ParamConverterProvider(javax.ws.rs.ext.ParamConverterProvider) MessageImpl(org.apache.cxf.message.MessageImpl) PriorityCustomerParameterHandler(org.apache.cxf.jaxrs.PriorityCustomerParameterHandler) CustomerParameterHandler(org.apache.cxf.jaxrs.CustomerParameterHandler) Comparator(java.util.Comparator) Test(org.junit.Test)

Aggregations

ParamConverterProvider (javax.ws.rs.ext.ParamConverterProvider)2 Customer (org.apache.cxf.jaxrs.Customer)2 CustomerParameterHandler (org.apache.cxf.jaxrs.CustomerParameterHandler)2 PriorityCustomerParameterHandler (org.apache.cxf.jaxrs.PriorityCustomerParameterHandler)2 MessageImpl (org.apache.cxf.message.MessageImpl)2 Test (org.junit.Test)2 Comparator (java.util.Comparator)1 ProviderInfo (org.apache.cxf.jaxrs.model.ProviderInfo)1