EMMA Coverage Report (generated Fri Jul 28 01:51:09 CEST 2006)
[all classes][org.jtiger.report.html]

COVERAGE SUMMARY FOR SOURCE FILE [FixturesHtmlFileWriterFactory.java]

nameclass, %method, %block, %line, %
FixturesHtmlFileWriterFactory.java100% (2/2)100% (4/4)70%  (120/171)78%  (31/40)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class FixturesHtmlFileWriterFactory100% (1/1)100% (2/2)100% (7/7)100% (3/3)
FixturesHtmlFileWriterFactory (): void 100% (1/1)100% (3/3)100% (2/2)
newFixturesHtmlFileWriter (): FixturesHtmlFileWriter 100% (1/1)100% (4/4)100% (1/1)
     
class FixturesHtmlFileWriterFactory$FixturesHtmlFileWriterImpl100% (1/1)100% (2/2)69%  (113/164)76%  (28/37)
FixturesHtmlFileWriterFactory$FixturesHtmlFileWriterImpl (): void 100% (1/1)100% (3/3)100% (2/2)
writeFixturesHtml (ReadOnlyArray, File): void 100% (1/1)68%  (110/161)74%  (26/35)

1/*
2 * JTiger Unit Testing Framework for J2SE 1.5
3 * Copyright (C) 2005 Tony Morris
4 *
5 * This software is licenced under the
6 * Common Public Licence version 1.0
7 * http://www.opensource.org/licenses/cpl1.0.php
8 *
9 * You received a copy of this licence with this software.
10 */
11package org.jtiger.report.html;
12 
13import java.beans.XMLEncoder;
14import java.io.ByteArrayInputStream;
15import java.io.ByteArrayOutputStream;
16import java.io.File;
17import java.io.FileNotFoundException;
18import java.io.FileOutputStream;
19import java.io.IOException;
20import java.io.InputStream;
21import java.io.OutputStream;
22import javax.xml.transform.Transformer;
23import javax.xml.transform.TransformerConfigurationException;
24import javax.xml.transform.TransformerException;
25import javax.xml.transform.TransformerFactory;
26import javax.xml.transform.stream.StreamResult;
27import javax.xml.transform.stream.StreamSource;
28import org.jtiger.framework.FixtureResultsHandlerException;
29import org.jtiger.framework.ReadOnlyArray;
30import static org.jtiger.report.html.FixturesFilenamePolicyFactory.newFixturesFilenamePolicy;
31 
32final class FixturesHtmlFileWriterFactory
33{
34    private static final String XSL_RESOURCE = "/org/jtiger/report/xsl/fixtures.xsl";
35    private static final String FILENAME = "fixtures.html";
36 
37    private FixturesHtmlFileWriterFactory()
38    {
39 
40    }
41 
42    static FixturesHtmlFileWriter newFixturesHtmlFileWriter()
43    {
44        return new FixturesHtmlFileWriterImpl();
45    }
46 
47    private static final class FixturesHtmlFileWriterImpl implements FixturesHtmlFileWriter
48    {
49        FixturesHtmlFileWriterImpl()
50        {
51 
52        }
53 
54        public void writeFixturesHtml(final ReadOnlyArray<FixtureResults> results, final File destination) throws FixtureResultsHandlerException
55        {
56            final ByteArrayOutputStream out = new ByteArrayOutputStream();
57            final XMLEncoder encoder = new XMLEncoder(out);
58 
59            final FilenamePolicy policy = newFixturesFilenamePolicy();
60 
61            for(FixtureResults result : results)
62            {
63                final Object bean = new FixtureResultBeanImpl(result.getName(), policy.nextFilename());
64                encoder.writeObject(bean);
65            }
66 
67            encoder.close();
68 
69            InputStream in = null;
70 
71            try
72            {
73                in = getClass().getResourceAsStream(XSL_RESOURCE);
74                final Transformer t = TransformerFactory.newInstance().newTransformer(new StreamSource(in));
75                OutputStream o = null;
76 
77                try
78                {
79                    final File f = new File(destination, FILENAME);
80                    o = new FileOutputStream(f);
81                    final StreamResult r = new StreamResult(o);
82                    t.transform(new StreamSource(new ByteArrayInputStream(out.toByteArray())), r);
83                }
84                catch(FileNotFoundException e)
85                {
86                    throw new FixtureResultsHandlerException(e.getMessage(), e);
87                }
88                finally
89                {
90                    if(o != null)
91                    {
92                        try
93                        {
94                            o.close();
95                        }
96                        catch(IOException e)
97                        {
98                            throw new FixtureResultsHandlerException(e.getMessage(), e);
99                        }
100                    }
101                }
102            }
103            catch(TransformerConfigurationException e)
104            {
105                throw new FixtureResultsHandlerException(e.getMessage(), e);
106            }
107            catch(TransformerException e)
108            {
109                throw new FixtureResultsHandlerException(e.getMessage(), e);
110            }
111            finally
112            {
113                if(in != null)
114                {
115                    try
116                    {
117                        in.close();
118                    }
119                    catch(IOException e)
120                    {
121                        throw new FixtureResultsHandlerException(e.getMessage(), e);
122                    }
123                }
124            }
125        }
126    }
127}

[all classes][org.jtiger.report.html]
EMMA 2.0.5312 (C) Vladimir Roubtsov