### Question:
BCodec extends RFC1522Codec implements StringEncoder, StringDecoder { public String encode(final String value, final Charset charset) throws EncoderException { if (value == null) { return null; } return encodeText(value, charset); } BCodec();  BCodec(final Charset charset);  BCodec(final String charsetName); String encode(final String value, final Charset charset); String encode(final String value, final String charset); @Override String encode(final String value); @Override String decode(final String value); @Override Object encode(final Object value); @Override Object decode(final Object value); Charset getCharset(); String getDefaultCharset();  }### Answer:
@Test public void testEncodeStringWithNull() throws Exception { final BCodec bcodec = new BCodec(); final String test = null; final String result = bcodec.encode(test, "charset"); assertEquals("Result should be null", null, result); }
@Test public void testEncodeObjects() throws Exception { final BCodec bcodec = new BCodec(); final String plain = "what not"; final String encoded = (String) bcodec.encode((Object) plain); assertEquals("Basic B encoding test", "=?UTF-8?B?d2hhdCBub3Q=?=", encoded); final Object result = bcodec.encode((Object) null); assertEquals("Encoding a null Object should return null", null, result); try { final Object dObj = new Double(3.0); bcodec.encode(dObj); fail("Trying to url encode a Double object should cause an exception."); } catch (final EncoderException ee) { } }