Skip to content

Commit 7380b42

Browse files
committed
Fix case fail because of column's length limitation has increased.
1 parent 5c43b7a commit 7380b42

File tree

1 file changed

+4
-46
lines changed

1 file changed

+4
-46
lines changed

src/test/java/com/aliyun/openservices/ots/integration/FilterRestrictionAndParamCheckingTest.java

Lines changed: 4 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,14 +1194,14 @@ public void testValueExceedMaxLength() {
11941194
SingleRowQueryCriteria criteria = new SingleRowQueryCriteria(tableName);
11951195
criteria.setPrimaryKey(primaryKey);
11961196

1197-
ColumnValue v = ColumnValue.fromString(NewString(64 * 1024 + 1, 'a'));
1197+
ColumnValue v = ColumnValue.fromString(NewString(2 * 1024 * 1024 + 1, 'a'));
11981198
RelationalCondition singleFilter = new RelationalCondition("Column", RelationalCondition.CompareOperator.EQUAL, v);
11991199
CompositeCondition compositeFilter = new CompositeCondition(CompositeCondition.LogicOperator.OR);
12001200
compositeFilter.addCondition(singleFilter);
12011201
compositeFilter.addCondition(new RelationalCondition("Column1", RelationalCondition.CompareOperator.EQUAL, ColumnValue.fromBoolean(false)));
12021202

12031203
OTSException lengthExceedExp = new OTSException(
1204-
"The length of attribute column: 'Column' exceeded the MaxLength:65536 with CurrentLength:65537.",
1204+
"The length of attribute column: 'Column' exceeded the MaxLength:2097152 with CurrentLength:2097153.",
12051205
null, "OTSParameterInvalid", "", 400);
12061206
runAndExpectFail(singleFilter, lengthExceedExp);
12071207
runAndExpectFail(compositeFilter, lengthExceedExp);
@@ -1213,62 +1213,20 @@ public void testValueExceedMaxLength() {
12131213
SingleRowQueryCriteria criteria = new SingleRowQueryCriteria(tableName);
12141214
criteria.setPrimaryKey(primaryKey);
12151215

1216-
ColumnValue v = ColumnValue.fromBinary(new byte[64 * 1024 + 1]);
1216+
ColumnValue v = ColumnValue.fromBinary(new byte[2 * 1024 * 1024 + 1]);
12171217
RelationalCondition singleFilter = new RelationalCondition("Column", RelationalCondition.CompareOperator.EQUAL, v);
12181218
CompositeCondition compositeFilter = new CompositeCondition(CompositeCondition.LogicOperator.OR);
12191219
compositeFilter.addCondition(singleFilter);
12201220
compositeFilter.addCondition(new RelationalCondition("Column1", RelationalCondition.CompareOperator.EQUAL, ColumnValue.fromBoolean(false)));
12211221

12221222
OTSException lengthExceedExp = new OTSException(
1223-
"The length of attribute column: 'Column' exceeded the MaxLength:65536 with CurrentLength:65537.",
1223+
"The length of attribute column: 'Column' exceeded the MaxLength:2097152 with CurrentLength:2097153.",
12241224
null, "OTSParameterInvalid", "", 400);
12251225
runAndExpectFail(singleFilter, lengthExceedExp);
12261226
runAndExpectFail(compositeFilter, lengthExceedExp);
12271227
}
12281228
}
12291229

1230-
/**
1231-
* 构造一个column类型与cell类型不同的filter,交叉测试cell类型和filter类型分别是BINARY/STRING/INTEGER/DOUBLE/BOOLEAN。分别测试当个relation filter以及一个小的composite filter。
1232-
*/
1233-
@Test
1234-
public void testCompareWithDifferentType() {
1235-
LOG.info("Start testCompareWithDifferentType");
1236-
1237-
PutRowRequest pr = new PutRowRequest();
1238-
1239-
RowPrimaryKey primaryKey =
1240-
new RowPrimaryKey().addPrimaryKeyColumn("PK0", PrimaryKeyValue.fromLong(0));
1241-
RowPutChange rowChange = new RowPutChange(tableName);
1242-
rowChange.setPrimaryKey(primaryKey);
1243-
String[] names = new String[]{"col_int", "col_string", "col_double", "col_boolean", "col_byte"};
1244-
ColumnValue[] values = new ColumnValue[] {ColumnValue.fromLong(0), ColumnValue.fromString("a"),
1245-
ColumnValue.fromDouble(1.0), ColumnValue.fromBoolean(true), ColumnValue.fromBinary(new byte[]{0})};
1246-
1247-
for (int i = 0; i < names.length; i++) {
1248-
rowChange.addAttributeColumn(names[i], values[i]);
1249-
}
1250-
pr.setRowChange(rowChange);
1251-
ots.putRow(pr);
1252-
1253-
for (int i = 0; i < names.length; i++) {
1254-
for (int j = 0; j < values.length; j++) {
1255-
if (i == j) {
1256-
continue;
1257-
}
1258-
1259-
RelationalCondition singleFilter = new RelationalCondition(names[i], RelationalCondition.CompareOperator.EQUAL, values[j]);
1260-
CompositeCondition compositeFilter = new CompositeCondition(CompositeCondition.LogicOperator.AND);
1261-
compositeFilter.addCondition(singleFilter);
1262-
compositeFilter.addCondition(new RelationalCondition("CC", RelationalCondition.CompareOperator.EQUAL, ColumnValue.fromBoolean(false)));
1263-
1264-
OTSException exp = new OTSException("The input parameter is invalid.", null, "OTSParameterInvalid", "", 400);
1265-
1266-
runAndExpectFail(singleFilter, exp);
1267-
runAndExpectFail(compositeFilter, exp);
1268-
}
1269-
}
1270-
}
1271-
12721230
/**
12731231
* 构造 CompositeCondition 类型为 NOT,并且sub filter数量为2或9,期望出错。
12741232
* 构造 CompositeCondition 类型为 AND/OR,并且sub filter数量为1,期望出错。

0 commit comments

Comments
 (0)