contentDispositionType = "inline";
}
@Test
public void testCreate() {
ContentDisposition contentDisposition = ContentDisposition.type(null).build();
assertNotNull(contentDisposition);
assertEquals(null, contentDisposition.getType());
contentDisposition = ContentDisposition.type(contentDispositionType).build();
assertNotNull(contentDisposition);
assertEquals(contentDispositionType, contentDisposition.getType());
final Date date = new Date();
contentDisposition = ContentDisposition.type(contentDispositionType).fileName("test.file")
.creationDate(date).modificationDate(date).readDate(date).size(1222).build();
assertContentDisposition(contentDisposition, date);
String header = contentDispositionType;
try {
contentDisposition = new ContentDisposition(contentDisposition.toString());
assertNotNull(contentDisposition);
contentDisposition = new ContentDisposition(header);
assertNotNull(contentDisposition);
assertEquals(contentDispositionType, contentDisposition.getType());
final String dateString = HttpDateFormat.getPreferredDateFormat().format(date);
header = contentDispositionType + ";filename=\"test.file\";creation-date=\""
+ dateString + "\";modification-date=\"" + dateString + "\";read-date=\""
+ dateString + "\";size=1222";
contentDisposition = new ContentDisposition(header);
assertContentDisposition(contentDisposition, date);
contentDisposition = new ContentDisposition(HttpHeaderReader.newInstance(header), true);
assertContentDisposition(contentDisposition, date);
}
catch (final ParseException ex) {
fail(ex.getMessage());
}
try {
new ContentDisposition((HttpHeaderReader) null, true);
fail("NullPointerException was expected to be thrown.");
}
catch (final ParseException exception) {
fail(exception.getMessage());
}