RDLBackendHandler implements TextProtocolBackendHandler { @Override public BackendResponse execute() throws SQLException { SQLStatementContext<?> context = getSQLStatementContext(); if (!isRegistryCenterExisted()) { throw new SQLException(String.format("No Registry center to execute `%s` SQL", context.getClass().getSimpleName())); } return getBackendResponse(context); }  @Override BackendResponse execute(); @Override boolean next(); @Override QueryData getQueryData();  }
@Test public void assertExecuteDataSourcesContext() throws SQLException { BackendConnection connection = mock(BackendConnection.class); when(connection.getSchemaName()).thenReturn("schema"); RDLBackendHandler executeEngine = new RDLBackendHandler(connection, mock(CreateDataSourcesStatement.class)); try { executeEngine.execute(); } catch (final SQLException ex) { assertThat(ex.getMessage(), is("No Registry center to execute `CreateDataSourcesStatementContext` SQL")); } setGovernanceSchemaContexts(true); BackendResponse response = executeEngine.execute(); assertThat(response, instanceOf(UpdateResponse.class)); }
@Test public void assertExecuteShardingRuleContext() throws SQLException { BackendConnection connection = mock(BackendConnection.class); when(connection.getSchemaName()).thenReturn("schema"); RDLBackendHandler executeEngine = new RDLBackendHandler(connection, mock(CreateShardingRuleStatement.class)); try { executeEngine.execute(); } catch (final SQLException ex) { assertThat(ex.getMessage(), is("No Registry center to execute `CreateShardingRuleStatementContext` SQL")); } setGovernanceSchemaContexts(true); BackendResponse response = executeEngine.execute(); assertThat(response, instanceOf(UpdateResponse.class)); }