You are on page 1of 62

SQA Assignment

Topic used: XML DBMS

By: Aditya Pancholi (02)


Barkha Sain (08)

Introduction (History Behind)


The project selected is XML-DBMS created by Aditya Pancholi, Shefali Sharma and Prerna Gupta as an assignment alloted by their DBMS instructor, Mrs V. Kulkarni in their 2nd semister. As XML-DBMS was a totally new area, never studied before, most of the time was spent on learning the concept and less time was devoted for implementation.

Requirement Specification (First Meeting)


Design a XML-DBMS I would like you to use of Xpath or Xquery It needs to be submitted by the end of the semester. I would like you to implement it in Java It is expected to have some basic minimum functionality.

Requirement Specification (Second Meeting)


It will be good if it provide basic features like create table, drop table, insert into table, delete from table, update table etc. Select is most important thing expected. Java provides features for XML processing, and I am more comfortable in Java (and not with C++) so I want you to make it in Java

Requirement Analysis and Feasibility Study


Time Constraint = Greatest Factor. Less Comfort level in Java as compared to Python and C++. Little or No knowledge about implementation of XML in Java. Tutorials available on internet. Help and guidance available from V.K. Mam.

Requirement Analysis and Feasibility Study (Contd.)


Xpath or Xquery ?? Xpath : Less features, Harder to Use but easier and more developed libraries in Java. Xquery : More features, Simpler to use than Xpath but less developed libraries in Java. Insert, Drop, Create can be implemented. Select can be implemented too. But Update and Delete cant be implemented due to technical reasons.

Requirement Analysis and Feasibility Study (Contd.)


Parsing cant be done. Input will be in form of Xpath and XML. As user is comfortable with both, so not a big issue.

Requirement Freezing
Deadline Accepted. Decided that Java will be used as programming language. Update and Delete not to be implemented. Xpath to be used for Selection Parser not to be implemented.

Designing
Objective

The aim is to simulate an XML Database Management System. An XML database is a data persistence software system that allows data to be stored in XML format.

Designing (contd.)

Designing (contd.)
Project Specifications Language Used : Java, Xpath Platform : Windows/ Linux Libraries (Main) : Java awt, Java swing, JAXP (Java API for XML Processing)

Interface : It will be a GUI. A window will be opened where there will be a space for writing queries and a space for output.

Designing (contd.)

Designing (contd.)
Assumptions Valid data-types are string and number

There are no constraints implemented in the program It is assumed that system memory is big enough that the whole DOM tree can fit into memory.

Designing (contd.)
Commands accepted are create, insert, drop and select. create, insert and drop are in form of xml while select is in form of xpath. It is assumed that the operator has some idea about XML and Xpath.

The limitations of Java libraries over implementation of Xpath and Dom holds true. These limitations and over complications can be seen well in the code. It is assumed that input are such that do not violate these limitations.

Designing (contd.)
Flow of Control

The user will get a GUI interface. When the user will input the query in the query box and then click on execute button. The query will go to the parser component which will check the syntax of the query and then converts the correct query into the XML query form. This goes to the Query analyzer which will check the syntax of the XML query. It sends the correct XML query to the query processor. This component first checks the semantics of the query and then processes the query using XPath on the DOM tree of the database and then returns the output. This output goes to the output area of the GUI window.

Designing (contd.)

Designing (contd.)
Storage structure The basic idea is to store one table in a XML file. In fact for every table, two files will be used. One file will be storing the meta data. That is information about attributes, like their name, data type, constraints etc. This itself will be in XML format.

The other file will store the data ( i.e tuples of the table). This data will be consistent with the information in the meta data. That is before making any entry into the data file, we need to check for its consistency with the meta data file.

Designing (contd.)
All the files are stored into one folder. This folder corresponds to the database. If we have to maintain multiple databases, we can extend the concept to having a one folder for each database, stored in a folder that corresponding to complete packing.

When ever we create a table using a create( ) command, both the files will be created. Meta data file will be filled with the information about the information provided along with the create ( ) command.

Designing (contd.)
Data Flow Diagrams

Designing (contd.)
Level-1 DFD

Designing (contd.)
Level-2 DFD

Risk Analysis (Before Coding)


