use of javax.ws.rs.core.MediaType in project jersey by jersey.
the class StreamDataBodyPartTest method testCreateStreamEntityNameStreamFilename.
@Test
public void testCreateStreamEntityNameStreamFilename() {
String expectedName = "foo";
String expectedFilename = "bar.txt";
MediaType expectedMediaType = StreamDataBodyPart.getDefaultMediaType();
cut = new StreamDataBodyPart(expectedName, new ByteArrayInputStream(new byte[] {}), expectedFilename);
boolean actualIsSimpleBodyPart = cut.isSimple();
String actualName = cut.getName();
String actualFilename = cut.getFilename();
// MediaType is to be the default one.
MediaType actualMediaType = cut.getMediaType();
assertEquals(expectedName, actualName);
assertEquals(expectedMediaType, actualMediaType);
assertEquals(expectedFilename, actualFilename);
assertFalse(actualIsSimpleBodyPart);
}
use of javax.ws.rs.core.MediaType in project jersey by jersey.
the class StreamDataBodyPartTest method testCreateStreamEntityNullMediaType.
@Test
public void testCreateStreamEntityNullMediaType() {
MediaType expectedMediaType = StreamDataBodyPart.getDefaultMediaType();
// MediaType is nullable - it takes the default value in such situation.
cut = new StreamDataBodyPart("foo", new ByteArrayInputStream(new byte[] {}), "bar.txt", null);
MediaType actualMediaType = cut.getMediaType();
assertEquals(expectedMediaType, actualMediaType);
}
use of javax.ws.rs.core.MediaType in project jersey by jersey.
the class StreamDataBodyPartTest method testCreateStreamEntity.
@Test
public void testCreateStreamEntity() {
String expectedName = "foo";
String expectedFilename = "bar.txt";
MediaType expectedMediaType = MediaType.TEXT_HTML_TYPE;
cut = new StreamDataBodyPart(expectedName, new ByteArrayInputStream(new byte[] {}), expectedFilename, expectedMediaType);
// All parameters must be set as the user requested. No defaults.
boolean actualIsSimpleBodyPart = cut.isSimple();
String actualName = cut.getName();
String actualFilename = cut.getFilename();
MediaType actualMediaType = cut.getMediaType();
assertEquals(expectedName, actualName);
assertEquals(expectedMediaType, actualMediaType);
assertEquals(expectedFilename, actualFilename);
assertFalse(actualIsSimpleBodyPart);
}
use of javax.ws.rs.core.MediaType in project jersey by jersey.
the class StreamDataBodyPartTest method testStreamEntityStreamMediaType.
///////////////////////////////////////////////////////////////////////////
// Stream entity setter tests
///////////////////////////////////////////////////////////////////////////
@Test
public void testStreamEntityStreamMediaType() {
MediaType expectedMediaType = MediaType.APPLICATION_SVG_XML_TYPE;
InputStream expectedInputStream = new ByteArrayInputStream(new byte[] { 0x002, 0x003 });
assertSetEntityStream(expectedMediaType, expectedInputStream);
}
use of javax.ws.rs.core.MediaType in project jersey by jersey.
the class StreamDataBodyPartTest method testCreateStreamEntityNameStream.
///////////////////////////////////////////////////////////////////////////
// Constructor tests
///////////////////////////////////////////////////////////////////////////
@Test
public void testCreateStreamEntityNameStream() {
String expectedName = "foo";
MediaType expectedMediaType = StreamDataBodyPart.getDefaultMediaType();
cut = new StreamDataBodyPart(expectedName, new ByteArrayInputStream(new byte[] {}));
boolean actualIsSimpleBodyPart = cut.isSimple();
String actualName = cut.getName();
// Filename and mediaType are to be the default ones.
String actualFilename = cut.getFilename();
MediaType actualMediaType = cut.getMediaType();
assertEquals(expectedName, actualName);
assertEquals(expectedMediaType, actualMediaType);
assertNull(actualFilename);
assertFalse(actualIsSimpleBodyPart);
}
Aggregations