You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by GitBox <gi...@apache.org> on 2017/10/19 01:44:55 UTC

[GitHub] reta commented on a change in pull request #321: Check @Priority annotations on providers when sorting

reta commented on a change in pull request #321: Check @Priority annotations on providers when sorting
URL: https://github.com/apache/cxf/pull/321#discussion_r145583920
 
 

 ##########
 File path: rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
 ##########
 @@ -820,6 +822,40 @@ public void testSetSchemasFromClasspath() {
         assertNotNull("schema can not be read from classpath", s);
     }
 
+    @Test
+    public void testSortByPriority() {
+        ProviderFactory pf = ServerProviderFactory.getInstance();
+        List<Object> providers = new ArrayList<>();
+        BookReaderWriter bookHandler = new BookReaderWriter();
+        providers.add(bookHandler);
+        HighPriorityBookReaderWriter highPriorityBookHandler = new HighPriorityBookReaderWriter();
+        providers.add(highPriorityBookHandler);
+        pf.setUserProviders(providers);
+        assertSame(highPriorityBookHandler,
+                   pf.createMessageBodyReader(Book.class, Book.class, new Annotation[]{},
+                                              MediaType.APPLICATION_XML_TYPE, new MessageImpl()));
+        assertSame(highPriorityBookHandler,
+                   pf.createMessageBodyWriter(Book.class, Book.class, new Annotation[]{},
+                                              MediaType.APPLICATION_XML_TYPE, new MessageImpl()));
+        
+        // do the same thing again but add the providers in the reverse order to ensure add order
 
 Review comment:
   Would you mind please to extract the second part of the test case to separate method, for example `public void testSortByPriorityReversed()`? Thanks.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services