Skip to content

Commit 445abc6

Browse files
committed
Changed unit test not to write to actual file since the getMimeType method does not require the file to exist anymore.
1 parent 915bee3 commit 445abc6

File tree

1 file changed

+6
-19
lines changed

1 file changed

+6
-19
lines changed

aws-serverless-java-container-core/src/test/java/com/amazonaws/serverless/proxy/internal/servlet/AwsServletContextTest.java

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -66,25 +66,12 @@ public void getMimeType_nonExistentFileInTaskPath_expectNull() {
6666
@Test
6767
public void getMimeType_mimeTypeOfCorrectFile_expectMime() {
6868
String tmpFilePath = TMP_DIR + "test_text.txt";
69-
try {
70-
System.out.println("Writing to tmp file " + tmpFilePath);
71-
PrintWriter tmpWriter = new PrintWriter(tmpFilePath, "UTF-8");
72-
tmpWriter.write("Test case for aws-serverless-java-container");
73-
tmpWriter.close();
74-
75-
AwsServletContext ctx = new AwsServletContext(null);
76-
String mimeType = ctx.getMimeType(tmpFilePath);
77-
assertEquals("text/plain", mimeType);
78-
79-
mimeType = ctx.getMimeType("file://" + tmpFilePath);
80-
assertEquals("text/plain", mimeType);
81-
} catch (FileNotFoundException e) {
82-
fail("tmp file not found");
83-
e.printStackTrace();
84-
} catch (UnsupportedEncodingException e) {
85-
fail("Unsupported encoding");
86-
e.printStackTrace();
87-
}
69+
AwsServletContext ctx = new AwsServletContext(null);
70+
String mimeType = ctx.getMimeType(tmpFilePath);
71+
assertEquals("text/plain", mimeType);
72+
73+
mimeType = ctx.getMimeType("file://" + tmpFilePath);
74+
assertEquals("text/plain", mimeType);
8875
}
8976

9077
@Test

0 commit comments

Comments
 (0)