GeoPubby  Version 0.1.0.0
PubbyNegotiatorTest Class Reference
Inheritance diagram for PubbyNegotiatorTest:
Collaboration diagram for PubbyNegotiatorTest:

Public Member Functions

void setUp ()
 
void testAcceptRDFXML ()
 
void testAcceptHTML ()
 
void testAcceptXHTMLGetsHTML ()
 
void testAcceptJSON ()
 
void testGetTurtle ()
 
void testGetN3 ()
 
void testGetNTriples ()
 
void testBrowsersGetHTML ()
 
void testAcceptXMLGetsRDFXML ()
 
void testNoAcceptGetsHTML ()
 
void testSafariGetsHTML ()
 
void testAcceptEverythingGetsHTML ()
 
void testFirefox3GetsHTML ()
 
void testTabulatorGetsRDF ()
 
void testDataURIDefaultsToN3ForFirefox ()
 
void testDataURIDefaultsToN3ForSafari ()
 

Private Attributes

ContentTypeNegotiator negotiator
 

Member Function Documentation

◆ setUp()

void setUp ( )
8  {
9  negotiator = PubbyNegotiator.getPubbyNegotiator();
10  }
ContentTypeNegotiator negotiator
Definition: PubbyNegotiatorTest.java:6

References PubbyNegotiator.getPubbyNegotiator(), and PubbyNegotiatorTest.negotiator.

◆ testAcceptEverythingGetsHTML()

void testAcceptEverythingGetsHTML ( )
84  {
85  assertEquals("text/html", negotiator.getBestMatch("*/*").getMediaType());
86  }
MediaRangeSpec getBestMatch(String accept)
Definition: ContentTypeNegotiator.java:47
String getMediaType()
Definition: MediaRangeSpec.java:151

References ContentTypeNegotiator.getBestMatch(), MediaRangeSpec.getMediaType(), and PubbyNegotiatorTest.negotiator.

◆ testAcceptHTML()

void testAcceptHTML ( )
17  {
18  assertEquals("text/html",
19  negotiator.getBestMatch("text/html").getMediaType());
20  }

References ContentTypeNegotiator.getBestMatch(), MediaRangeSpec.getMediaType(), and PubbyNegotiatorTest.negotiator.

◆ testAcceptJSON()

void testAcceptJSON ( )
27  {
28  assertEquals("application/json",
29  negotiator.getBestMatch("application/json").getMediaType());
30  }

References ContentTypeNegotiator.getBestMatch(), MediaRangeSpec.getMediaType(), and PubbyNegotiatorTest.negotiator.

◆ testAcceptRDFXML()

void testAcceptRDFXML ( )
12  {
13  assertEquals("application/rdf+xml",
14  negotiator.getBestMatch("application/rdf+xml").getMediaType());
15  }

References ContentTypeNegotiator.getBestMatch(), MediaRangeSpec.getMediaType(), and PubbyNegotiatorTest.negotiator.

◆ testAcceptXHTMLGetsHTML()

void testAcceptXHTMLGetsHTML ( )
22  {
23  assertEquals("text/html",
24  negotiator.getBestMatch("application/xhtml+xml").getMediaType());
25  }

References ContentTypeNegotiator.getBestMatch(), MediaRangeSpec.getMediaType(), and PubbyNegotiatorTest.negotiator.

◆ testAcceptXMLGetsRDFXML()

void testAcceptXMLGetsRDFXML ( )
62  {
63  assertEquals("application/rdf+xml",
64  negotiator.getBestMatch("application/xml").getMediaType());
65  assertEquals("application/rdf+xml",
66  negotiator.getBestMatch("text/xml").getMediaType());
67  }

References ContentTypeNegotiator.getBestMatch(), MediaRangeSpec.getMediaType(), and PubbyNegotiatorTest.negotiator.

◆ testBrowsersGetHTML()

void testBrowsersGetHTML ( )
55  {
56  // Safari and Mozilla have text/html;q=0.9,text/plain;q=0.8,*/*;q=0.5
57  // We want them to see HTML
58  assertEquals("text/html",
59  negotiator.getBestMatch("text/html;q=0.9,text/plain;q=0.8,*/*;q=0.5").getMediaType());
60  }

References ContentTypeNegotiator.getBestMatch(), MediaRangeSpec.getMediaType(), and PubbyNegotiatorTest.negotiator.

◆ testDataURIDefaultsToN3ForFirefox()

