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