ObjectInspector valueOI = PrimitiveObjectInspectorFactory.javaStringObjectInspector;
ObjectInspector charsetOI = PrimitiveObjectInspectorFactory.javaStringObjectInspector;
ObjectInspector[] initArguments = {valueOI, charsetOI};
udf.initialize(initArguments);
DeferredObject valueObj = new DeferredJavaObject(string);
DeferredObject charsetObj = new DeferredJavaObject(charsetName);
DeferredObject[] arguments = {valueObj, charsetObj};
BytesWritable outputWritable = (BytesWritable) udf.evaluate(arguments);
byte[] output = outputWritable.getBytes();
assertTrue("Encoding failed for CharSet: " + charsetName, expected.length == outputWritable.getLength());