Project may not complete on time severity : Very High likelihood : Low risk level : A possible causes : Java the devil. low skill of developers. measures : No time to waste. Study work needs to be be done in parallel.

Risk Analysis (Before Coding) (contd.)


Some unforeseen functionality issue caused by Java severity : High likelihood : High risk level : A possible causes : Java the devil. measures : some other method to be used to solve that. use of C or Python within java code

Risk Analysis (Before Coding) (contd.)


Proper modularity cannot be achieved severity : low likelihood : very low risk level : C possible causes : lack of time, so two modules clubbed together. measures : pipes will be used to connect modules, this will remove the issue

Coding

Risk Analysis (While Coding and After Coding)


Am I doing write thing ? Severity : Very High Likelihood : Very Low Risk level : B Possible causes : lack of requirements, wrong interpretation Measures : proper requirement specification and proper discussion with coder regarding requirements. Mitigation : Immediate Stop, Re-discuss the requirements and consider the design again and code again

Risk Analysis (While Coding and After Coding) (contd.)


Am I doing thing efficiently ? Severity : Low Likelihood : High Risk level : B Possible causes : Java the evil, lack of skill, lack of time Measures : maintaining quality from beginning and doing quality checks Mitigation : Re-discuss the efficiency issues and try to improve with minimum changes

Testing
Black Box Cause Effect Graph Equivalence Partitioning

White Box Branch and Path Coverage Date Flow Testing.

Black Box testing

Cause Effect Graph


GUI :

Query is placed in the Query text-box. When Execute button is pressed, input is passed to the program, where it is processed and result (or error) is displayed on Output box. Clear button is used for clearing the input text-box.

Cause Effect Graph (contd.)


Causes : C1 : Valid Query is written in Query text box. C2 : Execute button is pressed. C3 : Clear button is pressed. Effects : A1 : Output is displayed. A2 : Error is displayed. A3 : Query text box is cleared.

Cause Effect Graph (contd.)


Note Ci followed by Cj Cj followed by Ci

So in any sequence C1 or ~C1 is always considered to be first to happen. In case if C2 and C3 are both true, C2 is considered to be before C3

Cause Effect Graph (contd.)

Cause Effect Graph (contd.)


A1 = C1 & C2 A2 = ~C1 & C2
A3 = C3

Cause Effect Graph (contd.)


1
(T/T/T)

2
(T/T/F)

3
(T/F/T)

4
(T/F/F)

5
(F/T/T)

6
(F/T/F)

7
(F/F/T)

8
(F/F/F)

A1
A2 A3

T
T T T

Cause Effect Graph (contd.)


Test Cases:
Test Cases Input Query Valid Valid
Valid Valid

Execute Button
X X

Clear Button Expected Output X


X
Query Output + Input Box Cleared
Query Output Input Box Cleared No state Change

1 2 3 4 5 6 7 8

Invalid Invalid
Invalid Invalid


X X

X
X

Error Message Error Message


Input Box Cleared No state Change

Equivalence Partitioning
In order to select , the format is xpath <4-char keyword> <DB-name> <query>

4-char keyword can be NUBR or STRG or BOOL or NDST. query = xpath query
Output = valid output or an error.

Equivalence Partitioning (contd.)


Let us consider the input string as a set of input substrings Input substring1 : first label {xpath} Input substring2 : 4 char keyword Input substring3 : DB-name Input substring4 : Xpath Query Lets consider all set of possible inputs to these.

Equivalence Partitioning (contd.)


Possible Inputs for substring1 xpath any other string or number Null

Possible Inputs for substring2 NUBR STRG BOOL NDST Any other string or number Null

Equivalence Partitioning (contd.)


Possible Inputs for substring3 Valid database name (existing one) Invalid name (non-existing database) Null

Possible Inputs for substring4 Syntactically invalid query Syntactically valid query but semantically invalid query Syntactically and semantically valid query Null

Equivalence Partitioning (contd.)


We cant consider all input partitions as there will be 2 15 possible cases.

Possible Outputs Output as a Number Output as a String Output as a Boolean Value Output as a Node Set Error message We club cases together to get a smaller set of partitions.

Equivalence Partitioning (contd.)


Test cases (Input)

1) 2) 3)
4) 5) 6) 7) 8) 9)

