BroadcastBackendHandler implements TextProtocolBackendHandler { @Override public BackendResponse execute() throws SQLException { String originalSchema = backendConnection.getSchemaName(); for (String each : ProxyContext.getInstance().getAllSchemaNames()) { backendConnection.setCurrentSchema(each); if (!ProxyContext.getInstance().getSchema(each).isComplete()) { throw new RuleNotExistsException(); } databaseCommunicationEngineFactory.newTextProtocolInstance(sqlStatement, sql, backendConnection).execute(); } backendConnection.setCurrentSchema(originalSchema); return new UpdateResponse(); }  @Override BackendResponse execute(); @Override boolean next(); @Override QueryData getQueryData();  }
@Test public void assertExecuteSuccess() throws SQLException { mockDatabaseCommunicationEngine(new UpdateResponse()); BroadcastBackendHandler broadcastBackendHandler = new BroadcastBackendHandler("SET timeout = 1000", mock(SQLStatement.class), backendConnection); setBackendHandlerFactory(broadcastBackendHandler); BackendResponse actual = broadcastBackendHandler.execute(); assertThat(actual, instanceOf(UpdateResponse.class)); assertThat(((UpdateResponse) actual).getUpdateCount(), is(0L)); assertThat(((UpdateResponse) actual).getLastInsertId(), is(0L)); verify(databaseCommunicationEngine, times(10)).execute(); }