FileDocCategorySizeDatePackage
TestVisioExtractor.javaAPI DocApache Poi 3.0.13620Wed Jun 27 19:45:44 BST 2007org.apache.poi.hdgf.extractor

TestVisioExtractor

public class TestVisioExtractor extends TestCase

Fields Summary
private String
filename
Constructors Summary
Methods Summary
protected voidsetUp()

		String dirname = System.getProperty("HDGF.testdata.path");
		filename = dirname + "/Test_Visio-Some_Random_Text.vsd";
	
public voidtestCreation()
Test the 3 different ways of creating one

		VisioTextExtractor extractor;
		
		extractor = new VisioTextExtractor(new FileInputStream(filename));
		assertNotNull(extractor);
		assertNotNull(extractor.getAllText());
		assertEquals(3, extractor.getAllText().length);
		
		extractor = new VisioTextExtractor(
				new POIFSFileSystem(
						new FileInputStream(filename)
				)
		);
		assertNotNull(extractor);
		assertNotNull(extractor.getAllText());
		assertEquals(3, extractor.getAllText().length);
		
		extractor = new VisioTextExtractor(
			new HDGFDiagram(
				new POIFSFileSystem(
						new FileInputStream(filename)
				)
			)
		);
		assertNotNull(extractor);
		assertNotNull(extractor.getAllText());
		assertEquals(3, extractor.getAllText().length);
	
public voidtestExtraction()

		VisioTextExtractor extractor =
			new VisioTextExtractor(new FileInputStream(filename));
		
		// Check the array fetch
		String[] text = extractor.getAllText();
		assertNotNull(text);
		assertEquals(3, text.length);
		
		assertEquals("Test View\n", text[0]);
		assertEquals("I am a test view\n", text[1]);
		assertEquals("Some random text, on a page\n", text[2]);
		
		// And the all-in fetch
		String textS = extractor.getText();
		assertEquals("Test View\nI am a test view\nSome random text, on a page\n", textS);
	
public voidtestMain()

		PrintStream oldOut = System.out;
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		PrintStream capture = new PrintStream(baos);
		System.setOut(capture);
		
		VisioTextExtractor.main(new String[] {filename});
		
		// Put things back
		System.setOut(oldOut);
		
		// Check
		capture.flush();
		String text = baos.toString();
		assertEquals("Test View\nI am a test view\nSome random text, on a page\n", text);