提交 07252ecf authored 作者: Noel Grandin's avatar Noel Grandin

convert some indexOf to contains

上级 da0ff518
......@@ -194,8 +194,8 @@ public class BenchCThread {
rs.close();
String distInfo = dist[(dId - 1) % 10];
stock[number - 1] = sQuantity;
if ((data.indexOf("original") != -1)
&& (sData.indexOf("original") != -1)) {
if (data.contains("original")
&& sData.contains("original")) {
bg[number - 1] = 'B';
} else {
bg[number - 1] = 'G';
......
......@@ -10,7 +10,6 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.h2.api.ErrorCode;
import org.h2.api.Trigger;
import org.h2.store.fs.FileUtils;
......@@ -93,8 +92,8 @@ public class TestRunscript extends TestBase implements Trigger {
stat.execute("script schema include_schema1");
rs = stat.getResultSet();
while (rs.next()) {
assertTrue("The schema 'exclude_schema1' should not be present in the script",
rs.getString(1).indexOf("exclude_schema1".toUpperCase()) == -1);
assertFalse("The schema 'exclude_schema1' should not be present in the script",
rs.getString(1).contains("exclude_schema1".toUpperCase()));
}
rs.close();
stat.execute("create schema include_schema2");
......@@ -122,24 +121,24 @@ public class TestRunscript extends TestBase implements Trigger {
stat.execute("script table a.test1");
rs = stat.getResultSet();
while (rs.next()) {
assertTrue("The table 'a.test2' should not be present in the script",
rs.getString(1).indexOf("a.test2".toUpperCase()) == -1);
assertTrue("The table 'b.test1' should not be present in the script",
rs.getString(1).indexOf("b.test1".toUpperCase()) == -1);
assertTrue("The table 'b.test2' should not be present in the script",
rs.getString(1).indexOf("b.test2".toUpperCase()) == -1);
assertFalse("The table 'a.test2' should not be present in the script",
rs.getString(1).contains("a.test2".toUpperCase()));
assertFalse("The table 'b.test1' should not be present in the script",
rs.getString(1).contains("b.test1".toUpperCase()));
assertFalse("The table 'b.test2' should not be present in the script",
rs.getString(1).contains("b.test2".toUpperCase()));
}
rs.close();
stat.execute("set schema b");
stat.execute("script table test1");
rs = stat.getResultSet();
while (rs.next()) {
assertTrue("The table 'a.test1' should not be present in the script",
rs.getString(1).indexOf("a.test1".toUpperCase()) == -1);
assertTrue("The table 'a.test2' should not be present in the script",
rs.getString(1).indexOf("a.test2".toUpperCase()) == -1);
assertTrue("The table 'b.test2' should not be present in the script",
rs.getString(1).indexOf("b.test2".toUpperCase()) == -1);
assertFalse("The table 'a.test1' should not be present in the script",
rs.getString(1).contains("a.test1".toUpperCase()));
assertFalse("The table 'a.test2' should not be present in the script",
rs.getString(1).contains("a.test2".toUpperCase()));
assertFalse("The table 'b.test2' should not be present in the script",
rs.getString(1).contains("b.test2".toUpperCase()));
}
stat.execute("script nosettings table a.test1, test2");
rs = stat.getResultSet();
......@@ -163,9 +162,9 @@ public class TestRunscript extends TestBase implements Trigger {
stat.execute("script schema b");
rs = stat.getResultSet();
while (rs.next()) {
assertTrue("The function alias 'int_decode' " +
assertFalse("The function alias 'int_decode' " +
"should not be present in the script",
rs.getString(1).indexOf("int_decode".toUpperCase()) == -1);
rs.getString(1).contains("int_decode".toUpperCase()));
}
rs.close();
conn.close();
......@@ -186,9 +185,9 @@ public class TestRunscript extends TestBase implements Trigger {
stat.execute("script schema b");
rs = stat.getResultSet();
while (rs.next()) {
assertTrue("The constant 'default_email' " +
assertFalse("The constant 'default_email' " +
"should not be present in the script",
rs.getString(1).indexOf("default_email".toUpperCase()) == -1);
rs.getString(1).contains("default_email".toUpperCase()));
}
rs.close();
conn.close();
......@@ -207,8 +206,8 @@ public class TestRunscript extends TestBase implements Trigger {
stat.execute("script schema b");
rs = stat.getResultSet();
while (rs.next()) {
assertTrue("The sequence 'seq_id' should not be present in the script",
rs.getString(1).indexOf("seq_id".toUpperCase()) == -1);
assertFalse("The sequence 'seq_id' should not be present in the script",
rs.getString(1).contains("seq_id".toUpperCase()));
}
rs.close();
conn.close();
......@@ -229,18 +228,18 @@ public class TestRunscript extends TestBase implements Trigger {
stat.execute("script schema b");
rs = stat.getResultSet();
while (rs.next()) {
assertTrue("The sequence 'unique_constraint' " +
assertFalse("The sequence 'unique_constraint' " +
"should not be present in the script",
rs.getString(1).indexOf("unique_constraint".toUpperCase()) == -1);
rs.getString(1).contains("unique_constraint".toUpperCase()));
}
rs.close();
stat.execute("create table a.test2(x varchar, y int)");
stat.execute("script table a.test2");
rs = stat.getResultSet();
while (rs.next()) {
assertTrue("The sequence 'unique_constraint' " +
assertFalse("The sequence 'unique_constraint' " +
"should not be present in the script",
rs.getString(1).indexOf("unique_constraint".toUpperCase()) == -1);
rs.getString(1).contains("unique_constraint".toUpperCase()));
}
rs.close();
conn.close();
......@@ -261,16 +260,16 @@ public class TestRunscript extends TestBase implements Trigger {
stat.execute("script schema b");
rs = stat.getResultSet();
while (rs.next()) {
assertTrue("The trigger 'trigger_insert' should not be present in the script",
rs.getString(1).indexOf("trigger_insert".toUpperCase()) == -1);
assertFalse("The trigger 'trigger_insert' should not be present in the script",
rs.getString(1).contains("trigger_insert".toUpperCase()));
}
rs.close();
stat.execute("create table a.test2(x varchar, y int)");
stat.execute("script table a.test2");
rs = stat.getResultSet();
while (rs.next()) {
assertTrue("The trigger 'trigger_insert' should not be present in the script",
rs.getString(1).indexOf("trigger_insert".toUpperCase()) == -1);
assertFalse("The trigger 'trigger_insert' should not be present in the script",
rs.getString(1).contains("trigger_insert".toUpperCase()));
}
rs.close();
conn.close();
......@@ -294,8 +293,8 @@ public class TestRunscript extends TestBase implements Trigger {
stat.execute("script schema b");
rs = stat.getResultSet();
while (rs.next()) {
assertTrue("The grant to 'USER_A1' should not be present in the script",
rs.getString(1).indexOf("to USER_A1".toUpperCase()) == -1);
assertFalse("The grant to 'USER_A1' should not be present in the script",
rs.getString(1).contains("to USER_A1".toUpperCase()));
}
rs.close();
stat.execute("create user USER_A2 password 'test'");
......@@ -304,10 +303,10 @@ public class TestRunscript extends TestBase implements Trigger {
stat.execute("script table a.test2");
rs = stat.getResultSet();
while (rs.next()) {
assertTrue("The grant to 'USER_A1' should not be present in the script",
rs.getString(1).indexOf("to USER_A1".toUpperCase()) == -1);
assertTrue("The grant to 'USER_B1' should not be present in the script",
rs.getString(1).indexOf("to USER_B1".toUpperCase()) == -1);
assertFalse("The grant to 'USER_A1' should not be present in the script",
rs.getString(1).contains("to USER_A1".toUpperCase()));
assertFalse("The grant to 'USER_B1' should not be present in the script",
rs.getString(1).contains("to USER_B1".toUpperCase()));
}
rs.close();
conn.close();
......
......@@ -19,7 +19,6 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Random;
import org.h2.test.TestAll;
import org.h2.test.TestBase;
import org.h2.util.New;
......
......@@ -154,7 +154,7 @@ public class TestClearReferences extends TestBase {
throw e;
}
for (Field field : fields) {
if (field.getType().isPrimitive() || field.getName().indexOf("$") != -1) {
if (field.getType().isPrimitive() || field.getName().contains("$")) {
continue;
}
int modifiers = field.getModifiers();
......@@ -182,7 +182,7 @@ public class TestClearReferences extends TestBase {
private void clearInstance(Object instance) throws Exception {
for (Field field : instance.getClass().getDeclaredFields()) {
if (field.getType().isPrimitive() || (field.getName().indexOf("$") != -1)) {
if (field.getType().isPrimitive() || field.getName().contains("$")) {
continue;
}
int modifiers = field.getModifiers();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论