Project

General

Profile

« Previous | Next » 

Revision 5113

Added by daigle over 14 years ago

add method to read test file from disk

View differences:

MCTestCase.java
27 27

  
28 28
import junit.framework.TestCase;
29 29

  
30
import java.io.BufferedReader;
30 31
import java.io.File;
32
import java.io.FileReader;
31 33
import java.io.IOException;
34
import java.io.InputStreamReader;
32 35
import java.io.Reader;
33 36
import java.io.StringReader;
34 37
import java.sql.PreparedStatement;
......
357 360
		// System.out.println("Returning following document" + testDocument);
358 361
		return testDocument;
359 362
	}
363
	
364
	/**
365
	 * 
366
	 */
367
	protected String getTestDocFromFile(String filePath) throws IOException{
368
		StringBuffer output = new StringBuffer();
369
		
370
		FileReader fileReader = new FileReader(new File(filePath));
371
		BufferedReader bufferedReader = new BufferedReader(fileReader);
372
		String readLine = null;
373
		
374
		while ((readLine = bufferedReader.readLine()) != null) {
375
			output.append(readLine);
376
		}
377
		
378
		return output.toString();
379
	}
360 380

  
361 381
	
362 382
    /**
......
524 544
				+ " expectKarmaException=" + expectKarmaException);
525 545
		String response = null;
526 546
		try {
527
			response = m.insert(docid, new StringReader(testdocument), null);
547
			response = m.insert(docid, new StringReader(docText), null);
528 548
			if (result) {
529 549
				assertTrue(response, (response.indexOf("<success>") != -1));
530 550
				assertTrue(response, response.indexOf(docid) != -1);
......
662 682
		debug("readDocumentIdWhichEqualsDoc() - docid=" + docid + " expectedResult=" + result
663 683
				+ " expectedKarmaFailure=" + expectedKarmaFailure);
664 684
		try {
665
			Reader r = m.read(docid);
685
			Reader r = new InputStreamReader(m.read(docid));
666 686
			String doc = IOUtil.getAsString(r, true);
667 687
			debug("readDocumentIdWhichEqualsDoc() -  doc=" + doc);
668 688
			

Also available in: Unified diff