package at.ecrit.eclipse.plugin.outputter.html.test;

import java.io.File;
import java.io.IOException;
import java.net.URL;

import org.eclipse.e4.ui.internal.workbench.E4XMIResourceFactory;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.junit.Test;

import at.ecrit.document.model.DocumentFactory;
import at.ecrit.document.model.ecritdocument.Document;
import at.ecrit.eclipse.plugin.outputter.html.HTMLOutputter;
import at.ecrit.eclipse.plugin.outputter.html.internal.HTMLOutputConverter;

public class OutputterTest {
	
	private static ResourceSet resourceSet = new ResourceSetImpl();
	
	@Test
	public void testProcessOutput() throws IOException{
		URL applicationModelUrl = OutputterTest.class.getResource("Application.e4xmi");
		
		resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
			.put("e4xmi", new E4XMIResourceFactory());
		
		Resource appModelResource =
			resourceSet.getResource(URI.createURI(applicationModelUrl.toString()), true);
		
		Document doc =
			DocumentFactory.createFromApplicationModel(appModelResource, new HTMLOutputConverter());
		File destFolder = new File(System.getProperty("user.dir") + "\\ecrit_doc");
		if (!destFolder.exists()) {
			destFolder.mkdir();
		}
		HTMLOutputter outputter = new HTMLOutputter();
		outputter.performOutput(doc, destFolder, appModelResource);
	}
	
}

@@ -677,17 +677,16 @@
 rTest %7B%0A
-%09
 %0A%09privat
@@ -743,17 +743,16 @@
 Impl();%0A
-%09
 %0A%09@Test%0A
@@ -802,16 +802,17 @@
 xception
+ 
 %7B%0A%09%09URL 
@@ -852,16 +852,21 @@
 st.class
+%0A%09%09%09%09
 .getReso
@@ -892,18 +892,16 @@
 4xmi%22);%0A
-%09%09
 %0A%09%09resou
@@ -966,16 +966,17 @@
 ap()%0A%09%09%09
+%09
 .put(%22e4
@@ -1010,18 +1010,16 @@
 ory());%0A
-%09%09
 %0A%09%09Resou
@@ -1040,20 +1040,17 @@
 source =
-%0A%09%09%09
+ 
 resource
@@ -1065,16 +1065,21 @@
 esource(
+%0A%09%09%09%09
 URI.crea
@@ -1124,18 +1124,16 @@
  true);%0A
-%09%09
 %0A%09%09Docum
@@ -1141,20 +1141,17 @@
 nt doc =
-%0A%09%09%09
+ 
 Document
@@ -1185,16 +1185,21 @@
 onModel(
+%0A%09%09%09%09
 appModel
@@ -1299,14 +1299,33 @@
 ir%22)
+%0A%09%09%09%09+ File.separator
  + %22
-%5C%5C
 ecri
@@ -1504,12 +1504,11 @@
 ce);%0A%09%7D%0A
-%09
 %0A%7D%0A

Fix outputter.html.test output location