Substring1 is not xpath. Rest of the substrings can take any value. Substring1 is xpath and substring3 is not a valid database name. Substring1 is xpath and substring3 is valid database name, substring2 is not one of the four valid keywords Substring1 is xpath and substring3 is valid database name, substring2 is one of the four valid keywords but substring4 is a query with invalid syntax. Substring1 is xpath and substring3 is valid database name, substring2 is one of the four valid keywords but substring4 is a query with valid syntax but invalid semantics. Everything is valid, Substring2 is NUBR Everything is valid, Substring2 is STRG Everything is valid, Substring2 is BOOL Everything is valid, Substring2 is NDST

Equivalence Partitioning (contd.)


Test cases (Output) 10) Output is a number 11) Output is a string 12) Output is a Boolean value 13) Output is a Node set 14) Output is error message

Equivalence Partitioning (contd.)


Test cases
Test case
Substring1 Substring2

1
xpathe NUBR

2
xpath NUBR

3
xpath NUB

4
xpath NUBR

5
xpath NUBR

Substring3
Substring4 Expected Output

Students
count(/row s/row) Error Message

Stud
count(/row s/row) Error Message

Students
count(/row s/row) Error Message

Students
_rows_row Error Message

Students
/rows/row Error Message

Equivalence Partitioning (contd.)


Test cases (contd.)
Test case Substring1 6 xpath 7 xpath 8 xpath 9 xpath

Substring2 Substring3
Substring4 Expected Output

NUBR Students
count(/rows/r ow) 8

STRG Students
/rows/row[1]/colu mn[@name=na me]/@value

BOOL Students
count(/rows/r ow) ==1 False

NDST Students
/rows/row[1] Whole first row

aditya

Equivalence Partitioning (contd.)


Test cases (contd.)
Test case Substring1 Substring2 Substring3 Substring4 10 xpath NUBR Students count(/row s/row) 8 11 xpath STRG Students
/rows/row[1]/colu mn[@name=na me]/@value

12 xpath BOOL Students

13 xpath STRG Students

14 xpathe NUBR Students /rows/row

count(/row /rows/row s/row) ==1 False all rows printed

Expected Output

aditya

Error Message

White Box testing

Branch and Path Coverage Testing


0public void pushInput (Object obj) 1{ 2 Document doc = xmlComponent.getDocumentFromString (obj.toString (), "query"); 3 if (doc != null) 4 { 5 String queryType = xmlComponent.getStringFromXPath (doc, "name (/query/child::*[1])"); 6 if (queryType.equals ("createTable")) 7 { 8 String tableName = createTable (doc); 9 sendOutput ("Table : '" + tableName + "' successfuly created..."); 10 } 11 else if (queryType.equals ("dropTable")) 12 { 13 String tableName = dropTable (doc); 14 sendOutput ("Table : '" + tableName + "' successfuly dropped..."); 15 } 16 else if (queryType.equals ("insert")) 17 { 18 String tableName = insertIntoTable (doc); 19 sendOutput ("Data successfuly inserted into table : '" + tableName + "'"); 20 } 21 else 22 { 23 sendOutput ("Not implemented yet..."); 24 } 25 } 26 else 27 { 28 sendErrorMessage ("Error in parsing Xml."); 29 } 30}

Branch and Path Coverage (contd.)

Branch and Path Coverage (contd.)


Test Cases 1) Obj passed is such that its Dom tree is null. Path covered = 0,1,2,3,4,26,27,28,29,30

Statement Coverage : 10/31 = 32.26% Branch Coverage : 01/08 = 12.25% Path coverage : 01/05 = 20.00%

Branch and Path Coverage (contd.)


Test Cases (contd.) 2) Obj passed is such that its Dom tree is not null and its first child is createTable. Path covered = 0,1,2,3,4,5,6,7,8,9,10,25,29,30

Statement Coverage : 14/31 = 45.16% Branch Coverage : 02/08 = 25.00% Path coverage : 01/05 = 20.00%

Branch and Path Coverage (contd.)


Test Cases (contd.) 3) Obj passed is such that its Dom tree is not null and its first child is dropTable. Path covered = 0,1,2,3,4,5,6,7,11,12,13,14,15,25,29,30 Statement Coverage : 16/31 = 51.61% Branch Coverage : 03/08 = 37.5% Path coverage : 01/05 = 20.00%

