Package org.restlet.ext.xml

Examples of org.restlet.ext.xml.TransformRepresentation


     *
     * @throws Exception
     */
    public void parallelTestTransform() throws Exception {
        final Component comp = new Component();
        final TransformRepresentation tr = new TransformRepresentation(comp.getContext(),
                this.source, this.xslt);
        final FailureTracker tracker = new FailureTracker();

        final int testVolume = 5000;
        final Thread[] parallelTransform = new Thread[testVolume];
        for (int i = 0; i < parallelTransform.length; i++) {
            final int index = i;
            parallelTransform[i] = new Thread() {

                @Override
                public void run() {
                    try {
                        final ByteArrayOutputStream out = new ByteArrayOutputStream();
                        tr.write(out);
                        final String result = out.toString();
                        assertEquals(TransformerTestCase.this.output, result);
                        out.close();

                    } catch (Throwable e) {
View Full Code Here


                "<?xml version=\"1.0\"?>"
                        + "<xsl:transform xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>"
                        + "<xsl:template match ='/'><newroot/></xsl:template></xsl:transform>",
                MediaType.TEXT_XML);

        TransformRepresentation transRep = new TransformRepresentation(comp
                .getContext(), xml, xslt);

        // create a test-stream representation to be returned when the correct
        // code is presented
        String testCode = "rnd." + (new Random()).nextInt();
        String testData = "\"The resolver is doing OK\", said the testclass "
                + MY_NAME + ".";
        Representation testRep = new StringRepresentation(testData);

        SimpleUriMapApplication testApp = new SimpleUriMapApplication();
        testApp.add(testCode, testRep);

        comp.getInternalRouter().attach("/testApp/", testApp);
        String testBase = "riap://component/testApp";

        URIResolver uriResolver = transRep.getUriResolver();
        assertNotNull("no resolver present!", uriResolver);
        String baseUri = testBase + "/dummy";

        AssertResolvingHelper test = new AssertResolvingHelper(baseUri,
                uriResolver);
View Full Code Here

        // xslOne
        Reference xsltOneRef = new LocalReference("clap://thread/"
                + MY_BASEPATH + "/xslt/one/1st.xsl");
        Representation xsltOne = comp.getContext().getClientDispatcher()
                .handle(new Request(Method.GET, xsltOneRef)).getEntity();
        TransformRepresentation tr = new TransformRepresentation(comp
                .getContext(), xmlIn, xsltOne);

        // TODO transformer output should go to SAX! The sax-event-stream should
        // then be fed into a DOMBuilder
        // and then the assertions should be written as DOM tests...
        // (NOTE: current string-compare assertion might fail on lexical aspects
        // as ignorable whitespace, encoding settings etc etc)
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        tr.write(out);
        String xmlOut = out.toString();

        String expectedResult = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><output><data1>1st</data1><data2>2nd</data2>"
                + thirdDocData + "</output>";
        assertEquals("xslt result doesn't match expectations", expectedResult,
View Full Code Here

            builder.append("</xsl:stylesheet>");
            final Representation transformSheet = new StringRepresentation(
                    builder.toString(), MediaType.TEXT_XML);

            // Instantiates the representation with both source and stylesheet.
            final Representation representation = new TransformRepresentation(
                    getContext(), source, transformSheet);
            // Set the right media-type
            representation.setMediaType(variant.getMediaType());

            return representation;

        }
View Full Code Here

        if (wadl2htmlXsltUrl != null) {
            try {
                InputRepresentation xslRep = new InputRepresentation(
                        wadl2htmlXsltUrl.openStream(),
                        MediaType.APPLICATION_W3C_XSLT);
                representation = new TransformRepresentation(Context
                        .getCurrent(), this, xslRep);
                representation.setMediaType(MediaType.TEXT_HTML);
            } catch (IOException e) {
                Context.getCurrent().getLogger().log(Level.WARNING,
                        "Unable to generate the WADL HTML representation", e);
View Full Code Here

TOP

Related Classes of org.restlet.ext.xml.TransformRepresentation

Copyright © 2018 www.massapicom. 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.