src/java-tests/isac/util/genhtml/TestStyleSheets.java
author mlang
Wed, 06 Jul 2005 11:08:50 +0200
branchML_test
changeset 288 88d53ecfb298
child 2634 6b7352cee9c5
permissions -rw-r--r--
ML: implemented a testcase for generating a html-file out of ine xml-file
     1 /*
     2  * Created on Jun 30, 2005
     3  * 
     4  * TODO To change the template for this generated file go to Window -
     5  * Preferences - Java - Code Style - Code Templates
     6  */
     7 package isac.util.genhtml;
     8 
     9 import isac.util.InformationProcessor;
    10 
    11 import java.io.BufferedInputStream;
    12 import java.io.FileInputStream;
    13 import java.io.FileReader;
    14 import java.io.FileWriter;
    15 import java.io.IOException;
    16 import java.io.StringReader;
    17 
    18 import javax.xml.transform.Source;
    19 import javax.xml.transform.stream.StreamSource;
    20 
    21 import com.sun.corba.se.internal.javax.rmi.CORBA.Util;
    22 
    23 import junit.framework.TestCase;
    24 
    25 /**
    26  * @author ML
    27  * 
    28  * TODO To change the template for this generated type comment go to Window -
    29  * Preferences - Java - Code Style - Code Templates
    30  */
    31 public class TestStyleSheets extends TestCase {
    32 
    33     String test_destination_ = "/netshares/studenthomes/mlang/test_xml_file/";
    34 
    35     /**
    36      * @author ML creating one single html-file out of xml-file
    37      */
    38 
    39     public void testCreateHtml() {
    40         System.out
    41                 .println("---BEGIN isac.util.genhtml.start.TestStyleSheets#testCreateHtml");
    42         System.out.println("creating html_file");
    43 
    44         FileWriter out;
    45 
    46         Source xslSource = null;
    47         Source xmlSource = null;
    48 
    49         String header = "<?xml version=\"1.0\"?> \n"
    50                 + "<?xml-stylesheet href=\"http://pear.math.pitt.edu/mathzilla/Examples/mml.css\" type=\"text/css\"?>\n"
    51                 + "<!DOCTYPE html SYSTEM \"mathml.dtd_\">\n" +
    52                 //"<?xml-stylesheet type=\"text/xsl\"
    53                 // href=\"http://www.w3.org/Math/XSL/pmathml.xsl\"?>\n"+
    54                 //" <HTML xmlns=\"http://www.w3.org/1999/xhtml\">\n"+
    55                 "<HTML xmlns=\"http://www.w3.org/1999/xhtml\"\n"
    56                 + "xmlns:math=\"http://www.w3.org/1998/Math/MathML\"\n"
    57                 + "xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n" + "<BODY>";
    58 
    59         String footer = "</BODY>\n</HTML>";
    60 
    61         String destination = "/netshares/studenthomes/mlang/test_xml_file/test";
    62         String destination_xml = "/netshares/studenthomes/mlang/test_xml_file/exp/exp_IsacCore_Tests_1b.xml";
    63       
    64         
    65         try {
    66             out = new FileWriter(destination + ".html");
    67             
    68             FileInputStream xml_source = new FileInputStream(destination_xml);
    69             int lenght= xml_source.available();
    70             byte buffer[]= new byte[lenght];
    71             xml_source.read(buffer);
    72             String content_xml_file = new String(buffer);            
    73             
    74             xmlSource = new StreamSource(new StringReader(content_xml_file));
    75             xslSource = new StreamSource(getClass().getResourceAsStream(
    76             //"/netshares/studenthomes/mlang/test_xml_file/exp/exp_hcontent.xsl"));
    77                     "/isac/util/genhtml/templates/pbl_node_content.xsl"));          
    78             out.write(header);
    79             out.flush();
    80             Encoder.encodeInformation(xslSource, xmlSource, out);
    81             out.flush();
    82             out.write(footer);
    83             out.flush();
    84                        
    85             
    86         } catch (IOException e) {
    87             e.printStackTrace();
    88         }
    89 
    90         assertEquals("TODO", "TODO");
    91         System.out
    92                 .println("---END isac.util.genhtml.end.TestStyleSheet#testCreateHtml");
    93 
    94     }
    95     
    96 }
    97