void testDataURIDefaultsToN3ForFirefox ( )
108  {
109  assertEquals("text/rdf+n3;charset=utf-8",
110  PubbyNegotiator.getDataNegotiator().getBestMatch(
111  "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
112  ).getMediaType());
113  }

References ContentTypeNegotiator.getBestMatch(), PubbyNegotiator.getDataNegotiator(), and MediaRangeSpec.getMediaType().

◆ testDataURIDefaultsToN3ForSafari()

void testDataURIDefaultsToN3ForSafari ( )
115  {
116  assertEquals("text/rdf+n3;charset=utf-8",
117  PubbyNegotiator.getDataNegotiator().getBestMatch(
118  "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,"+
119  "text/plain;q=0.8,image/png,*/*;q=0.5",
120  "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_4; en-us) " +
121  "AppleWebKit/525.18 (KHTML, like Gecko) " +
122  "Version/3.1.2 Safari/525.20.1"
123  ).getMediaType());
124  }

References ContentTypeNegotiator.getBestMatch(), PubbyNegotiator.getDataNegotiator(), and MediaRangeSpec.getMediaType().

◆ testFirefox3GetsHTML()

void testFirefox3GetsHTML ( )
88  {
89  // Firefox 3.0.1, OS X
90  assertEquals("text/html",
92  "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
93  "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.1) " +
94  "Gecko/2008070206 Firefox/3.0.1").getMediaType());
95  }

References ContentTypeNegotiator.getBestMatch(), MediaRangeSpec.getMediaType(), and PubbyNegotiatorTest.negotiator.

◆ testGetN3()

void testGetN3 ( )
41  {
42  assertEquals("text/rdf+n3;charset=utf-8",
43  negotiator.getBestMatch("text/rdf+n3").getMediaType());
44  assertEquals("text/rdf+n3;charset=utf-8",
45  negotiator.getBestMatch("text/n3").getMediaType());
46  assertEquals("text/rdf+n3;charset=utf-8",
47  negotiator.getBestMatch("application/n3").getMediaType());
48  }

References ContentTypeNegotiator.getBestMatch(), MediaRangeSpec.getMediaType(), and PubbyNegotiatorTest.negotiator.

◆ testGetNTriples()

void testGetNTriples ( )
50  {
51  assertEquals("text/plain",
52  negotiator.getBestMatch("text/plain").getMediaType());
53  }

References ContentTypeNegotiator.getBestMatch(), MediaRangeSpec.getMediaType(), and PubbyNegotiatorTest.negotiator.

◆ testGetTurtle()

void testGetTurtle ( )
32  {
33  assertEquals("application/x-turtle",
34  negotiator.getBestMatch("application/x-turtle").getMediaType());
35  assertEquals("application/x-turtle",
36  negotiator.getBestMatch("application/turtle").getMediaType());
37  assertEquals("application/x-turtle",
38  negotiator.getBestMatch("text/turtle").getMediaType());
39  }

References ContentTypeNegotiator.getBestMatch(), MediaRangeSpec.getMediaType(), and PubbyNegotiatorTest.negotiator.

◆ testNoAcceptGetsHTML()

void testNoAcceptGetsHTML ( )

◆ testSafariGetsHTML()

void testSafariGetsHTML ( )
74  {
75  // Some versions of Safari send a broken "*/*" Accept header.
76  // We must override this to send HTML.
77  assertEquals("text/html",
78  negotiator.getBestMatch("*/*",
79  "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) " +
80  "AppleWebKit/522.11.1 (KHTML, like Gecko) " +
81  "Version/3.0.3 Safari/522.12.1").getMediaType());
82  }

References ContentTypeNegotiator.getBestMatch(), MediaRangeSpec.getMediaType(), and PubbyNegotiatorTest.negotiator.

◆ testTabulatorGetsRDF()

void testTabulatorGetsRDF ( )
97  {
98  // Tabulator 0.8.5 on Firefox 3.0.1, OS X
99  assertEquals("application/rdf+xml",
101  "application/rdf+xml, application/xhtml+xml;q=0.3, text/xml;q=0.2, " +
102  "application/xml;q=0.2, text/html;q=0.3, text/plain;q=0.1, text/n3, " +
103  "text/rdf+n3;q=0.5, application/x-turtle;q=0.2, text/turtle;q=1",
104  "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.1) " +
105  "Gecko/2008070206 Firefox/3.0.1").getMediaType());
106  }

References ContentTypeNegotiator.getBestMatch(), MediaRangeSpec.getMediaType(), and PubbyNegotiatorTest.negotiator.

Member Data Documentation

◆ negotiator