### Question:
GangliaSink extends EventSink.Base { public static SinkBuilder builder() { return new SinkBuilder() { @Override public EventSink build(Context context, String... argv) { Preconditions.checkArgument(argv.length >= 3 && argv.length <= 4, "usage: ganglia(\"attr\", \"units\",\"type\"[, \"gmondservers\"])"); String ganglias = FlumeConfiguration.get().getGangliaServers(); String attr = argv[0]; String units = argv[1]; String type = argv[2]; Type t = null; if (type.equals("int")) { t = Type.INT; } else if (type.equals("long")) { t = Type.LONG; } else if (type.equals("double")) { t = Type.DOUBLE; } else if (type.equals("string")) { t = Type.STRING; } else { throw new IllegalArgumentException( "Illegal ganglia xdr type: " + type + " != int|long|double|string\n" + "usage: ganglia(\"attr\", \"units\",\"type\"[, \"gmondservers\"]"); } if (argv.length >= 4) { ganglias = argv[3]; } EventSink snk = new GangliaSink(ganglias, attr, units, t); return snk; } }; } GangliaSink(String gangliaSvrs, String attr, String units, Type t); @Override void append(Event e); @Override void open(); @Override void close(); static SinkBuilder builder();  }### Answer:
@Test public void testBuilder() throws IOException { EventSink snk = GangliaSink.builder().build(new Context(), "localhost", "foo", "int"); for (int i = 0; i < 10; i++) { snk.open(); snk.append(new EventImpl("".getBytes())); snk.close(); } EventSink snk4 = GangliaSink.builder().build(new Context(), "localhost", "foo", "int", FlumeConfiguration.get().getGangliaServers()); for (int i = 0; i < 10; i++) { snk4.open(); snk4.append(new EventImpl("".getBytes())); snk4.close(); } try { GangliaSink.builder().build(new Context(), "localhost", "foo", "bar"); } catch (IllegalArgumentException e) { return; } fail("expected failure"); }