ML: implemented a testcase for generating a html-file out of ine xml-file ML_test
authormlang
Wed, 06 Jul 2005 11:08:50 +0200
branchML_test
changeset 28888d53ecfb298
parent 287 75e7d0720b23
child 289 6d7b07dc8e91
ML: implemented a testcase for generating a html-file out of ine xml-file
src/java-tests/isac/util/genhtml/TestStyleSheets.java
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/java-tests/isac/util/genhtml/TestStyleSheets.java	Wed Jul 06 11:08:50 2005 +0200
     1.3 @@ -0,0 +1,97 @@
     1.4 +/*
     1.5 + * Created on Jun 30, 2005
     1.6 + * 
     1.7 + * TODO To change the template for this generated file go to Window -
     1.8 + * Preferences - Java - Code Style - Code Templates
     1.9 + */
    1.10 +package isac.util.genhtml;
    1.11 +
    1.12 +import isac.util.InformationProcessor;
    1.13 +
    1.14 +import java.io.BufferedInputStream;
    1.15 +import java.io.FileInputStream;
    1.16 +import java.io.FileReader;
    1.17 +import java.io.FileWriter;
    1.18 +import java.io.IOException;
    1.19 +import java.io.StringReader;
    1.20 +
    1.21 +import javax.xml.transform.Source;
    1.22 +import javax.xml.transform.stream.StreamSource;
    1.23 +
    1.24 +import com.sun.corba.se.internal.javax.rmi.CORBA.Util;
    1.25 +
    1.26 +import junit.framework.TestCase;
    1.27 +
    1.28 +/**
    1.29 + * @author ML
    1.30 + * 
    1.31 + * TODO To change the template for this generated type comment go to Window -
    1.32 + * Preferences - Java - Code Style - Code Templates
    1.33 + */
    1.34 +public class TestStyleSheets extends TestCase {
    1.35 +
    1.36 +    String test_destination_ = "/netshares/studenthomes/mlang/test_xml_file/";
    1.37 +
    1.38 +    /**
    1.39 +     * @author ML creating one single html-file out of xml-file
    1.40 +     */
    1.41 +
    1.42 +    public void testCreateHtml() {
    1.43 +        System.out
    1.44 +                .println("---BEGIN isac.util.genhtml.start.TestStyleSheets#testCreateHtml");
    1.45 +        System.out.println("creating html_file");
    1.46 +
    1.47 +        FileWriter out;
    1.48 +
    1.49 +        Source xslSource = null;
    1.50 +        Source xmlSource = null;
    1.51 +
    1.52 +        String header = "<?xml version=\"1.0\"?> \n"
    1.53 +                + "<?xml-stylesheet href=\"http://pear.math.pitt.edu/mathzilla/Examples/mml.css\" type=\"text/css\"?>\n"
    1.54 +                + "<!DOCTYPE html SYSTEM \"mathml.dtd_\">\n" +
    1.55 +                //"<?xml-stylesheet type=\"text/xsl\"
    1.56 +                // href=\"http://www.w3.org/Math/XSL/pmathml.xsl\"?>\n"+
    1.57 +                //" <HTML xmlns=\"http://www.w3.org/1999/xhtml\">\n"+
    1.58 +                "<HTML xmlns=\"http://www.w3.org/1999/xhtml\"\n"
    1.59 +                + "xmlns:math=\"http://www.w3.org/1998/Math/MathML\"\n"
    1.60 +                + "xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n" + "<BODY>";
    1.61 +
    1.62 +        String footer = "</BODY>\n</HTML>";
    1.63 +
    1.64 +        String destination = "/netshares/studenthomes/mlang/test_xml_file/test";
    1.65 +        String destination_xml = "/netshares/studenthomes/mlang/test_xml_file/exp/exp_IsacCore_Tests_1b.xml";
    1.66 +      
    1.67 +        
    1.68 +        try {
    1.69 +            out = new FileWriter(destination + ".html");
    1.70 +            
    1.71 +            FileInputStream xml_source = new FileInputStream(destination_xml);
    1.72 +            int lenght= xml_source.available();
    1.73 +            byte buffer[]= new byte[lenght];
    1.74 +            xml_source.read(buffer);
    1.75 +            String content_xml_file = new String(buffer);            
    1.76 +            
    1.77 +            xmlSource = new StreamSource(new StringReader(content_xml_file));
    1.78 +            xslSource = new StreamSource(getClass().getResourceAsStream(
    1.79 +            //"/netshares/studenthomes/mlang/test_xml_file/exp/exp_hcontent.xsl"));
    1.80 +                    "/isac/util/genhtml/templates/pbl_node_content.xsl"));          
    1.81 +            out.write(header);
    1.82 +            out.flush();
    1.83 +            Encoder.encodeInformation(xslSource, xmlSource, out);
    1.84 +            out.flush();
    1.85 +            out.write(footer);
    1.86 +            out.flush();
    1.87 +                       
    1.88 +            
    1.89 +        } catch (IOException e) {
    1.90 +            e.printStackTrace();
    1.91 +        }
    1.92 +
    1.93 +        assertEquals("TODO", "TODO");
    1.94 +        System.out
    1.95 +                .println("---END isac.util.genhtml.end.TestStyleSheet#testCreateHtml");
    1.96 +
    1.97 +    }
    1.98 +    
    1.99 +}
   1.100 +