Package org.apache.sirona.reporting.web.handler

Examples of org.apache.sirona.reporting.web.handler.TemplateHelper.renderPlain()


    @Test
    public void renderToXML() throws Exception {
        final StringWriter out = new StringWriter();
        final TemplateHelper helper = new TemplateHelper(new PrintWriter(out), Collections.<String, Object>emptyMap());
        final Template template = Format.Defaults.XML.render(Collections.<String, Object>emptyMap());
        helper.renderPlain(template.getTemplate(), template.getUserParams());

        assertEquals("<?xml version=\"1.0\"?> <repository> " +
            "<counter name=\"RendererTest\" role=\"failures\" unit=\"u\" Hits=\"1.0\" Max=\"1.0\" Mean=\"1.0\" Min=\"1.0\" " +
            "StandardDeviation=\"0.0\" Sum=\"1.0\" Variance=\"0.0\" Value=\"1.0\" Concurrency=\"0.0\" MaxConcurrency=\"1.0\" />" +
            " </repository>", inline(out));
View Full Code Here


    @Test
    public void renderToJSON() throws Exception {
        final StringWriter out = new StringWriter();
        final TemplateHelper helper = new TemplateHelper(new PrintWriter(out), Collections.<String, Object>emptyMap());
        final Template template = Format.Defaults.JSON.render(Collections.<String, Object>emptyMap());
        helper.renderPlain(template.getTemplate(), template.getUserParams());

        assertEquals("{\"counters\":[" +
            " {\"name\":\"RendererTest\", \"role\":\"failures\",\"unit\":\"u\",\"Hits\":\"1.0\",\"Max\":\"1.0\",\"Mean\":\"1.0\",\"Min\":\"1.0\"," +
            "\"StandardDeviation\":\"0.0\",\"Sum\":\"1.0\",\"Variance\":\"0.0\"," +
            "\"Value\":\"1.0\",\"Concurrency\":\"0.0\",\"MaxConcurrency\":\"1.0\"} ]}", inline(out));
View Full Code Here

    @Test
    public void renderToCSV() throws Exception {
        final StringWriter out = new StringWriter();
        final TemplateHelper helper = new TemplateHelper(new PrintWriter(out), Collections.<String, Object>emptyMap());
        final Template template = Format.Defaults.CSV.render(Collections.<String, Object>emptyMap());
        helper.renderPlain(template.getTemplate(), template.getUserParams());

        assertEquals(CSVFormat.HEADER +
            "RendererTest;failures (u);1.0;1.0;1.0;1.0;0.0;1.0;0.0;1.0;0.0;1.0\n",
            out.toString());
    }
View Full Code Here

                final TemplateHelper helper = new TemplateHelperExtractor(name).extract(request, response, matcher);
                if (template.isHtml()) {
                    response.setContentType(TEXT_HTML);
                    helper.renderHtml(template.getTemplate(), template.getUserParams());
                } else {
                    helper.renderPlain(template.getTemplate(), template.getUserParams());
                }
            } else if (result != null) {
                response.getWriter().write(result.toString());
            }
        } catch (final InvocationTargetException e) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.