use of com.oracle.truffle.api.source.MissingMIMETypeException in project graal by oracle.
the class SourceBuilderTest method assignMimeTypeAndIdentity.
@Test
public void assignMimeTypeAndIdentity() {
Source.Builder<RuntimeException, MissingMIMETypeException, RuntimeException> builder = Source.newBuilder("// a comment\n").name("Empty comment");
Source s1 = builder.mimeType("content/unknown").build();
assertEquals("No mime type assigned", "content/unknown", s1.getMimeType());
Source s2 = builder.mimeType("text/x-c").build();
assertEquals("They have the same content", s1.getCharacters(), s2.getCharacters());
assertNotEquals("But different type", s1.getMimeType(), s2.getMimeType());
assertNotEquals("So they are different", s1, s2);
assertNotNull("Every source must have URI", s1.getURI());
assertEquals("Source with different MIME type has the same URI", s1.getURI(), s2.getURI());
}
use of com.oracle.truffle.api.source.MissingMIMETypeException in project graal by oracle.
the class SourceBuilderTest method assignMimeTypeAndIdentityForReader.
@Test
public void assignMimeTypeAndIdentityForReader() throws IOException {
String text = "// Hello";
Source.Builder<IOException, MissingMIMETypeException, RuntimeException> builder = Source.newBuilder(new StringReader(text)).name("test.txt");
Source s1 = builder.name("Hello").mimeType("text/plain").build();
assertEquals("Base type assigned", "text/plain", s1.getMimeType());
Source s2 = builder.mimeType("text/x-c").build();
assertEquals("They have the same content", s1.getCharacters(), s2.getCharacters());
assertEquals("// Hello", s1.getCharacters());
assertNotEquals("But different type", s1.getMimeType(), s2.getMimeType());
assertNotEquals("So they are different", s1, s2);
assertNotNull("Every source must have URI", s1.getURI());
assertEquals("Source with different MIME type has the same URI", s1.getURI(), s2.getURI());
}
Aggregations