Flow Graph (contd.)


Test Cases (contd.) 4) Obj passed is such that its Dom tree is not null and its first child is insertIntoTable. Path covered = 0,1,2,3,4,5,6,7,11,12,16,17,18,19,20,25,29,30 Statement Coverage : 18/31 = 58.06% Branch Coverage : 04/08 = 50.00% Path coverage : 01/05 = 20.00%

Flow Graph (contd.)


Test Cases (contd.) 5) Obj passed is such that its Dom tree is not null and its first child is joinTable. Path covered = 0,1,2,3,4,5,6,7,11,12,16,17,21,22,23,24,25,29, 30 Statement Coverage : 19/31 = 61.29% Branch Coverage : 04/08 = 50.00% Path coverage : 01/05 = 20.00%

Branch and Path Coverage (contd.)


All the 5 test cases gives 100% statement coverage 100% branch coverage 100% path coverage

Data Flow Testing


0protected void 1parseAndSend (String str) 2{ 3if (str.equals ("") == false) 4{ 5if (str.indexOf ("xpath") == 0) 6{ 7String rest = str.substring (11); 8int nextSpace = rest.indexOf (" "); 9String tablename = rest.substring (0, nextSpace); 10String xpathExpression = rest.substring (nextSpace + 1); 11String tableData = configuration.getDataDirectory () + "/" + tablename + "/data.xml"; 12Document tableDoc = xmlComponent.getDocumentFromFile (tableData); 13String type = str.substring (6, 10); 14if (type.equals ("NUMR")) 15{ 16Double number = xmlComponent.getDoubleFromXPath (tableDoc, xpathExpression); 17flowController.pushOutput ("parserXPathResultOutputAOPipe", number); 18} 19else if (type.equals ("STRG")) 20{ 21String strVal = xmlComponent.getStringFromXPath (tableDoc, xpathExpression); 22flowController.pushOutput ("parserXPathResultOutputAOPipe", strVal); 23} 24else 25{ 26flowController.pushOutput ("parserErrorAOPipe", "Unknown XPath type : " + type); 27} 28} 29else 30{ 31flowController.pushOutput ("parserOutputAOPipe", str); 32} 33else 34{ 35flowController.pushOutput ("parserErrorAOPipe", "Empty strings not accepted !"); 36} 37}

Data Flow Testing (contd.)


Variables : str rest nextSpace tablename xpathExpression tableData tableDoc type number strVal

Data Flow Testing (contd.)


Variable str rest nextSpace tablename xpathExpression definition 1 7 8 9 10 P-use 3,5 C-use 7,13,31 8,9,10 9 11 16,21

tableData
tableDoc type

11
12 13 14,19

12
16,21 26

number
strVal

16
21

17
22

Data Flow Testing (contd.)


du-pairs

[1,3] &[1,5] : p-use of str [1,7], [1,13] &[1,31] : c-use of str [7,8], [7,9] & [7,10] : c-use of rest [8,9] : c-use of nextspace [9,11] : c-use of tablename [10,16] &[10,21] : c-use of xpathExpression [11,12] : c-use of tableData [12,16] &[12,21] : c-use of tableDoc [13,14] & [13,19] : p-use of type [13,26] : c-use of type [16,17] : c-use of number [21,22] : c-use of strVal

Data Flow Testing (contd.)


Test Cases (All p-use)
Test-case variable du-pair subpaths input (str) outputs (pushoutput)
"Empty strings not accepted !"

str

[1,3]

1,2,3

str

[1,5]

1,2,3,4,5

xpath NUBR students count(/rows/row) xpath NUBR students count(/rows/row) xpath STRG students /rows/row[1]/col umn[@name=n ame]/@value

type

[13,14]

13,14

type

[13,19]

13,14,15,19 or 13,14,15,16, 17,18,19

aditya

Data Flow Testing (contd.)


Test Cases (All c-use) There are many , we show only for 1 varaiable str.
Test-case variable du-pair subpaths input (str) outputs (pushoutput)

str

[1,7]

1,2,3,4,5,6,7

xpath NUBR students count(/rows/row) xpath NUBR students count(/rows/row)


<query><createT able tableName=Stu dents ..

str

[1,13]

1-13

str

[1,31]

1-6,29-31

You might also like