HandlerFactory { public Handler getHandler(Service service, Driver.Serialization serialization) { switch (serialization) { case JSON: return new AvaticaHandler(service); case PROTOBUF: return new AvaticaProtobufHandler(service); default: throw new IllegalArgumentException("Unknown Avatica handler for " + serialization.name()); } }  Handler getHandler(Service service, Driver.Serialization serialization);  }
@Test public void testJson() { Handler handler = factory.getHandler(service, Serialization.JSON); assertTrue("Expected an implementation of the AvaticaHandler, " + "but got " + handler.getClass(), handler instanceof AvaticaHandler); }
@Test public void testProtobuf() { Handler handler = factory.getHandler(service, Serialization.PROTOBUF); assertTrue("Expected an implementation of the AvaticaProtobufHandler, " + "but got " + handler.getClass(), handler instanceof AvaticaProtobufHandler); }