private void testMatch(String header, String offer, String result) { AcceptList list1 = new AcceptList(header) ; AcceptList list2 = new AcceptList(offer) ; MediaType matchItem = AcceptList.match(list1, list2) ; if ( result == null ) { assertNull("Match not null: from "+q(header)+" :: "+q(offer), matchItem) ; return ; } assertNotNull("Match is null: expected "+q(result), matchItem) ; assertEquals("Match different", result, matchItem.toHeaderString()) ; }
@Test public void qualNeg3() { testMatch( "text/turtle,application/rdf+xml;q=0.5", "text/turtle,application/rdf+xml" , "text/turtle") ; }
@Test public void connegResultSet_03() { testMatch( "application/sparql-results+json;q=0.9, */*;q=0.1", offerResultSet, "application/sparql-results+json") ; }
@Test public void qualNeg4() { testMatch( "application/rdf+xml;q=0.5,text/turtle", "text/turtle,application/rdf+xml" , "text/turtle") ; }
@Test public void qualNeg5() { testMatch( "application/rdf+xml;q=0.5,text/turtle", ",application/rdf+xml,text/turtle" , "text/turtle") ; }
@Test public void conneg_01() { testMatch( // SPARQL -- ask for either. "application/sparql-results+json , application/sparql-results+xml;q=0.9 , text/turtle, application/rdf+xml;q=0.9 , */*;q=0.1", offerRDF, "text/turtle") ; }
@Test public void connegResultSet_01() { testMatch( "application/sparql-results+json , application/sparql-results+xml;q=0.9 , application/rdf+xml , application/turtle;q=0.9 , */*;q=0.1", offerResultSet, "application/sparql-results+json") ; }
@Test public void connegResultSet_02() { testMatch( "application/sparql-results+xml;q=0.9, */*;q=0.1", offerResultSet, "application/sparql-results+xml") ; }
@Test public void connegRDF_01() { testMatch( "application/rdf+xml , text/turtle;q=0.9 , */*;q=0.1", offerRDF, "application/rdf+xml") ; }
@Test public void qualNeg2() { testMatch( "text/turtle,application/rdf+xml;q=0.5", "application/rdf+xml,text/turtle" , "text/turtle") ; }
@Test public void connegRDF_02() { testMatch( "application/turtle;q=0.9 , application/rdf+xml , */*;q=0.1", offerRDF, "application/rdf+xml") ; }
@Test public void qualNeg1() { testMatch("text/xml;q=0.5,text/plain", "text/plain", "text/plain") ; }
@Test public void simpleNeg1() { testMatch("text/plain", "text/plain", "text/plain") ; }
@Test public void listNeg2() { testMatch("text/xml,text/*", "text/plain,text/xml", "text/xml") ; }
@Test public void listNeg3() { testMatch("text/xml,text/*", "text/plain", "text/plain") ; }
@Test public void simpleNeg2() { testMatch("application/xml", "text/plain", null) ; }
@Test public void simpleNeg3() { testMatch("text/*", "text/plain", "text/plain") ; }
@Test public void listNeg1() { testMatch("text/xml,text/*", "text/xml", "text/xml") ; }