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

Public Member Functions

void setUp ()
 
void testNoVariantOnServer ()
 
void testMatchSimple ()
 
void testNoMatch ()
 
void testUseDefaultIfNoMatch ()
 
void testUseDefaultIfTwoEqualOptions ()
 
void testPickFirstIfTwoEqualOptions ()
 
void testDefaultToHigherQuality ()
 
void testPickCorrectMatchSimple ()
 
void testPickCorrectMatchWithClientQuality ()
 
void testPickCorrectMatchWithServerQuality1 ()
 
void testPickCorrectMatchWithServerQuality2 ()
 
void testNoMatchIfBestEqualsZero ()
 
void testQualityMultiplication ()
 
void testEmptyHeader ()
 
void testEmptyHeaderPickBestQuality ()
 
void testAcceptAlias ()
 
void testUseAliasQuality ()
 
void testSpecifyDefaultAccept ()
 
void testUserAgentOverrideSimple ()
 

Private Attributes

ContentTypeNegotiator negotiator
 

Member Function Documentation

◆ setUp()

void setUp ( )
10  {
11  negotiator = new ContentTypeNegotiator();
12  }
ContentTypeNegotiator negotiator
Definition: ContentTypeNegotiatorTest.java:8

References ContentTypeNegotiatorTest.negotiator.

◆ testAcceptAlias()

void testAcceptAlias ( )
101  {
103  assertEquals("a/b", negotiator.getBestMatch("c/d").getMediaType());
104  }
VariantSpec addVariant(String mediaType)
Definition: ContentTypeNegotiator.java:16
MediaRangeSpec getBestMatch(String accept)
Definition: ContentTypeNegotiator.java:47
VariantSpec addAliasMediaType(String mediaType)
Definition: ContentTypeNegotiator.java:84
String getMediaType()
Definition: MediaRangeSpec.java:151

References ContentTypeNegotiator.VariantSpec.addAliasMediaType(), ContentTypeNegotiator.addVariant(), ContentTypeNegotiator.getBestMatch(), MediaRangeSpec.getMediaType(), and ContentTypeNegotiatorTest.negotiator.

◆ testDefaultToHigherQuality()

void testDefaultToHigherQuality ( )

◆ testEmptyHeader()

void testEmptyHeader ( )

◆ testEmptyHeaderPickBestQuality()

void testEmptyHeaderPickBestQuality ( )

◆ testMatchSimple()

◆ testNoMatch()

void testNoMatch ( )

◆ testNoMatchIfBestEqualsZero()

void testNoMatchIfBestEqualsZero ( )

◆ testNoVariantOnServer()

void testNoVariantOnServer ( )

◆ testPickCorrectMatchSimple()

void testPickCorrectMatchSimple ( )

◆ testPickCorrectMatchWithClientQuality()

void testPickCorrectMatchWithClientQuality ( )
57  {
58  negotiator.addVariant("a/b");
59  negotiator.addVariant("c/d");
60  assertEquals("a/b", negotiator.getBestMatch("a/b;q=0.8,c/d;q=0.6").getMediaType());
61  assertEquals("c/d", negotiator.getBestMatch("a/b;q=0.6,c/d;q=0.8").getMediaType());
62  }

References ContentTypeNegotiator.addVariant(), ContentTypeNegotiator.getBestMatch(), MediaRangeSpec.getMediaType(), and ContentTypeNegotiatorTest.negotiator.

◆ testPickCorrectMatchWithServerQuality1()

void testPickCorrectMatchWithServerQuality1 ( )

◆ testPickCorrectMatchWithServerQuality2()

void testPickCorrectMatchWithServerQuality2 ( )

◆ testPickFirstIfTwoEqualOptions()

void testPickFirstIfTwoEqualOptions ( )

◆ testQualityMultiplication()

void testQualityMultiplication ( )
81  {
82  negotiator.addVariant("a/b;q=0.1");
83  negotiator.addVariant("c/d;q=0.9");
84  negotiator.addVariant("e/f;q=0.8");
85  assertEquals("e/f", negotiator.getBestMatch("a/b;q=0.9;c/d;q=0.1;e/f;q=0.8").getMediaType());
86  }

References ContentTypeNegotiator.addVariant(), ContentTypeNegotiator.getBestMatch(), MediaRangeSpec.getMediaType(), and ContentTypeNegotiatorTest.negotiator.

◆ testSpecifyDefaultAccept()

void testSpecifyDefaultAccept ( )
112  {
113  negotiator.addVariant("a/b");
114  negotiator.addVariant("c/d;q=0.5");
116  assertEquals("c/d", negotiator.getBestMatch(null).getMediaType());
117  }
void setDefaultAccept(String accept)
Sets an Accept header to be used as the default if a client does not send an Accept header,...
Definition: ContentTypeNegotiator.java:27

References ContentTypeNegotiator.addVariant(), ContentTypeNegotiator.getBestMatch(), MediaRangeSpec.getMediaType(), ContentTypeNegotiatorTest.negotiator, and ContentTypeNegotiator.setDefaultAccept().

◆ testUseAliasQuality()

◆ testUseDefaultIfNoMatch()

◆ testUseDefaultIfTwoEqualOptions()

◆ testUserAgentOverrideSimple()

void testUserAgentOverrideSimple ( )
119  {
120  negotiator.addVariant("a/b");
121  negotiator.addVariant("c/d;q=0.5");
122  negotiator.addUserAgentOverride(Pattern.compile(""), null, "c/d");
123  assertEquals("c/d", negotiator.getBestMatch("a/b", null).getMediaType());
124  }
void addUserAgentOverride(Pattern userAgentString, String originalAcceptHeader, String newAcceptHeader)
Overrides the Accept header for certain user agents.
Definition: ContentTypeNegotiator.java:41

References ContentTypeNegotiator.addUserAgentOverride(), ContentTypeNegotiator.addVariant(), ContentTypeNegotiator.getBestMatch(), MediaRangeSpec.getMediaType(), and ContentTypeNegotiatorTest.negotiator.

Member Data Documentation

◆ negotiator