### Question:
RpcClientFactory { @SuppressWarnings("unchecked") public static RpcClient getInstance(Properties properties) throws FlumeException { String type = null; type = properties.getProperty( RpcClientConfigurationConstants.CONFIG_CLIENT_TYPE); if (type == null || type.isEmpty()) { type = ClientType.DEFAULT.getClientClassName(); } Class<? extends AbstractRpcClient> clazz; AbstractRpcClient client; try { String clientClassType = type; ClientType clientType = null; try{ clientType = ClientType.valueOf(type.toUpperCase()); } catch (IllegalArgumentException e){ clientType = ClientType.OTHER; } if (!clientType.equals(ClientType.OTHER)){ clientClassType = clientType.getClientClassName(); } clazz = (Class<? extends AbstractRpcClient>) Class.forName(clientClassType); } catch (ClassNotFoundException e) { throw new FlumeException("No such client!", e); } try { client = clazz.newInstance(); } catch (InstantiationException e) { throw new FlumeException("Cannot instantiate client. " + "Exception follows:", e); } catch (IllegalAccessException e) { throw new FlumeException("Cannot instantiate client. " + "Exception follows:", e); } client.configure(properties); return client; }  @SuppressWarnings("unchecked") static RpcClient getInstance(Properties properties); static RpcClient getInstance(File propertiesFile); @Deprecated static RpcClient getInstance(String hostname, Integer port); static RpcClient getDefaultInstance(String hostname, Integer port); @Deprecated static RpcClient getInstance(String hostname, Integer port,
      Integer batchSize); static RpcClient getDefaultInstance(String hostname, Integer port,
      Integer batchSize); static RpcClient getThriftInstance(String hostname, Integer port,
    Integer batchSize); static RpcClient getThriftInstance(String hostname, Integer port); static RpcClient getThriftInstance(Properties props);  }### Answer:
@Test public void testTwoParamDeprecatedAppend() throws FlumeException, EventDeliveryException { RpcClient client = null; Server server = RpcTestUtils.startServer(new OKAvroHandler()); try { client = RpcClientFactory.getInstance(localhost, server.getPort()); client.append(EventBuilder.withBody("wheee!!!", Charset.forName("UTF8"))); } finally { RpcTestUtils.stopServer(server); if (client != null) client.close(); } }
@Test public void testThreeParamDeprecatedAppend() throws FlumeException, EventDeliveryException { RpcClient client = null; Server server = RpcTestUtils.startServer(new OKAvroHandler()); try { client = RpcClientFactory.getInstance(localhost, server.getPort(), 3); Assert.assertEquals("Batch size was specified", 3, client.getBatchSize()); client.append(EventBuilder.withBody("wheee!!!", Charset.forName("UTF8"))); } finally { RpcTestUtils.stopServer(server); if (client != null) client.close(); } }
@Test public void testPropertiesBatchAppend() throws FlumeException, EventDeliveryException { int batchSize = 7; RpcClient client = null; Server server = RpcTestUtils.startServer(new OKAvroHandler()); try { Properties p = new Properties(); p.put("hosts", "host1"); p.put("hosts.host1", localhost + ":" + String.valueOf(server.getPort())); p.put("batch-size", String.valueOf(batchSize)); client = RpcClientFactory.getInstance(p); List<Event> events = new ArrayList<Event>(); for (int i = 0; i < batchSize; i++) { events.add(EventBuilder.withBody("evt: " + i, Charset.forName("UTF8"))); } client.appendBatch(events); } finally { RpcTestUtils.stopServer(server); if (client != null) client.close(); } }