EscapeTool extends org.apache.velocity.tools.generic.EscapeTool { public String b(Object content) { if (content != null) { try { return new BCodec().encode(String.valueOf(content)); } catch (EncoderException ex) { } } return null; }  @Override String xml(Object content); String json(Object string); String quotedPrintable(Object content); String q(Object content); String b(Object content); String url(Map<String, ?> parametersMap); String css(String identifier); @Override String url(Object string);  }
@Test void bWithSimpleText() { assertEquals("=?UTF-8?B?SGVsbG8gV29ybGQ=?=", this.tool.b("Hello World")); }
@Test void bWithSpecialChars() { assertEquals("=?UTF-8?B?YT1iPwo=?=", this.tool.b("a=b?\n")); }
@Test void bWithNonAsciiChars() { assertEquals("=?UTF-8?B?xKM=?=", this.tool.b("\u0123")); }
@Test void bWithNull() { assertNull(this.tool.b(null)); }