[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-schemafuzz] branch master updated: fixed buggs.
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-schemafuzz] branch master updated: fixed buggs. |
Date: |
Tue, 19 Jun 2018 15:14:03 +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 1d5a1e6 fixed buggs.
1d5a1e6 is described below
commit 1d5a1e6f42792676d0b71ad624559155e40de4d2
Author: Feideus <address@hidden>
AuthorDate: Tue Jun 19 15:13:52 2018 +0200
fixed buggs.
---
src/main/java/org/schemaspy/DBFuzzer.java | 13 +++++--
.../org/schemaspy/model/FkGenericTreeNode.java | 2 +-
src/main/java/org/schemaspy/model/GenericTree.java | 3 +-
.../java/org/schemaspy/model/GenericTreeNode.java | 43 +++++++++++-----------
src/main/java/org/schemaspy/model/Row.java | 16 +++++---
5 files changed, 44 insertions(+), 33 deletions(-)
diff --git a/src/main/java/org/schemaspy/DBFuzzer.java
b/src/main/java/org/schemaspy/DBFuzzer.java
index f23d238..a7b0df6 100644
--- a/src/main/java/org/schemaspy/DBFuzzer.java
+++ b/src/main/java/org/schemaspy/DBFuzzer.java
@@ -113,6 +113,9 @@ public class DBFuzzer
currentMutation = chooseNextMutation();
}
+
if(currentMutation.getInitial_state_row().compare(currentMutation.getPost_change_row()))
+ System.out.println("ICI");
+
System.out.println("chosen mutation "+currentMutation);
System.out.println("parent mutation "+currentMutation.getParent());
@@ -138,6 +141,7 @@ public class DBFuzzer
{
LOGGER.info("GenericTreeNode was sucessfull");
mutationTree.addToTree(currentMutation);
+
currentMutation.discoverMutationPossibilities(analyzer.getSqlService());
}
else
LOGGER.info("QueryError. This update affected 0 rows");
@@ -319,20 +323,22 @@ public class DBFuzzer
if (mutationTree.getRoot() != null)
{
- if (markingDiff > 0) //
+ if (markingDiff > 0 ) //
{
+ System.out.println("creation1");
int randNumber =
rand.nextInt(previousMutation.getPotential_changes().size());
GenericTreeNode nextMut = new
GenericTreeNode(previousMutation.getPost_change_row(), nextId(),
mutationTree.getRoot(), previousMutation,false,analyzer.getSqlService());
nextMut.setChosenChange(previousMutation.getPotential_changes().get(randNumber));
nextMut.initPostChangeRow();
return nextMut;
}
- else if (markingDiff <= 0)
+ else
{
Random changeOrDepthen = new Random(); // 1 is same row
if(changeOrDepthen.nextInt(2) == 1)
{
+ System.out.println("creation2");
SingleChange tmp =
mutationTree.getRoot().singleChangeBasedOnWeight();
GenericTreeNode nextMut = new
GenericTreeNode(tmp.getAttachedToMutation().getPost_change_row(), nextId(),
mutationTree.getRoot(),
tmp.getAttachedToMutation(),false,analyzer.getSqlService());
nextMut.setChosenChange(tmp);
@@ -341,6 +347,7 @@ public class DBFuzzer
}
else
{
+ System.out.println("creation3");
Row nextRow;
GenericTreeNode nextMut;
do
@@ -355,8 +362,6 @@ public class DBFuzzer
return nextMut;
}
}
- else
- System.out.println("I mean What Da Heck");
}
throw new Error("No mutation returned. That should not happen");
}
diff --git a/src/main/java/org/schemaspy/model/FkGenericTreeNode.java
b/src/main/java/org/schemaspy/model/FkGenericTreeNode.java
index cdad44a..d29033e 100644
--- a/src/main/java/org/schemaspy/model/FkGenericTreeNode.java
+++ b/src/main/java/org/schemaspy/model/FkGenericTreeNode.java
@@ -24,7 +24,7 @@ public class FkGenericTreeNode {
public void initPostChangeRow()
{
- this.post_change_row = this.initial_state_row.clone();
+ this.post_change_row = this.initial_state_row.myClone();
this.post_change_row.setValueOfColumn(fkChange.getParentTableColumn().getName(),
fkChange.getNewValue());
}
diff --git a/src/main/java/org/schemaspy/model/GenericTree.java
b/src/main/java/org/schemaspy/model/GenericTree.java
index e89feb0..c6f488d 100644
--- a/src/main/java/org/schemaspy/model/GenericTree.java
+++ b/src/main/java/org/schemaspy/model/GenericTree.java
@@ -76,7 +76,8 @@ public class GenericTree {
return find(getLastId());
}
- public void addToTree(GenericTreeNode currentMutation) {
+ public void addToTree(GenericTreeNode currentMutation)
+ {
currentMutation.getParent().addChild(currentMutation);
}
diff --git a/src/main/java/org/schemaspy/model/GenericTreeNode.java
b/src/main/java/org/schemaspy/model/GenericTreeNode.java
index 14d2cec..ec25a57 100644
--- a/src/main/java/org/schemaspy/model/GenericTreeNode.java
+++ b/src/main/java/org/schemaspy/model/GenericTreeNode.java
@@ -37,7 +37,7 @@ public class GenericTreeNode {
this.id = id;
this.isFirstApperance = true;
this.initial_state_row = initial_state_row;
- this.potential_changes = discoverMutationPossibilities(this,
sqlService);
+ this.potential_changes = discoverMutationPossibilities(sqlService);
}
@@ -50,7 +50,7 @@ public class GenericTreeNode {
initDepth();
this.isFirstApperance = isFirstApperance;
this.initial_state_row = initial_state_row;
- this.potential_changes = discoverMutationPossibilities(rootMutation,
sqlService);
+ this.potential_changes = discoverMutationPossibilities(sqlService);
}
@@ -186,7 +186,11 @@ public class GenericTreeNode {
public void setChosenChange(SingleChange sc) {
this.chosenChange = sc;
+
this.chosenChange.getAttachedToMutation().getPotential_changes().remove(chosenChange);
+ this.getPotential_changes().add(sc);
this.chosenChange.setAttachedToMutation(this);
+
+ assert(sc.getAttachedToMutation().equals(this.getId()));
}
/**
@@ -199,12 +203,7 @@ public class GenericTreeNode {
this.parent = parent;
}
- public ArrayList<SingleChange>
discoverMutationPossibilities(GenericTreeNode rootMutation, SqlService
sqlService) {
-
- if (initial_state_row == null) {
- System.out.println("NO INITIAL STATE");
- return null;
- }
+ public ArrayList<SingleChange> discoverMutationPossibilities( SqlService
sqlService) {
ArrayList<SingleChange> possibilities = new ArrayList<SingleChange>();
@@ -212,7 +211,7 @@ public class GenericTreeNode {
for (Map.Entry<String, Object> content :
initial_state_row.getContent().entrySet()) {
try {
TableColumn parentColumn =
initial_state_row.getParentTable().findTableColumn(content.getKey());
- possibilities.addAll(discoverFieldPossibilities(parentColumn,
content.getValue(), rootMutation));
+ possibilities.addAll(discoverFieldPossibilities(parentColumn,
content.getValue()));
} catch (Exception e) {
e.printStackTrace();
}
@@ -224,7 +223,7 @@ public class GenericTreeNode {
return possibilities;
}
- public ArrayList<SingleChange> discoverFieldPossibilities(TableColumn
tableColumn, Object column_value, GenericTreeNode rootMutation) throws
Exception //listing of the mutation possibilities on the specified row
+ public ArrayList<SingleChange> discoverFieldPossibilities(TableColumn
tableColumn, Object column_value) throws Exception //listing of the mutation
possibilities on the specified row
{
ArrayList<SingleChange> oneChange = new ArrayList<SingleChange>();
@@ -331,7 +330,6 @@ public class GenericTreeNode {
default:
System.out.println("Unsupported dataType = " + typeName);
}
-
return oneChange;
}
@@ -358,8 +356,10 @@ public class GenericTreeNode {
}
public void initPostChangeRow() {
- this.post_change_row = this.initial_state_row.clone();
+ this.post_change_row = this.initial_state_row.myClone();
this.post_change_row.setValueOfColumn(chosenChange.getParentTableColumn().getName(),
chosenChange.getNewValue());
+
if(!post_change_row.getValueOfColumn(chosenChange.getParentTableColumn().getName()).equals(chosenChange.getNewValue()))
+ System.out.println("problem");
}
public int undo(SqlService sqlService, Database db) {
@@ -374,11 +374,6 @@ public class GenericTreeNode {
public String updateQueryBuilder(boolean undo, Database db, SqlService
sqlService) //undo variable tells if the function should build Inject string or
Undo string
{
-
if(db.getTablesMap().get(chosenChange.getParentTableColumn().getTable().getName())
== null)
- {
- System.out.println("unmatching tableColumn");
- }
-
String theQuery;
if (undo) {
@@ -561,6 +556,7 @@ public class GenericTreeNode {
tmpThis = tmpThis.getParent();
tmpTarget = tmpTarget.getParent();
}
+ thisPath.add(tmpThis); // tmpThis and tmpTarget are equals, so add the
commun ancestor
Collections.reverse(targetPath);
finalPath.add(thisPath); //way up
@@ -705,8 +701,7 @@ public class GenericTreeNode {
QueryResponse response = fetchingDataFromDatabase(semiQuery,
chosenChange.getParentTableColumn().getTable(), sqlService);
-
- setInitial_state_row(response.getRows().get(0)); // Crashes sometimes
due to 0 row found. to be fixed.
+ setInitial_state_row(response.getRows().get(0),sqlService); // Crashes
sometimes due to 0 row found. to be fixed.
semiQuery = "SELECT * FROM " +
chosenChange.getParentTableColumn().getTable().getName();
@@ -732,8 +727,10 @@ public class GenericTreeNode {
}
- public void setInitial_state_row(Row initial_state_row) {
+ public void setInitial_state_row(Row initial_state_row,SqlService
sqlService) {
this.initial_state_row = initial_state_row;
+ this.potential_changes = null;
+ this.potential_changes = discoverMutationPossibilities(sqlService);
initPostChangeRow();
}
@@ -758,13 +755,14 @@ public class GenericTreeNode {
else
semiQuery = semiQuery + " WHERE " +
sg.getParentTableColumn().getName() + "=" + sg.getNewValue();
- System.out.println("removing = " + semiQuery);
-
QueryResponse response = fetchingDataFromDatabase(semiQuery,
sg.getParentTableColumn().getTable(), sqlService);
SingleChange tmp = sg;
if (response.getNbRows() > 0)
+ {
+ System.out.println("removing "+sg);
toBeRemoved.add(tmp);
+ }
}
}
possibilities.removeAll(toBeRemoved);
@@ -810,4 +808,5 @@ public class GenericTreeNode {
return true;
return false;
}
+
}
diff --git a/src/main/java/org/schemaspy/model/Row.java
b/src/main/java/org/schemaspy/model/Row.java
index 991e4f7..b92c434 100644
--- a/src/main/java/org/schemaspy/model/Row.java
+++ b/src/main/java/org/schemaspy/model/Row.java
@@ -77,7 +77,9 @@ public class Row
public void setValueOfColumn(String columnName, Object newVal)
{
- this.getContent().replace(columnName, newVal);
+ this.getContent().put(columnName,newVal);
+ if(!this.getContent().get(columnName).equals(newVal))
+ System.out.println("problem");
}
public void setNbKeys(Integer nbKeys) {
@@ -114,11 +116,15 @@ public class Row
return true;
}
- public Row clone()
+ public Row myClone()
{
- HashMap<String,Object> clonedMap = (HashMap<String,Object>)
this.content.clone();
- Row res = new Row(this.parentTable,clonedMap,this.content.keySet().size());
+ HashMap<String,Object> clonedRow = new HashMap<String,Object>();
- return res;
+ for(Map.Entry<String,Object> entry: content.entrySet())
+ {
+ clonedRow.put(entry.getKey(),entry.getValue());
+ }
+
+ return new Row(parentTable,clonedRow,clonedRow.size());
}
}
--
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: fixed buggs.,
gnunet <=