@Test public void testNoClosingBoundary() { String boundary = "----=_Part_4_910054940.1065629194743"; final byte[] chunk1 = concat(("--" + boundary + "\n" + "Content-Type: text/xml; charset=UTF-8\n" + "Content-Id: part1\n" + "\n" + "<foo>bar</foo>\n" + "--" + boundary + "\n" + "Content-Type: image/jpeg\n" + "Content-Transfer-Encoding: binary\n" + "Content-Id: part2\n" + "\n").getBytes(), new byte[]{(byte) 0xff, (byte) 0xd8}); MimeParser.ParsingException ex = assertThrows(MimeParser.ParsingException.class, () -> parse(boundary, chunk1)); assertThat(ex.getMessage(), is(equalTo("No closing MIME boundary"))); }
private static byte[] getBytes(String str) { char[] chars = str.toCharArray(); int size = chars.length; byte[] bytes = new byte[size]; for (int i = 0; i < size;) { bytes[i] = (byte) chars[i++]; } return bytes; }
MimeParser { private static byte[] getBytes(String str) { char[] chars = str.toCharArray(); int size = chars.length; byte[] bytes = new byte[size]; for (int i = 0; i < size;) { bytes[i] = (byte) chars[i++]; } return bytes; } }
MimeParser { private static byte[] getBytes(String str) { char[] chars = str.toCharArray(); int size = chars.length; byte[] bytes = new byte[size]; for (int i = 0; i < size;) { bytes[i] = (byte) chars[i++]; } return bytes; } MimeParser(String boundary); }
MimeParser { private static byte[] getBytes(String str) { char[] chars = str.toCharArray(); int size = chars.length; byte[] bytes = new byte[size]; for (int i = 0; i < size;) { bytes[i] = (byte) chars[i++]; } return bytes; } MimeParser(String boundary);  }
MimeParser { private static byte[] getBytes(String str) { char[] chars = str.toCharArray(); int size = chars.length; byte[] bytes = new byte[size]; for (int i = 0; i < size;) { bytes[i] = (byte) chars[i++]; } return bytes; } MimeParser(String boundary);   }