### Question:
FileNameEncoding { private static String encode(String source, String encoding) throws UnsupportedEncodingException { byte[] bytes; if (source.length() == 1 && source.equals(".")) { bytes = PercentEncoder.encode(source.getBytes(encoding), OS_RESERVED); } else if (source.length() == 2 && source.equals("..")) { bytes = PercentEncoder.encode(source.getBytes(encoding), OS_RESERVED); } else { bytes = PercentEncoder.encode(source.getBytes(encoding), NOT_ENCODED); } return new String(bytes, "US-ASCII"); }  static final String encode(final String fileName); static final String decode(final String fileName); static final int MAX_LENGTH; static final String CHARSET; }### Answer:
@Test public void encodeTest() throws OperationException { String input = ".test/file^!?name<foo>bar*what?"; testEncode(input); }
@Test public void testLengthExceed() { String input = "f%this is*^!@#? is_ƒåœ®∫ƒ®hellowå∫∫23/123/e/$@!$˚∆˙ˆ˙¥∫ç˜åasdad"; try { FileNameEncoding.encode(input); } catch (OperationException ex) { LoggerFactory.getLogger(FileNameEncodingTest.class.getName()).info("OperationException was caught"); assertEquals(ex.getErrorCode(), ErrorCode.STRING_LENGTH_EXCEEDED); } }