### Question:
JDBCDriver extends AbstractLensDriver { @Override public void prepare(PreparedQueryContext pContext) throws LensException { if (preparedQueries.containsKey(pContext.getPrepareHandle())) { return; } PreparedStatement stmt = prepareInternal(pContext); if (stmt != null) { preparedQueries.put(pContext.getPrepareHandle(), stmt); } }  @Override void configure(Configuration conf, String driverType, String driverName); void init(); QueryCost calculateQueryCost(AbstractQueryContext qctx); @Override QueryCost estimate(AbstractQueryContext qctx); @Override DriverQueryPlan explain(AbstractQueryContext explainCtx); void validate(AbstractQueryContext pContext); @Override void prepare(PreparedQueryContext pContext); @Override DriverQueryPlan explainAndPrepare(PreparedQueryContext pContext); @Override void closePreparedQuery(QueryPrepareHandle handle); @Override LensResultSet execute(QueryContext context); @Override void executeAsync(QueryContext context); @Override void updateStatus(QueryContext context); @Override void closeResultSet(QueryHandle handle); @Override boolean cancelQuery(QueryHandle handle); @Override void closeQuery(QueryHandle handle); @Override void close(); @Override void registerDriverEventListener(LensEventListener<DriverEvent> driverEventListener); @Override void readExternal(ObjectInput arg0); @Override void writeExternal(ObjectOutput arg0); @Override StatusUpdateMethod getStatusUpdateMethod(); static final AtomicInteger THID; }### Answer:
@Test public void testPrepare() throws Exception { createTable("prepare_test"); createTable("prepare_test", driver.getEstimateConnection()); insertData("prepare_test"); insertData("prepare_test", driver.getEstimateConnection()); final String query = "SELECT * from prepare_test"; PreparedQueryContext pContext = new PreparedQueryContext(query, "SA", baseConf, drivers); driver.validate(pContext); driver.prepare(pContext); }
@Test public void testPrepareFailing() throws Exception { String query = "SELECT * FROM prepare_test2"; try { PreparedQueryContext pContext = new PreparedQueryContext(query, "SA", baseConf, drivers); driver.prepare(pContext); Assert.fail("Running prepare on a non existing table."); } catch (LensException ex) { Assert.assertEquals(LensUtil.getCauseMessage(ex), "user lacks privilege or object not found: PREPARE_TEST2"); } }