Skip to content

Commit f95d4d5

Browse files
authored
Merge pull request #1140 from WebFuzzing/sql-multidb-v3
sql-multidb-v3
2 parents 0baef1f + 56ba8e6 commit f95d4d5

File tree

164 files changed

+2062
-1032
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

164 files changed

+2062
-1032
lines changed

client-java/controller/src/main/java/org/evomaster/client/java/controller/internal/SutController.java

Lines changed: 162 additions & 60 deletions
Large diffs are not rendered by default.

client-java/controller/src/test/java/org/evomaster/client/java/controller/internal/db/sql/InitSqlScriptWithSmartDbCleanTest.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,17 @@ default String getInitSqlScript() {
3939

4040
@Test
4141
default void testAccessedFkClean() throws Exception {
42-
EMSqlScriptRunner.execCommand(getConnection(), "CREATE TABLE Bar(id INT Primary Key, valueColumn INT)", true);
43-
EMSqlScriptRunner.execCommand(getConnection(), "CREATE TABLE Foo(id INT Primary Key, valueColumn INT, refer_foo INT DEFAULT NULL, bar_id INT, " +
42+
EMSqlScriptRunner.execCommand(getConnection(),
43+
"CREATE TABLE Bar(id INT Primary Key, valueColumn INT)", true);
44+
EMSqlScriptRunner.execCommand(getConnection(),
45+
"CREATE TABLE Foo(id INT Primary Key, valueColumn INT, refer_foo INT DEFAULT NULL, bar_id INT, " +
4446
"CONSTRAINT fk_foo FOREIGN KEY (bar_id) REFERENCES Bar(id)," +
4547
"CONSTRAINT fk_self_foo FOREIGN KEY (refer_foo) REFERENCES Foo(id) )", true);
46-
EMSqlScriptRunner.execCommand(getConnection(), "CREATE TABLE Abc(id INT Primary Key, valueColumn INT, foo_id INT, " +
48+
EMSqlScriptRunner.execCommand(getConnection(),
49+
"CREATE TABLE Abc(id INT Primary Key, valueColumn INT, foo_id INT, " +
4750
"CONSTRAINT fk_abc FOREIGN KEY (foo_id) REFERENCES Foo(id) )", true);
48-
EMSqlScriptRunner.execCommand(getConnection(), "CREATE TABLE Xyz(id INT Primary Key, valueColumn INT, abc_id INT, " +
51+
EMSqlScriptRunner.execCommand(getConnection(),
52+
"CREATE TABLE Xyz(id INT Primary Key, valueColumn INT, abc_id INT, " +
4953
"CONSTRAINT fk_xyz FOREIGN KEY (abc_id) REFERENCES Abc(id) )", true);
5054

5155
InstrumentedSutStarter starter = getInstrumentedSutStarter();

client-java/controller/src/test/java/org/evomaster/client/java/controller/internal/db/sql/h2/DatabaseFakeH2SutController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public SutInfoDto.OutputFormat getPreferredOutputFormat() {
5252
@Override
5353
public String startSut() {
5454
running = true;
55-
DbCleaner.clearDatabase(sqlConnection, null, DatabaseType.H2);
55+
DbCleaner.clearDatabase_H2(sqlConnection, null, null);
5656
return "foo";
5757
}
5858

client-java/controller/src/test/java/org/evomaster/client/java/controller/internal/db/sql/h2/H2SchemaExtractorTest.java

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public void testBasic() throws Exception {
3232
assertAll(() -> assertEquals("db_test", schema.name.toLowerCase()),
3333
() -> assertEquals(DatabaseType.H2, schema.databaseType),
3434
() -> assertEquals(1, schema.tables.size()),
35-
() -> assertEquals("foo", schema.tables.get(0).name.toLowerCase()),
35+
() -> assertEquals("foo", schema.tables.get(0).id.name.toLowerCase()),
3636
() -> assertEquals(1, schema.tables.get(0).columns.size())
3737
);
3838
}
@@ -45,8 +45,8 @@ public void testTwoTables() throws Exception {
4545
assertNotNull(schema);
4646

4747
assertEquals(2, schema.tables.size());
48-
assertTrue(schema.tables.stream().map(t -> t.name.toLowerCase()).anyMatch(n -> n.equals("foo")));
49-
assertTrue(schema.tables.stream().map(t -> t.name.toLowerCase()).anyMatch(n -> n.equals("bar")));
48+
assertTrue(schema.tables.stream().map(t -> t.id.name.toLowerCase()).anyMatch(n -> n.equals("foo")));
49+
assertTrue(schema.tables.stream().map(t -> t.id.name.toLowerCase()).anyMatch(n -> n.equals("bar")));
5050
}
5151

5252

@@ -135,8 +135,8 @@ public void testBasicForeignKey() throws Exception {
135135
DbInfoDto schema = DbInfoExtractor.extract(getConnection());
136136
assertEquals(2, schema.tables.size());
137137

138-
TableDto bar = schema.tables.stream().filter(t -> t.name.equalsIgnoreCase("Bar")).findAny().get();
139-
TableDto foo = schema.tables.stream().filter(t -> t.name.equalsIgnoreCase("Foo")).findAny().get();
138+
TableDto bar = schema.tables.stream().filter(t -> t.id.name.equalsIgnoreCase("Bar")).findAny().get();
139+
TableDto foo = schema.tables.stream().filter(t -> t.id.name.equalsIgnoreCase("Foo")).findAny().get();
140140

141141
assertEquals(0, bar.foreignKeys.size());
142142
assertEquals(1, foo.foreignKeys.size());
@@ -184,7 +184,7 @@ public void testColumnUpperBoundConstraint() throws Exception {
184184

185185
assertEquals(1, schema.tables.size());
186186

187-
TableDto fooTable = schema.tables.stream().filter(t -> t.name.equalsIgnoreCase("Foo")).findAny().get();
187+
TableDto fooTable = schema.tables.stream().filter(t -> t.id.name.equalsIgnoreCase("Foo")).findAny().get();
188188

189189
assertEquals(2, fooTable.columns.size());
190190

@@ -212,7 +212,7 @@ public void testTableConstraint() throws Exception {
212212

213213
assertEquals(1, schema.tables.size());
214214

215-
TableDto fooTable = schema.tables.stream().filter(t -> t.name.equalsIgnoreCase("Foo")).findAny().get();
215+
TableDto fooTable = schema.tables.stream().filter(t -> t.id.name.equalsIgnoreCase("Foo")).findAny().get();
216216

217217
assertEquals(2, fooTable.columns.size());
218218

@@ -236,7 +236,7 @@ public void testPrimaryKey() throws Exception {
236236

237237
assertEquals(1, schema.tables.size());
238238

239-
TableDto fooTable = schema.tables.stream().filter(t -> t.name.equalsIgnoreCase("Foo")).findAny().get();
239+
TableDto fooTable = schema.tables.stream().filter(t -> t.id.name.equalsIgnoreCase("Foo")).findAny().get();
240240

241241
assertEquals(1, fooTable.columns.size());
242242

@@ -257,7 +257,7 @@ public void testEnumStringConstraint() throws Exception {
257257

258258
assertEquals(1, schema.tables.size());
259259

260-
TableDto fooTable = schema.tables.stream().filter(t -> t.name.equalsIgnoreCase("Foo")).findAny().get();
260+
TableDto fooTable = schema.tables.stream().filter(t -> t.id.name.equalsIgnoreCase("Foo")).findAny().get();
261261

262262
assertEquals(2, fooTable.columns.size());
263263

@@ -282,7 +282,7 @@ public void testEnumBooleanConstraint() throws Exception {
282282

283283
assertEquals(1, schema.tables.size());
284284

285-
TableDto fooTable = schema.tables.stream().filter(t -> t.name.equalsIgnoreCase("Foo")).findAny().get();
285+
TableDto fooTable = schema.tables.stream().filter(t -> t.id.name.equalsIgnoreCase("Foo")).findAny().get();
286286

287287
assertEquals(1, fooTable.columns.size());
288288

@@ -306,7 +306,7 @@ public void testEnumIntegerConstraint() throws Exception {
306306

307307
assertEquals(1, schema.tables.size());
308308

309-
TableDto fooTable = schema.tables.stream().filter(t -> t.name.equalsIgnoreCase("Foo")).findAny().get();
309+
TableDto fooTable = schema.tables.stream().filter(t -> t.id.name.equalsIgnoreCase("Foo")).findAny().get();
310310

311311
assertEquals(1, fooTable.columns.size());
312312

@@ -331,7 +331,7 @@ public void testEnumTinyIntConstraint() throws Exception {
331331

332332
assertEquals(1, schema.tables.size());
333333

334-
TableDto fooTable = schema.tables.stream().filter(t -> t.name.equalsIgnoreCase("Foo")).findAny().get();
334+
TableDto fooTable = schema.tables.stream().filter(t -> t.id.name.equalsIgnoreCase("Foo")).findAny().get();
335335

336336
assertEquals(1, fooTable.columns.size());
337337

@@ -355,7 +355,7 @@ public void testEnumSmallIntConstraint() throws Exception {
355355

356356
assertEquals(1, schema.tables.size());
357357

358-
TableDto fooTable = schema.tables.stream().filter(t -> t.name.equalsIgnoreCase("Foo")).findAny().get();
358+
TableDto fooTable = schema.tables.stream().filter(t -> t.id.name.equalsIgnoreCase("Foo")).findAny().get();
359359

360360
assertEquals(1, fooTable.columns.size());
361361

@@ -380,7 +380,7 @@ public void testEnumBigIntConstraint() throws Exception {
380380

381381
assertEquals(1, schema.tables.size());
382382

383-
TableDto fooTable = schema.tables.stream().filter(t -> t.name.equalsIgnoreCase("Foo")).findAny().get();
383+
TableDto fooTable = schema.tables.stream().filter(t -> t.id.name.equalsIgnoreCase("Foo")).findAny().get();
384384

385385
assertEquals(1, fooTable.columns.size());
386386

@@ -404,7 +404,7 @@ public void testEnumDoubleConstraint() throws Exception {
404404

405405
assertEquals(1, schema.tables.size());
406406

407-
TableDto fooTable = schema.tables.stream().filter(t -> t.name.equalsIgnoreCase("Foo")).findAny().get();
407+
TableDto fooTable = schema.tables.stream().filter(t -> t.id.name.equalsIgnoreCase("Foo")).findAny().get();
408408

409409
assertEquals(1, fooTable.columns.size());
410410

@@ -429,7 +429,7 @@ public void testEnumRealConstraint() throws Exception {
429429

430430
assertEquals(1, schema.tables.size());
431431

432-
TableDto fooTable = schema.tables.stream().filter(t -> t.name.equalsIgnoreCase("Foo")).findAny().get();
432+
TableDto fooTable = schema.tables.stream().filter(t -> t.id.name.equalsIgnoreCase("Foo")).findAny().get();
433433

434434
assertEquals(1, fooTable.columns.size());
435435

@@ -453,7 +453,7 @@ public void testEnumDecimalConstraint() throws Exception {
453453

454454
assertEquals(1, schema.tables.size());
455455

456-
TableDto fooTable = schema.tables.stream().filter(t -> t.name.equalsIgnoreCase("Foo")).findAny().get();
456+
TableDto fooTable = schema.tables.stream().filter(t -> t.id.name.equalsIgnoreCase("Foo")).findAny().get();
457457

458458
assertEquals(1, fooTable.columns.size());
459459

@@ -475,7 +475,7 @@ public void testEnumCharConstraint() throws Exception {
475475

476476
assertEquals(1, schema.tables.size());
477477

478-
TableDto fooTable = schema.tables.stream().filter(t -> t.name.equalsIgnoreCase("Foo")).findAny().get();
478+
TableDto fooTable = schema.tables.stream().filter(t -> t.id.name.equalsIgnoreCase("Foo")).findAny().get();
479479

480480
assertEquals(1, fooTable.columns.size());
481481

@@ -498,7 +498,7 @@ public void testEnumLikeConstraint() throws Exception {
498498

499499
assertEquals(1, schema.tables.size());
500500

501-
TableDto fooTable = schema.tables.stream().filter(t -> t.name.equalsIgnoreCase("Foo")).findAny().get();
501+
TableDto fooTable = schema.tables.stream().filter(t -> t.id.name.equalsIgnoreCase("Foo")).findAny().get();
502502

503503
assertEquals(1, fooTable.columns.size());
504504

@@ -520,7 +520,7 @@ public void testCreateEnumIntColumn() throws Exception {
520520
DbInfoDto schema = DbInfoExtractor.extract(getConnection());
521521
assertEquals(1, schema.tables.size());
522522

523-
TableDto fooTable = schema.tables.stream().filter(t -> t.name.equalsIgnoreCase("Foo")).findAny().get();
523+
TableDto fooTable = schema.tables.stream().filter(t -> t.id.name.equalsIgnoreCase("Foo")).findAny().get();
524524

525525
assertEquals(1, fooTable.columns.size());
526526

@@ -546,7 +546,7 @@ public void testCreateEnumColumn() throws Exception {
546546
DbInfoDto schema = DbInfoExtractor.extract(getConnection());
547547
assertEquals(1, schema.tables.size());
548548

549-
TableDto fooTable = schema.tables.stream().filter(t -> t.name.equalsIgnoreCase("Foo")).findAny().get();
549+
TableDto fooTable = schema.tables.stream().filter(t -> t.id.name.equalsIgnoreCase("Foo")).findAny().get();
550550

551551
assertEquals(1, fooTable.columns.size());
552552

@@ -571,7 +571,7 @@ public void testEnumColumn() throws Exception {
571571
DbInfoDto schema = DbInfoExtractor.extract(getConnection());
572572
assertEquals(1, schema.tables.size());
573573

574-
TableDto fooTable = schema.tables.stream().filter(t -> t.name.equalsIgnoreCase("Foo")).findAny().get();
574+
TableDto fooTable = schema.tables.stream().filter(t -> t.id.name.equalsIgnoreCase("Foo")).findAny().get();
575575

576576
assertEquals(1, fooTable.columns.size());
577577

@@ -598,7 +598,7 @@ public void testArray() throws Exception {
598598
DbInfoDto schema = DbInfoExtractor.extract(getConnection());
599599
assertEquals(1, schema.tables.size());
600600

601-
Optional<TableDto> fooTableOptional = schema.tables.stream().filter(t -> t.name.equalsIgnoreCase("foo")).findAny();
601+
Optional<TableDto> fooTableOptional = schema.tables.stream().filter(t -> t.id.name.equalsIgnoreCase("foo")).findAny();
602602
assertTrue(fooTableOptional.isPresent());
603603
TableDto fooTable = fooTableOptional.get();
604604

@@ -621,7 +621,7 @@ public void testMultidimensionalArrayOfTwoDimensions() throws Exception {
621621
DbInfoDto schema = DbInfoExtractor.extract(getConnection());
622622
assertEquals(1, schema.tables.size());
623623

624-
Optional<TableDto> fooTableOptional = schema.tables.stream().filter(t -> t.name.equalsIgnoreCase("foo")).findAny();
624+
Optional<TableDto> fooTableOptional = schema.tables.stream().filter(t -> t.id.name.equalsIgnoreCase("foo")).findAny();
625625
assertTrue(fooTableOptional.isPresent());
626626
TableDto fooTable = fooTableOptional.get();
627627

@@ -644,7 +644,7 @@ public void testMultidimensionalArrayOfThreeDimensions() throws Exception {
644644
DbInfoDto schema = DbInfoExtractor.extract(getConnection());
645645
assertEquals(1, schema.tables.size());
646646

647-
Optional<TableDto> fooTableOptional = schema.tables.stream().filter(t -> t.name.equalsIgnoreCase("foo")).findAny();
647+
Optional<TableDto> fooTableOptional = schema.tables.stream().filter(t -> t.id.name.equalsIgnoreCase("foo")).findAny();
648648
assertTrue(fooTableOptional.isPresent());
649649
TableDto fooTable = fooTableOptional.get();
650650

@@ -667,7 +667,7 @@ public void testBooleanNonlArray() throws Exception {
667667
DbInfoDto schema = DbInfoExtractor.extract(getConnection());
668668
assertEquals(1, schema.tables.size());
669669

670-
Optional<TableDto> fooTableOptional = schema.tables.stream().filter(t -> t.name.equalsIgnoreCase("foo")).findAny();
670+
Optional<TableDto> fooTableOptional = schema.tables.stream().filter(t -> t.id.name.equalsIgnoreCase("foo")).findAny();
671671
assertTrue(fooTableOptional.isPresent());
672672
TableDto fooTable = fooTableOptional.get();
673673

@@ -690,7 +690,7 @@ public void testVarCharArray() throws Exception {
690690
DbInfoDto schema = DbInfoExtractor.extract(getConnection());
691691
assertEquals(1, schema.tables.size());
692692

693-
Optional<TableDto> fooTableOptional = schema.tables.stream().filter(t -> t.name.equalsIgnoreCase("foo")).findAny();
693+
Optional<TableDto> fooTableOptional = schema.tables.stream().filter(t -> t.id.name.equalsIgnoreCase("foo")).findAny();
694694
assertTrue(fooTableOptional.isPresent());
695695
TableDto fooTable = fooTableOptional.get();
696696

@@ -714,7 +714,7 @@ public void testIntegerArrayWithMaxLengthColumn() throws Exception {
714714
DbInfoDto schema = DbInfoExtractor.extract(getConnection());
715715
assertEquals(1, schema.tables.size());
716716

717-
Optional<TableDto> fooTableOptional = schema.tables.stream().filter(t -> t.name.equalsIgnoreCase("foo")).findAny();
717+
Optional<TableDto> fooTableOptional = schema.tables.stream().filter(t -> t.id.name.equalsIgnoreCase("foo")).findAny();
718718
assertTrue(fooTableOptional.isPresent());
719719
TableDto fooTable = fooTableOptional.get();
720720

client-java/controller/src/test/java/org/evomaster/client/java/controller/internal/db/sql/h2/H2SqlHandlerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public void testHandleNoRows(boolean useCompleteSqlHeuristics) throws Exception
3131
DbInfoExtractor dbInfoExtractor = new DbInfoExtractor();
3232
DbInfoDto schema = dbInfoExtractor.extract(connection);
3333
assertEquals(1, schema.tables.size());
34-
assertEquals("Person".toUpperCase(), schema.tables.get(0).name.toUpperCase());
34+
assertEquals("Person".toUpperCase(), schema.tables.get(0).id.name.toUpperCase());
3535

3636
SqlHandler sqlHandler = new SqlHandler(null);
3737
sqlHandler.setConnection(connection);
@@ -67,7 +67,7 @@ public void testHandleOneOrMoreRows(boolean useCompleteSqlHeuristics) throws Exc
6767
DbInfoExtractor dbInfoExtractor = new DbInfoExtractor();
6868
DbInfoDto schema = dbInfoExtractor.extract(connection);
6969
assertEquals(1, schema.tables.size());
70-
assertEquals("Person".toUpperCase(), schema.tables.get(0).name.toUpperCase());
70+
assertEquals("Person".toUpperCase(), schema.tables.get(0).id.name.toUpperCase());
7171

7272
SqlScriptRunner.execCommand(connection, "INSERT INTO Person (person_id, first_name, last_name, age, email)\n" +
7373
"VALUES (1, 'John', 'Doe', 30, '[email protected]');");

client-java/controller/src/test/java/org/evomaster/client/java/controller/internal/db/sql/mysql/DatabaseFakeMySQLSutController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public SutInfoDto.OutputFormat getPreferredOutputFormat() {
5555
public String startSut() {
5656
running = true;
5757

58-
DbCleaner.clearDatabase(sqlConnection, DB_NAME,null, DatabaseType.MYSQL);
58+
DbCleaner.clearDatabase_MySQL(sqlConnection, DB_NAME,null, null);
5959
return "foo";
6060
}
6161

client-java/controller/src/test/java/org/evomaster/client/java/controller/internal/db/sql/mysql/MySQLSchemaExtractorTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public void testCaseSensitivityOfExtractor() throws Exception {
8686

8787
TableDto table = schema.tables.get(0);
8888
assertEquals("intColumn",table.columns.get(0).name);
89-
assertEquals("TableNot", table.name);
89+
assertEquals("TableNot", table.id.name);
9090

9191
}
9292

@@ -163,15 +163,15 @@ public void testTwoSchemas() throws Exception {
163163
DbInfoDto schemaTest0 = DbInfoExtractor.extract(testUser0Connection);
164164
assertEquals("test", schemaTest0.name);
165165
assertEquals(1, schemaTest0.tables.size());
166-
assertEquals("my_table", schemaTest0.tables.get(0).name);
166+
assertEquals("my_table", schemaTest0.tables.get(0).id.name);
167167

168168
DbInfoDto newSchema = DbInfoExtractor.extract(testUser1Connection);
169169
// assertEquals("new_schema", newSchema.name);
170170
assertEquals("test", newSchema.name); //the connection is still on same URL, with same catalog
171171
//assertEquals(1, newSchema.tables.size());
172172
//we are now fetching data for all schemas (/catalogs in MySQL)
173173
assertEquals(2, newSchema.tables.size());
174-
assertEquals("my_table", newSchema.tables.get(0).name);
174+
assertEquals("my_table", newSchema.tables.get(0).id.name);
175175

176176
SqlScriptRunner.execCommand(testUser1Connection, "DROP SCHEMA IF EXISTS new_schema");
177177
deleteUserInDatabase(url, anotherTestUserName);

0 commit comments

Comments
 (0)