Skip to content

Commit

Permalink
Making sure prefer header params isn't null (FCREPO-1406)
Browse files Browse the repository at this point in the history
  • Loading branch information
escowles committed Mar 19, 2015
1 parent a78707c commit 2ab5967
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Expand Up @@ -75,6 +75,9 @@ public PreferTag(final HttpHeaderReader reader) throws ParseException {

if (reader.hasNext()) {
params = HttpHeaderReader.readParameters(reader);
if ( params == null ) {
params = new HashMap<>();
}
}
} else {
tag = "";
Expand Down
Expand Up @@ -18,6 +18,7 @@
import static org.fcrepo.kernel.RdfLexicon.LDP_NAMESPACE;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import java.text.ParseException;
Expand All @@ -37,6 +38,12 @@ public void testEmpty() {
assertTrue(preferTag.getParams().isEmpty());
}

@Test
public void testTrailingSemicolon() throws ParseException {
final PreferTag preferTag = new PreferTag("foo=bar;");
assertNotNull(preferTag.getParams());
}

@Test
public void testEquals() throws ParseException {
final PreferTag preferTag1 = new PreferTag("handling=lenient; received=\"minimal\"");
Expand Down Expand Up @@ -70,4 +77,4 @@ private void doTestHashCode(final PreferTag tag0, final PreferTag tag1, final bo
assertEquals(expectEqual, tag0.hashCode() == tag1.hashCode());
}

}
}

0 comments on commit 2ab5967

Please sign in to comment.