提交 63eb20f4 编写于 作者: T terrymanu

for #1898, remove SuccessResponse

上级 b1ef272f
......@@ -34,7 +34,6 @@ import org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connec
import org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.execute.JDBCExecuteEngine;
import org.apache.shardingsphere.shardingproxy.backend.result.BackendResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.common.FailureResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.common.SuccessResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryData;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryHeader;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryResponse;
......@@ -85,7 +84,7 @@ public final class JDBCDatabaseCommunicationEngine implements DatabaseCommunicat
private BackendResponse execute(final SQLRouteResult routeResult) throws SQLException {
if (routeResult.getRouteUnits().isEmpty()) {
return new SuccessResponse();
return new UpdateResponse();
}
SQLStatement sqlStatement = routeResult.getSqlStatement();
if (isUnsupportedXA(sqlStatement.getType()) || isUnsupportedBASE(sqlStatement.getType())) {
......
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.shardingsphere.shardingproxy.backend.result.common;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.shardingproxy.backend.result.BackendResponse;
/**
* Success response.
*
* @author zhangliang
*/
@RequiredArgsConstructor
@Getter
public final class SuccessResponse implements BackendResponse {
private final long affectedRows;
private final long lastInsertId;
public SuccessResponse() {
this(0L, 0L);
}
}
......@@ -23,6 +23,7 @@ import org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.execut
import org.apache.shardingsphere.shardingproxy.backend.result.BackendResponse;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
......@@ -41,6 +42,10 @@ public final class UpdateResponse implements BackendResponse {
@Getter
private long updateCount;
public UpdateResponse() {
this(Collections.<ExecuteResponseUnit>emptyList());
}
public UpdateResponse(final Collection<ExecuteResponseUnit> responseUnits) {
for (ExecuteResponseUnit each : responseUnits) {
updateCount = ((ExecuteUpdateResponseUnit) each).getUpdateCount();
......
......@@ -22,8 +22,8 @@ import org.apache.shardingsphere.shardingproxy.backend.communication.DatabaseCom
import org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.shardingproxy.backend.result.BackendResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.common.FailureResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.common.SuccessResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryData;
import org.apache.shardingsphere.shardingproxy.backend.result.update.UpdateResponse;
import org.apache.shardingsphere.shardingproxy.backend.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.shardingproxy.runtime.GlobalRegistry;
......@@ -56,7 +56,7 @@ public final class BroadcastBackendHandler implements TextProtocolBackendHandler
return each;
}
}
return new SuccessResponse();
return new UpdateResponse();
}
@Override
......
......@@ -18,8 +18,8 @@
package org.apache.shardingsphere.shardingproxy.backend.text.admin;
import org.apache.shardingsphere.shardingproxy.backend.result.BackendResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.common.SuccessResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryData;
import org.apache.shardingsphere.shardingproxy.backend.result.update.UpdateResponse;
import org.apache.shardingsphere.shardingproxy.backend.text.TextProtocolBackendHandler;
/**
......@@ -31,7 +31,7 @@ public final class GUICompatibilityBackendHandler implements TextProtocolBackend
@Override
public BackendResponse execute() {
return new SuccessResponse();
return new UpdateResponse();
}
@Override
......
......@@ -23,8 +23,8 @@ import org.apache.shardingsphere.core.util.SQLUtil;
import org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.shardingproxy.backend.result.BackendResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.common.FailureResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.common.SuccessResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryData;
import org.apache.shardingsphere.shardingproxy.backend.result.update.UpdateResponse;
import org.apache.shardingsphere.shardingproxy.backend.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.shardingproxy.runtime.GlobalRegistry;
import org.apache.shardingsphere.shardingproxy.transport.mysql.constant.MySQLServerErrorCode;
......@@ -49,7 +49,7 @@ public final class UseDatabaseBackendHandler implements TextProtocolBackendHandl
return new FailureResponse(MySQLServerErrorCode.ER_BAD_DB_ERROR, schema);
}
backendConnection.setCurrentSchema(schema);
return new SuccessResponse();
return new UpdateResponse();
}
@Override
......
......@@ -21,8 +21,8 @@ import com.google.common.base.Optional;
import org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.shardingproxy.backend.result.BackendResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.common.FailureResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.common.SuccessResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryData;
import org.apache.shardingsphere.shardingproxy.backend.result.update.UpdateResponse;
import org.apache.shardingsphere.shardingproxy.backend.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.transaction.core.TransactionType;
......@@ -59,7 +59,7 @@ public final class ShardingCTLSetBackendHandler implements TextProtocolBackendHa
default:
return new FailureResponse(0, "", String.format("Could not support this sctl grammar [%s].", sql));
}
return new SuccessResponse();
return new UpdateResponse();
}
@Override
......
......@@ -18,8 +18,8 @@
package org.apache.shardingsphere.shardingproxy.backend.text.transaction;
import org.apache.shardingsphere.shardingproxy.backend.result.BackendResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.common.SuccessResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryData;
import org.apache.shardingsphere.shardingproxy.backend.result.update.UpdateResponse;
import org.apache.shardingsphere.shardingproxy.backend.text.TextProtocolBackendHandler;
/**
......@@ -31,7 +31,7 @@ public final class SkipBackendHandler implements TextProtocolBackendHandler {
@Override
public BackendResponse execute() {
return new SuccessResponse();
return new UpdateResponse();
}
@Override
......
......@@ -21,8 +21,8 @@ import org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connec
import org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendTransactionManager;
import org.apache.shardingsphere.shardingproxy.backend.result.BackendResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.common.FailureResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.common.SuccessResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryData;
import org.apache.shardingsphere.shardingproxy.backend.result.update.UpdateResponse;
import org.apache.shardingsphere.shardingproxy.backend.text.TextProtocolBackendHandler;
import org.apache.shardingsphere.transaction.core.TransactionOperationType;
......@@ -68,7 +68,7 @@ public final class TransactionBackendHandler implements TextProtocolBackendHandl
default:
throw new SQLFeatureNotSupportedException(operationType.name());
}
return new SuccessResponse();
return new UpdateResponse();
}
@Override
......
......@@ -26,7 +26,6 @@ import org.apache.shardingsphere.shardingproxy.backend.communication.DatabaseCom
import org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.shardingproxy.backend.result.BackendResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.common.FailureResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.common.SuccessResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryData;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryHeader;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryResponse;
......@@ -36,7 +35,6 @@ import org.apache.shardingsphere.shardingproxy.transport.common.packet.command.C
import org.apache.shardingsphere.shardingproxy.transport.common.packet.command.query.DataHeaderPacket;
import org.apache.shardingsphere.shardingproxy.transport.common.packet.command.query.QueryResponsePackets;
import org.apache.shardingsphere.shardingproxy.transport.common.packet.generic.DatabaseFailurePacket;
import org.apache.shardingsphere.shardingproxy.transport.common.packet.generic.DatabaseSuccessPacket;
import org.apache.shardingsphere.shardingproxy.transport.mysql.constant.MySQLColumnType;
import org.apache.shardingsphere.shardingproxy.transport.mysql.constant.MySQLNewParametersBoundFlag;
import org.apache.shardingsphere.shardingproxy.transport.mysql.constant.MySQLServerErrorCode;
......@@ -156,9 +154,6 @@ public final class MySQLQueryComStmtExecutePacket implements MySQLQueryCommandPa
return Optional.of(new CommandResponsePackets(new MySQLErrPacket(1, MySQLServerErrorCode.ER_CIRCUIT_BREAK_MODE)));
}
BackendResponse backendResponse = databaseCommunicationEngine.execute();
if (backendResponse instanceof SuccessResponse) {
return Optional.of(new CommandResponsePackets(createDatabaseSuccessPacket((SuccessResponse) backendResponse)));
}
if (backendResponse instanceof FailureResponse) {
return Optional.of(new CommandResponsePackets(createDatabaseFailurePacket((FailureResponse) backendResponse)));
}
......@@ -167,10 +162,6 @@ public final class MySQLQueryComStmtExecutePacket implements MySQLQueryCommandPa
return Optional.<CommandResponsePackets>of(new QueryResponsePackets(dataHeaderPackets, dataHeaderEofSequenceId));
}
private DatabaseSuccessPacket createDatabaseSuccessPacket(final SuccessResponse successResponse) {
return new DatabaseSuccessPacket(1, successResponse.getAffectedRows(), successResponse.getLastInsertId());
}
private DatabaseFailurePacket createDatabaseFailurePacket(final FailureResponse failureResponse) {
return new DatabaseFailurePacket(1, failureResponse.getErrorCode(), failureResponse.getSqlState(), failureResponse.getErrorMessage());
}
......
......@@ -23,7 +23,6 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.shardingproxy.backend.result.BackendResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.common.FailureResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.common.SuccessResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryData;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryHeader;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryResponse;
......@@ -95,9 +94,6 @@ public final class MySQLComPacketQuery implements MySQLQueryCommandPacket {
return Optional.of(new CommandResponsePackets(new MySQLErrPacket(1, MySQLServerErrorCode.ER_CIRCUIT_BREAK_MODE)));
}
BackendResponse backendResponse = textProtocolBackendHandler.execute();
if (backendResponse instanceof SuccessResponse) {
return Optional.of(new CommandResponsePackets(createDatabaseSuccessPacket()));
}
if (backendResponse instanceof FailureResponse) {
return Optional.of(new CommandResponsePackets(createDatabaseFailurePacket((FailureResponse) backendResponse)));
}
......@@ -109,10 +105,6 @@ public final class MySQLComPacketQuery implements MySQLQueryCommandPacket {
return Optional.<CommandResponsePackets>of(new QueryResponsePackets(dataHeaderPackets, dataHeaderEofSequenceId));
}
private DatabaseSuccessPacket createDatabaseSuccessPacket() {
return new DatabaseSuccessPacket(1, 0, 0);
}
private DatabaseFailurePacket createDatabaseFailurePacket(final FailureResponse failureResponse) {
return new DatabaseFailurePacket(1, failureResponse.getErrorCode(), failureResponse.getSqlState(), failureResponse.getErrorMessage());
}
......
......@@ -25,7 +25,6 @@ import org.apache.shardingsphere.shardingproxy.backend.communication.DatabaseCom
import org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.shardingproxy.backend.result.BackendResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.common.FailureResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.common.SuccessResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryData;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryHeader;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryResponse;
......@@ -35,7 +34,6 @@ import org.apache.shardingsphere.shardingproxy.transport.common.packet.command.C
import org.apache.shardingsphere.shardingproxy.transport.common.packet.command.query.DataHeaderPacket;
import org.apache.shardingsphere.shardingproxy.transport.common.packet.command.query.QueryResponsePackets;
import org.apache.shardingsphere.shardingproxy.transport.common.packet.generic.DatabaseFailurePacket;
import org.apache.shardingsphere.shardingproxy.transport.common.packet.generic.DatabaseSuccessPacket;
import org.apache.shardingsphere.shardingproxy.transport.postgresql.constant.PostgreSQLColumnType;
import org.apache.shardingsphere.shardingproxy.transport.postgresql.packet.PostgreSQLPacketPayload;
import org.apache.shardingsphere.shardingproxy.transport.postgresql.packet.command.PostgreSQLCommandPacketType;
......@@ -116,9 +114,6 @@ public final class PostgreSQLComBindPacket implements PostgreSQLQueryCommandPack
CommandResponsePackets result = new CommandResponsePackets(new PostgreSQLBindCompletePacket());
if (null != databaseCommunicationEngine) {
BackendResponse backendResponse = databaseCommunicationEngine.execute();
if (backendResponse instanceof SuccessResponse) {
return Optional.of(new CommandResponsePackets(createDatabaseSuccessPacket((SuccessResponse) backendResponse)));
}
if (backendResponse instanceof FailureResponse) {
return Optional.of(new CommandResponsePackets(createDatabaseFailurePacket((FailureResponse) backendResponse)));
}
......@@ -128,10 +123,6 @@ public final class PostgreSQLComBindPacket implements PostgreSQLQueryCommandPack
return Optional.of(result);
}
private DatabaseSuccessPacket createDatabaseSuccessPacket(final SuccessResponse successResponse) {
return new DatabaseSuccessPacket(1, successResponse.getAffectedRows(), successResponse.getLastInsertId());
}
private DatabaseFailurePacket createDatabaseFailurePacket(final FailureResponse failureResponse) {
return new DatabaseFailurePacket(1, failureResponse.getErrorCode(), failureResponse.getSqlState(), failureResponse.getErrorMessage());
}
......
......@@ -23,7 +23,6 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.shardingproxy.backend.result.BackendResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.common.FailureResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.common.SuccessResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryHeader;
import org.apache.shardingsphere.shardingproxy.backend.result.query.QueryResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.update.UpdateResponse;
......@@ -78,9 +77,6 @@ public final class PostgreSQLComQueryPacket implements PostgreSQLQueryCommandPac
return Optional.of(new CommandResponsePackets(new MySQLErrPacket(1, MySQLServerErrorCode.ER_CIRCUIT_BREAK_MODE)));
}
BackendResponse backendResponse = textProtocolBackendHandler.execute();
if (backendResponse instanceof SuccessResponse) {
return Optional.of(new CommandResponsePackets(createDatabaseSuccessPacket()));
}
if (backendResponse instanceof FailureResponse) {
return Optional.of(new CommandResponsePackets(createDatabaseFailurePacket((FailureResponse) backendResponse)));
}
......@@ -91,10 +87,6 @@ public final class PostgreSQLComQueryPacket implements PostgreSQLQueryCommandPac
return Optional.<CommandResponsePackets>of(new QueryResponsePackets(dataHeaderPackets, dataHeaderPackets.size() + 2));
}
private DatabaseSuccessPacket createDatabaseSuccessPacket() {
return new DatabaseSuccessPacket(1, 0, 0);
}
private DatabaseFailurePacket createDatabaseFailurePacket(final FailureResponse failureResponse) {
return new DatabaseFailurePacket(1, failureResponse.getErrorCode(), failureResponse.getSqlState(), failureResponse.getErrorMessage());
}
......
......@@ -24,7 +24,7 @@ import org.apache.shardingsphere.shardingproxy.backend.communication.DatabaseCom
import org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.shardingproxy.backend.result.BackendResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.common.FailureResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.common.SuccessResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.update.UpdateResponse;
import org.apache.shardingsphere.shardingproxy.runtime.schema.LogicSchema;
import org.junit.Test;
import org.junit.runner.RunWith;
......@@ -58,13 +58,13 @@ public final class BroadcastBackendHandlerTest {
@Test
public void assertExecuteSuccess() {
MockGlobalRegistryUtil.setLogicSchemas("schema", 10);
mockDatabaseCommunicationEngine(new SuccessResponse(0L, 0L));
mockDatabaseCommunicationEngine(new UpdateResponse());
BroadcastBackendHandler broadcastBackendHandler = new BroadcastBackendHandler("SET timeout = 1000", backendConnection);
setBackendHandlerFactory(broadcastBackendHandler);
BackendResponse actual = broadcastBackendHandler.execute();
assertThat(actual, instanceOf(SuccessResponse.class));
assertThat(((SuccessResponse) actual).getAffectedRows(), is(0L));
assertThat(((SuccessResponse) actual).getLastInsertId(), is(0L));
assertThat(actual, instanceOf(UpdateResponse.class));
assertThat(((UpdateResponse) actual).getUpdateCount(), is(0L));
assertThat(((UpdateResponse) actual).getLastInsertId(), is(0L));
verify(databaseCommunicationEngine, times(10)).execute();
}
......
......@@ -23,7 +23,7 @@ import org.apache.shardingsphere.shardingproxy.backend.communication.DatabaseCom
import org.apache.shardingsphere.shardingproxy.backend.communication.DatabaseCommunicationEngineFactory;
import org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.shardingproxy.backend.result.BackendResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.common.SuccessResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.update.UpdateResponse;
import org.apache.shardingsphere.shardingproxy.runtime.schema.LogicSchema;
import org.apache.shardingsphere.transaction.core.TransactionType;
import org.junit.Before;
......@@ -52,7 +52,7 @@ public final class UnicastBackendHandlerTest {
@Before
public void setUp() {
MockGlobalRegistryUtil.setLogicSchemas("schema", 10);
setUnderlyingHandler(new SuccessResponse(0L, 0L));
setUnderlyingHandler(new UpdateResponse());
}
@Test
......@@ -60,7 +60,7 @@ public final class UnicastBackendHandlerTest {
UnicastBackendHandler backendHandler = new UnicastBackendHandler("show variable like %s", backendConnection);
setDatabaseCommunicationEngine(backendHandler);
BackendResponse actual = backendHandler.execute();
assertThat(actual, instanceOf(SuccessResponse.class));
assertThat(actual, instanceOf(UpdateResponse.class));
backendHandler.execute();
}
......@@ -70,7 +70,7 @@ public final class UnicastBackendHandlerTest {
UnicastBackendHandler backendHandler = new UnicastBackendHandler("show variable like %s", backendConnection);
setDatabaseCommunicationEngine(backendHandler);
BackendResponse actual = backendHandler.execute();
assertThat(actual, instanceOf(SuccessResponse.class));
assertThat(actual, instanceOf(UpdateResponse.class));
backendHandler.execute();
}
......
......@@ -22,7 +22,7 @@ import org.apache.shardingsphere.shardingproxy.backend.MockGlobalRegistryUtil;
import org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.shardingproxy.backend.result.BackendResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.common.FailureResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.common.SuccessResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.update.UpdateResponse;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
......@@ -55,7 +55,7 @@ public final class UseDatabaseBackendHandlerTest {
UseDatabaseBackendHandler useSchemaBackendHandler = new UseDatabaseBackendHandler(useStatement, backendConnection);
BackendResponse actual = useSchemaBackendHandler.execute();
verify(backendConnection).setCurrentSchema(anyString());
assertThat(actual, instanceOf(SuccessResponse.class));
assertThat(actual, instanceOf(UpdateResponse.class));
}
@Test
......
......@@ -20,7 +20,7 @@ package org.apache.shardingsphere.shardingproxy.backend.text.sctl.set;
import org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.shardingproxy.backend.result.BackendResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.common.FailureResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.common.SuccessResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.update.UpdateResponse;
import org.apache.shardingsphere.transaction.core.TransactionType;
import org.junit.Test;
......@@ -37,7 +37,7 @@ public final class ShardingCTLSetBackendHandlerTest {
backendConnection.setCurrentSchema("schema");
ShardingCTLSetBackendHandler shardingCTLBackendHandler = new ShardingCTLSetBackendHandler("sctl:set transaction_type=XA", backendConnection);
BackendResponse actual = shardingCTLBackendHandler.execute();
assertThat(actual, instanceOf(SuccessResponse.class));
assertThat(actual, instanceOf(UpdateResponse.class));
assertThat(backendConnection.getTransactionType(), is(TransactionType.XA));
}
......@@ -46,7 +46,7 @@ public final class ShardingCTLSetBackendHandlerTest {
backendConnection.setCurrentSchema("schema");
ShardingCTLSetBackendHandler shardingCTLBackendHandler = new ShardingCTLSetBackendHandler("sctl:set transaction_type=BASE", backendConnection);
BackendResponse actual = shardingCTLBackendHandler.execute();
assertThat(actual, instanceOf(SuccessResponse.class));
assertThat(actual, instanceOf(UpdateResponse.class));
assertThat(backendConnection.getTransactionType(), is(TransactionType.BASE));
}
......@@ -55,7 +55,7 @@ public final class ShardingCTLSetBackendHandlerTest {
backendConnection.setCurrentSchema("schema");
ShardingCTLSetBackendHandler shardingCTLBackendHandler = new ShardingCTLSetBackendHandler("sctl:set transaction_type=LOCAL", backendConnection);
BackendResponse actual = shardingCTLBackendHandler.execute();
assertThat(actual, instanceOf(SuccessResponse.class));
assertThat(actual, instanceOf(UpdateResponse.class));
assertThat(backendConnection.getTransactionType(), is(TransactionType.LOCAL));
}
......
......@@ -18,7 +18,7 @@
package org.apache.shardingsphere.shardingproxy.backend.text.transaction;
import org.apache.shardingsphere.shardingproxy.backend.result.BackendResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.common.SuccessResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.update.UpdateResponse;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.instanceOf;
......@@ -30,6 +30,6 @@ public final class SkipBackendHandlerTest {
public void assertExecuteSkipBackendHandler() {
SkipBackendHandler skipBackendHandler = new SkipBackendHandler();
BackendResponse actual = skipBackendHandler.execute();
assertThat(actual, instanceOf(SuccessResponse.class));
assertThat(actual, instanceOf(UpdateResponse.class));
}
}
......@@ -19,7 +19,7 @@ package org.apache.shardingsphere.shardingproxy.backend.text.transaction;
import org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.shardingproxy.backend.result.BackendResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.common.SuccessResponse;
import org.apache.shardingsphere.shardingproxy.backend.result.update.UpdateResponse;
import org.apache.shardingsphere.transaction.core.TransactionOperationType;
import org.apache.shardingsphere.transaction.core.TransactionType;
import org.junit.Test;
......@@ -38,6 +38,6 @@ public final class TransactionBackendHandlerTest {
public void assertExecute() {
TransactionBackendHandler transactionBackendHandler = new TransactionBackendHandler(TransactionOperationType.BEGIN, backendConnection);
BackendResponse actual = transactionBackendHandler.execute();
assertThat(actual, instanceOf(SuccessResponse.class));
assertThat(actual, instanceOf(UpdateResponse.class));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册