Home > Archive > MySQL Java > April 2006 > Junit help









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Junit help
dijeshharidas@gmail.com

2006-04-07, 7:27 am

THis is a java code for getting the xml data from an XMl file...Please
help me to make a Junit test case to test this piece of code.

public static StringBuffer getXMLData(String fileName) throws
NBCException {
//Creating the string buffer to get the data from the xml
StringBuffer xmlDataStream = new StringBuffer();
try {
//Creating the FileReader object to read the contents of the
xml file
FileReader frForXML = new FileReader(fileName)
;
//char array to hold the data of the xml file
char xmlData[] = new char[1000];
//integer variable to hold the character data of the xml
file
int v = 0;
//Read till end of file
while ((v = frForXML.read(xmlData)) != -1) {
//putting the xml data into the string buffer
xmlDataStream.append(xmlData, 0, v);
}
//closing the FileReader object
frForXML.close();
}
catch (Exception expXMLNotFound) {
throw new NBCException("Could not find the xml file at the specified
location : " + fileName);
}
return xmlDataStream;
}

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com