Clover Coverage Report
Coverage timestamp: Sat Sep 18 2010 04:09:52 UTC
18   86   6   4.5
4   39   0.33   4
4     1.5  
1    
 
  GenerateXmlTest       Line # 32 18 6 88.5% 0.88461536
 
  (1)
 
1    /* This file is part of the project "Hilbert II" - http://www.qedeq.org
2    *
3    * Copyright 2000-2010, Michael Meyling <mime@qedeq.org>.
4    *
5    * "Hilbert II" is free software; you can redistribute
6    * it and/or modify it under the terms of the GNU General Public
7    * License as published by the Free Software Foundation; either
8    * version 2 of the License, or (at your option) any later version.
9    *
10    * This program is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13    * GNU General Public License for more details.
14    */
15   
16    package org.qedeq.kernel.xml.dao;
17   
18    import java.io.File;
19    import java.io.IOException;
20   
21    import org.qedeq.base.io.IoUtility;
22    import org.qedeq.base.test.QedeqTestCase;
23    import org.qedeq.kernel.bo.test.DummyInternalKernalServices;
24    import org.qedeq.kernel.bo.test.KernelFacade;
25    import org.qedeq.kernel.common.SourceFileExceptionList;
26   
27    /**
28    * Test generating LaTeX files for all known samples.
29    *
30    * @author Michael Meyling
31    */
 
32    public final class GenerateXmlTest extends QedeqTestCase {
33   
 
34  1 toggle public void setUp() throws Exception {
35  1 super.setUp();
36  1 KernelFacade.startup();
37    }
38   
 
39  1 toggle public void tearDown() throws Exception {
40  1 KernelFacade.shutdown();
41  1 super.tearDown();
42    }
43   
44    /**
45    * Start main process.
46    *
47    * @throws Exception
48    */
 
49  1 toggle public void testGeneration() throws Exception {
50  1 File docDir = new File("../QedeqDoc");
51  1 File genDir = new File("../../../qedeq_gen");
52    // test if we are in the normal development environment, where a project with name
53    // "../QedeqDoc" exists, otherwise we assume to run within the build process
54  1 if (!docDir.exists()) {
55  1 docDir = new File(getIndir(), "doc");
56  1 genDir = new File(getOutdir(), "doc");
57  1 if (!docDir.exists()) {
58  0 throw new IOException("unknown source directory for QEDEQ modules");
59    }
60    }
61  1 generate(docDir, "math/qedeq_sample1.xml", genDir);
62   
63  1 generate(getIndir(), "qedeq_set_theory_compare.xml", genDir);
64  1 generate(getIndir(), "qedeq_basic_concept_compare.xml", genDir);
65    }
66   
67    /**
68    * Call the generation of one LaTeX file and copy XML source to same destination directory.
69    *
70    * @param dir Start directory.
71    * @param xml Relative path to XML file. Must not be <code>null</code>.
72    * @param destinationDirectory Directory path for LaTeX file. Must not be <code>null</code>.
73    * @throws IOException File IO failed.
74    * @throws XmlFilePositionExceptionList File data is invalid.
75    */
 
76  3 toggle private static void generate(final File dir, final String xml,
77    final File destinationDirectory) throws IOException, SourceFileExceptionList {
78  3 final File xmlFile = new File(dir, xml);
79  3 final File destination = new File(destinationDirectory, xml + "_").getAbsoluteFile();
80  3 Xml2Xml.generate(new DummyInternalKernalServices(), xmlFile, destination);
81    // assertEquals(IoUtility.loadFile(xmlFile.getAbsolutePath(), "ISO-8859-1"),
82    // IoUtility.loadFile(destination.getAbsolutePath(), "ISO-8859-1"));
83  3 assertEquals(true, IoUtility.compareTextFiles(xmlFile, destination, "ISO-8859-1"));
84    }
85   
86    }