use of com.jsql.model.bean.database.Database in project jsql-injection by ron190.
the class AbstractTestSuite method listColumns.
@Test
public void listColumns() throws JSqlException {
Set<Object> set1 = new HashSet<>();
Set<Object> set2 = new HashSet<>();
try {
List<Column> cs = DataAccess.listColumns(new Table(this.jsqlTableName, "0", new Database(this.jsqlDatabaseName, "0")));
List<String> columnsFound = new ArrayList<>();
for (Column c : cs) {
columnsFound.add(c.toString());
}
set1.addAll(columnsFound);
set2.addAll(this.columnToFind);
LOGGER.info("listColumns: found " + set1 + "\nto find " + set2 + "\n");
Assert.assertTrue(!set1.isEmpty() && !set2.isEmpty() && set1.equals(set2));
} catch (AssertionError e) {
Set<Object> tmp = new TreeSet<>();
for (Object x : set1) {
if (!set2.contains(x)) {
tmp.add(x);
}
}
for (Object x : set2) {
if (!set1.contains(x)) {
tmp.add(x);
}
}
throw new AssertionError("Error listColumns: " + tmp + "\n" + e);
}
}
use of com.jsql.model.bean.database.Database in project jsql-injection by ron190.
the class AbstractTestSuite method listValues.
@Test
public void listValues() throws JSqlException {
Set<Object> set1 = new TreeSet<>();
Set<Object> set2 = new TreeSet<>();
try {
String[][] vs = DataAccess.listValues(Arrays.asList(new Column(this.jsqlColumnName, new Table(this.jsqlTableName, "0", new Database(this.jsqlDatabaseName, "0")))));
List<String> valuesFound = new ArrayList<>();
for (String[] v : vs) {
valuesFound.add(v[2].replaceAll("\r\n", "\n"));
}
set1.addAll(valuesFound);
set2.addAll(this.valueToFind);
LOGGER.info("<<listValues: found " + set1.toString().replaceAll("\n", "[n]").replaceAll("\r", "[r]") + "\nto find " + set2.toString().replaceAll("\n", "[n]").replaceAll("\r", "[r]") + ">>\n");
Assert.assertTrue(!set1.isEmpty() && !set2.isEmpty() && set1.equals(set2));
} catch (AssertionError e) {
Set<Object> tmp = new TreeSet<>();
for (Object x : set1) {
if (!set2.contains(x)) {
tmp.add(x);
}
}
for (Object x : set2) {
if (!set1.contains(x)) {
tmp.add(x);
}
}
throw new AssertionError("Error listValues: " + tmp + "\n" + e);
}
}
use of com.jsql.model.bean.database.Database in project jsql-injection by ron190.
the class AbstractTestSuite method listTables.
@Test
public void listTables() throws JSqlException {
Set<Object> set1 = new HashSet<>();
Set<Object> set2 = new HashSet<>();
try {
List<Table> ts = DataAccess.listTables(new Database(this.jsqlDatabaseName, "0"));
List<String> tablesFound = new ArrayList<>();
for (Table t : ts) {
tablesFound.add(t.toString());
}
set1.addAll(tablesFound);
set2.addAll(this.tableToFind);
LOGGER.info("listTables: found " + set1 + "\nto find " + set2 + "\n");
Assert.assertTrue(!set1.isEmpty() && !set2.isEmpty() && set1.equals(set2));
} catch (AssertionError e) {
Set<Object> tmp = new TreeSet<>();
for (Object x : set1) {
if (!set2.contains(x)) {
tmp.add(x);
}
}
for (Object x : set2) {
if (!set1.contains(x)) {
tmp.add(x);
}
}
throw new AssertionError("Error listTables: " + tmp + "\n" + e);
}
}
Aggregations