package com.javahonk;

import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;


public class ParseXMLGenerateReportTest {

	String xmlFilePath = "";
	String reportFilePath = "";
	
	@Before
	public void setUp() throws Exception {
		xmlFilePath = "src\\main\\resources\\vehicles.xml";
		reportFilePath = "VehicleReport.txt";		
	}

	@After
	public void tearDown() throws Exception {
		xmlFilePath = "";
		reportFilePath ="";
	}

	@Test
	public final void testGenerateReportFromXMLToFileAndConsole() {
		
		String actualMessage = ParseXMLGenerateReport.generateReportFromXMLToFileAndConsole(null, null);
		assertEquals("XML and Report file is null", actualMessage);		
		
		actualMessage = ParseXMLGenerateReport.generateReportFromXMLToFileAndConsole(xmlFilePath, null);
		assertEquals("Report file is null", actualMessage);
		
		actualMessage = ParseXMLGenerateReport.generateReportFromXMLToFileAndConsole(null, reportFilePath);
		assertEquals("XML file is null", actualMessage);
		
		actualMessage = ParseXMLGenerateReport.generateReportFromXMLToFileAndConsole("", "");
		assertEquals("XML and Report file is empty", actualMessage);
		
		actualMessage = ParseXMLGenerateReport.generateReportFromXMLToFileAndConsole(xmlFilePath, "");
		assertEquals("Report file is empty", actualMessage);
		
		actualMessage = ParseXMLGenerateReport.generateReportFromXMLToFileAndConsole("", reportFilePath);
		assertEquals("XML file is empty", actualMessage);
		
		xmlFilePath ="badFilePath";
		actualMessage = ParseXMLGenerateReport.generateReportFromXMLToFileAndConsole(xmlFilePath, reportFilePath);
		assertEquals(actualMessage.indexOf("org.xml.sax.SAXParseException")!=-1, actualMessage.indexOf("org.xml.sax.SAXParseException")!=-1);
		
	}

}
