#!/bin/csh

# CSC 468
# Winter 2009
# Project Stage 2 Correctness test

# Create four repositories

java XpathPlus CREATE Food

java XpathPlus CREATE Movies

java XpathPlus CREATE Music

java XpathPlus CREATE Money


# Create a test repository for INSERT XML command

java XpathPlus CREATE Test01

# Create a test repository for DELETE command

java XpathPlus CREATE ToBeDeleted


# LIST

java XpathPlus LIST

# Populate repositories
# this assumes that the XML files are in the current directory

java XpathPlus INSERT FILE Food FoodRepository.xml

java XpathPlus INSERT FILE Money moneyrepository.xml

java XpathPlus INSERT FILE Music MusicRepository.xml

java XpathPlus INSERT FILE Movies MoviesRepository.xml


# Find out useful information about repositories

java XpathPlus LIST

java XpathPlus STATS Food

java XpathPlus STATS Money

java XpathPlus STATS Music

java XpathPlus STATS Movies

java XpathPlus STATS Test01

java XpathPlus STATS ToBeDeleted


# Check INSERT XML command

java XpathPlus INSERT XML Test01 <root><a>1</a><b>2</b></root>

# LIST command should reflect new content for Test01

java XpathPlus LIST

java XpathPlus STATS Test01

# CLEAR command

java XpathPlus CLEAR Test01

java XpathPlus LIST

java XpathPlus STATS Test01

# Repopulate

java XpathPlus INSERT XML Test01 <root><a>1</a><b>2</b><c>3</c></root>

java XpathPlus LIST

java XpathPlus STATS Test01

# DELETE command

#first populate 

java XpathPlus INSERT FILE ToBeDeleted FoodRepository.xml

java XpathPlus STATS ToBeDeleted

# Now, delete it

java XpathPlus DELETE ToBeDeleted

# Confirm deletion
LIST


#####
##
##  Error Checks
##
#####

#
#  Error #1: Create Repository: repository exists
#

java XpathPlus CREATE Food

# there should be some visible error message here

java XpathPlus LIST

#
# Error #2: CLEAR repository: repository does not exist
#

java XpathPlus CLEAR Boo

# should see some error message 

#
# Error #3: DELETE repository
#

java XpathPlus DELETE  Boo

# not an error really, but still notification needs to be posted


#
# Error #4: Insert FILE: No Repository
#

java XpathPlus INSERT FILE Boo Food.xml


#
# Error #5: Insert FILE: Repository Full
#


java XpathPlus INSERT FILE Food Money.xml



#
# Error #6: Insert FILE: File Not Found
#

# make certain file with the name below is NOT in the current directory

java XpathPlus CREATE Test02

java XpathPlus LIST

java XpathPlus INSERT FILE Test02  TEST_02.xml



#
# Error #7: Insert FILE: Not an XML file/ file not well-formed (parser error)
#

java XpathPlus INSERT FILE Test02  boo.txt




#
# Error #8: Insert XML: No Repository
#

java XpathPlus INSERT XML  boo  <a>1</a>





#
# Error #9: Insert XML: Repository Full
#

java XpathPlus INSERT XML  Food  <a>1</a>




#
# Error #8: Insert XML: Parse Error
#

java XpathPlus CREATE Test03

java XpathPlus LIST

java XpathPlus INSERT XML   Test03 <a>1</b>



#
# Error #9: STATS: No Repository
#

java XpathPlus STATS boo


#
# Finally, just list repositories and say good bye
#

java XpathPlus LIST


#
# AND WE ARE DONE!
#























