[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-schemafuzz] branch master updated: added more dataty
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-schemafuzz] branch master updated: added more datatypes (not tested). Working on timestamps and general main loop structure. |
Date: |
Tue, 29 May 2018 11:56:14 +0200 |
This is an automated email from the git hooks/post-receive script.
erwan-ulrich pushed a commit to branch master
in repository schemafuzz.
The following commit(s) were added to refs/heads/master by this push:
new ca68b41 added more datatypes (not tested). Working on timestamps and
general main loop structure.
ca68b41 is described below
commit ca68b41f0172dc17ac39db9e913cd9566a0b9536
Author: Feideus <address@hidden>
AuthorDate: Tue May 29 11:56:08 2018 +0200
added more datatypes (not tested). Working on timestamps and general main
loop structure.
---
TODO.txt | 1 -
src/main/java/org/schemaspy/DBFuzzer.java | 28 ++++++++++-----
.../java/org/schemaspy/model/GenericTreeNode.java | 42 +++++++++++++++++-----
3 files changed, 53 insertions(+), 18 deletions(-)
diff --git a/TODO.txt b/TODO.txt
index 4dcbc01..1e12e98 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -3,7 +3,6 @@ MANUAL FOR USE
WEBSITE
TEST CASES/ UNIT TESTING INTEGRATION TESTING
VARCHAR CLASSIFIER (LATER)
-ADD DEPTH TO COMMAND LINE OPTIONS AS ENDING CONDITION FOR MAIN LOOP
ADD MULTI TABLE/ROW SUPPORT TO THE TREE
MORE TYPES
MORE DB TYPES
diff --git a/src/main/java/org/schemaspy/DBFuzzer.java
b/src/main/java/org/schemaspy/DBFuzzer.java
index cf62f06..8de09e3 100644
--- a/src/main/java/org/schemaspy/DBFuzzer.java
+++ b/src/main/java/org/schemaspy/DBFuzzer.java
@@ -79,7 +79,6 @@ public class DBFuzzer
boolean resQuery;
int TreeDepth = 0;
int maxDepth =
Integer.parseInt(analyzer.getCommandLineArguments().getMaxDepth());
- System.out.println(maxDepth);
int mark = 0;
//adding CASCADE to all foreign key tableColumns.
settingTemporaryCascade(false); // need to drop and recreate database
@@ -179,8 +178,8 @@ public class DBFuzzer
Table randomTable = pickRandomTable();
- //String theQuery = "SELECT * FROM "+randomTable.getName()+" ORDER BY
RANDOM() LIMIT 1";
- String theQuery = "SELECT * FROM test_table2 ORDER BY RANDOM() LIMIT 1";
// Change test_table2 to test_table here to swap back to line finding
+ String theQuery = "SELECT * FROM "+randomTable.getName()+" ORDER BY
RANDOM() LIMIT 1";
+ //String theQuery = "SELECT * FROM test_table2 ORDER BY RANDOM() LIMIT
1"; // Change test_table2 to test_table here to swap back to line finding
QueryResponseParser qrp = new QueryResponseParser();
ResultSet rs = null;
Row res = null ;
@@ -190,7 +189,7 @@ public class DBFuzzer
{
stmt = analyzer.getSqlService().prepareStatement(theQuery);
rs = stmt.executeQuery();
- res =
qrp.parse(rs,analyzer.getDb().getTablesMap().get("test_table2")).getRows().get(0);
//randomTable should be set there
+ res =
qrp.parse(rs,analyzer.getDb().getTablesMap().get(randomTable.getName())).getRows().get(0);
//randomTable should be set there
}
catch (Exception e)
{
@@ -326,10 +325,23 @@ public class DBFuzzer
}
else if (markingDiff == 0 || markingDiff < 0)
{
- SingleChange tmp =
mutationTree.getRoot().singleChangeBasedOnWeight();
- nextMut = new
GenericTreeNode(tmp.getAttachedToMutation().getPost_change_row(), nextId(),
mutationTree.getRoot(), tmp.getAttachedToMutation());
- nextMut.setChosenChange(tmp);
- nextMut.initPostChangeRow();
+ Random changeOrDepthen = new Random();
+
+ if(changeOrDepthen.nextInt(2) == 1)
+ {
+ SingleChange tmp =
mutationTree.getRoot().singleChangeBasedOnWeight();
+ nextMut = new
GenericTreeNode(tmp.getAttachedToMutation().getPost_change_row(), nextId(),
mutationTree.getRoot(), tmp.getAttachedToMutation());
+ nextMut.setChosenChange(tmp);
+ nextMut.initPostChangeRow();
+ }
+ else
+ {
+ Row nextRow = pickRandomRow();
+ nextMut = new
GenericTreeNode(nextRow,nextId(),mutationTree.getRoot(),previousMutation);
+ Random nextSingleChangeId = new Random();
+
nextMut.setChosenChange(nextMut.getPotential_changes().get(nextSingleChangeId.nextInt(nextMut.getPotential_changes().size())));
+ nextMut.initPostChangeRow();
+ }
}
else
System.out.println("I mean What Da Heck");
diff --git a/src/main/java/org/schemaspy/model/GenericTreeNode.java
b/src/main/java/org/schemaspy/model/GenericTreeNode.java
index 0e93ab4..f974463 100644
--- a/src/main/java/org/schemaspy/model/GenericTreeNode.java
+++ b/src/main/java/org/schemaspy/model/GenericTreeNode.java
@@ -2,6 +2,8 @@ package org.schemaspy.model;
import java.sql.PreparedStatement;
+import java.sql.Timestamp;
+import java.text.SimpleDateFormat;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
@@ -226,6 +228,8 @@ public class GenericTreeNode {
e.printStackTrace();
}
}
+ if(possibilities.isEmpty())
+ throw new Error("No raw Mutation could be found for this row");
//REMOVING POSSIBILITIES THAT DONT MATCH CONSTRAINTS
for(SingleChange singleChange : possibilities)
@@ -242,15 +246,20 @@ public class GenericTreeNode {
ArrayList<SingleChange> oneChange = new ArrayList<SingleChange>();
String typeName = tableColumn.getTypeName();
-
+ System.out.println("TABLECOLUMN TYPE = "+typeName);
switch (typeName) {
+ case "smallint":
+ case "integer":
case "int2":
int tmp =
Integer.parseInt(rootMutation.getInitial_state_row().getContent().get(tableColumn.getName()));
oneChange.add(new SingleChange(tableColumn, this,
column_value, Integer.toString(tmp++)));
oneChange.add(new SingleChange(tableColumn, this,
column_value, Integer.toString(32767)));
oneChange.add(new SingleChange(tableColumn, this,
column_value, Integer.toString(1)));
break;
+
+ case "character":
+ case "character varying":
case "varchar":
if (rootMutation == null) {
char tmp2 = column_value.charAt(0);
@@ -271,9 +280,27 @@ public class GenericTreeNode {
if (column_value.equals("t"))
oneChange.add(new SingleChange(tableColumn, this,
column_value, "f"));
break;
- /* case 5: typeName = "May";
- break;
- case 6: typeName = "June";
+
+ case "timestamp":
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd
hh:mm:ss");
+ Calendar cal = Calendar.getInstance();
+
+ Date parsedDate = dateFormat.parse(column_value);
+ cal.setTime(parsedDate);
+ cal.add(Calendar.DAY_OF_WEEK,1);
+
+ Timestamp tsInc = new
java.sql.Timestamp(cal.getTime().getTime());
+ oneChange.add(new SingleChange(tableColumn, this,
column_value, tsInc.toString()));
+
+ parsedDate = new Date(Long.MIN_VALUE);
+ cal.setTime(parsedDate);
+
+ Timestamp tsDinausors = new
java.sql.Timestamp(cal.getTime().getTime());
+ oneChange.add(new SingleChange(tableColumn, this,
column_value, tsDinausors.toString()));
+
+ break;
+
+ /*case 6: typeName = "June";
break;
case 7: typeName = "July";
break;
@@ -288,7 +315,7 @@ public class GenericTreeNode {
case 12: typeName = "December";
break;*/
default:
- throw new Exception("No raw GenericTreeNode possibilities
could be found");
+ System.out.println("Unsupported dataType");
}
@@ -394,7 +421,7 @@ public class GenericTreeNode {
theQuery = theQuery + (" " +
initial_state_row.getParentTable().getPrimaryColumns().get(0).getName() + "=" +
initial_state_row.getValueOfColumn(initial_state_row.getParentTable().getPrimaryColumns().get(0).getName()));
- //System.out.println("build query ! "+theQuery); uncomment to see
built request;
+ System.out.println("build query ! "+theQuery); //uncomment to see
built request;
return theQuery;
}
@@ -528,9 +555,6 @@ public class GenericTreeNode {
}
}
- System.out.println(tmpThis);
- System.out.println(tmpTarget);
-
while (!tmpThis.compare(tmpTarget))
{
thisPath.add(tmpThis);
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [taler-schemafuzz] branch master updated: added more datatypes (not tested). Working on timestamps and general main loop structure.,
gnunet <=