Package org.carrot2.util.resource

Examples of org.carrot2.util.resource.IResource


    }

    @Test
    public void testResultsTruncation()
    {
        IResource xml = resourceLocator.getFirst("/xml/carrot2-apple-computer.xml");

        processingAttributes.put(AttributeUtils.getKey(XmlDocumentSource.class, "xml"),
            xml);
        processingAttributes.put(AttributeNames.RESULTS, 50);
        processingAttributes.put(AttributeUtils.getKey(XmlDocumentSource.class, "readAll"),
View Full Code Here


    }

    @Test
    public void testXsltNoParameters()
    {
        IResource xml = resourceLocator.getFirst("/xml/custom-parameters-not-required.xml");
        IResource xslt = resourceLocator.getFirst("/xsl/custom-xslt.xsl");

        processingAttributes.put(AttributeUtils.getKey(XmlDocumentSource.class, "xml"),
            xml);
        processingAttributes.put(AttributeUtils.getKey(XmlDocumentSource.class, "xslt"),
            xslt);
View Full Code Here

    }

    @Test
    public void testXsltWithParameters()
    {
        IResource xml = resourceLocator.getFirst("/xml/custom-parameters-required.xml");
        IResource xslt = resourceLocator.getFirst("/xsl/custom-xslt.xsl");

        Map<String, String> xsltParameters = Maps.newHashMap();
        xsltParameters.put("id-field", "number");
        xsltParameters.put("title-field", "heading");
        xsltParameters.put("snippet-field", "snippet");
View Full Code Here

    }

    @Test
    public void testNoIdsInSourceXml()
    {
        IResource xml = resourceLocator.getFirst("/xml/carrot2-no-ids.xml");

        processingAttributes.put(AttributeUtils.getKey(XmlDocumentSource.class, "xml"),
            xml);
        final int documentCount = runQuery();
        assertEquals(2, documentCount);
View Full Code Here

    }

    @Test
    public void testGappedIdsInSourceXml()
    {
        IResource xml = resourceLocator.getFirst("/xml/carrot2-gapped-ids.xml");
        processingAttributes.put(AttributeUtils.getKey(XmlDocumentSource.class, "xml"), xml);
        try {
            runQuery();
            fail();
        } catch (ProcessingException e) {
View Full Code Here

    }

    @Test
    public void testDuplicatedIdsInSourceXml()
    {
        IResource xml = resourceLocator.getFirst("/xml/carrot2-duplicated-ids.xml");
        processingAttributes.put(AttributeUtils.getKey(XmlDocumentSource.class, "xml"), xml);
        try {
            runQuery();
            fail();
        } catch (ProcessingException e) {
View Full Code Here

    }

    @Test
    public void testInitializationTimeXslt()
    {
        IResource xslt = resourceLocator.getFirst("/xsl/custom-xslt.xsl");
        initAttributes.put(AttributeUtils.getKey(XmlDocumentSource.class, "xslt"), xslt);

        IResource xml = resourceLocator.getFirst("/xml/custom-parameters-not-required.xml");
        processingAttributes.put(AttributeUtils.getKey(XmlDocumentSource.class, "xml"),
            xml);

        final int documentCount = runQueryInCachingController();
        assertTransformedDocumentsEqual(documentCount);
View Full Code Here

    }

    @Test
    public void testOverridingInitializationTimeXslt()
    {
        IResource initXslt = resourceLocator.getFirst("/xsl/carrot2-identity.xsl");
        initAttributes.put(AttributeUtils.getKey(XmlDocumentSource.class, "xslt"),
            initXslt);
       
        @SuppressWarnings("unchecked")
        Controller controller = getCachingController(initAttributes);

        // Run with identity XSLT
        {
            IResource xml = resourceLocator.getFirst("/xml/carrot2-test.xml");
            processingAttributes.put(AttributeUtils
                .getKey(XmlDocumentSource.class, "xml"), xml);

            final int documentCount = runQuery(controller);
            assertEquals(2, documentCount);
            assertEquals(Lists.newArrayList("Title 0", "Title 1"), Lists.transform(
                getDocuments(), DOCUMENT_TO_TITLE));
            assertEquals(Lists.newArrayList("Snippet 0", "Snippet 1"), Lists.transform(
                getDocuments(), DOCUMENT_TO_SUMMARY));
        }

        // Run with swapping XSLT
        {
            IResource xml = resourceLocator.getFirst("/xml/carrot2-test.xml");
            IResource xslt = resourceLocator.getFirst("/xsl/carrot2-title-snippet-switch.xsl");
            processingAttributes.put(AttributeUtils
                .getKey(XmlDocumentSource.class, "xml"), xml);
            processingAttributes.put(AttributeUtils.getKey(XmlDocumentSource.class,
                "xslt"), xslt);
View Full Code Here

    }

    @Test
    public void testDisablingInitializationTimeXslt()
    {
        IResource initXslt = resourceLocator.getFirst(
            "/xsl/carrot2-title-snippet-switch.xsl");
        initAttributes.put(AttributeUtils.getKey(XmlDocumentSource.class, "xslt"),
            initXslt);

        @SuppressWarnings("unchecked")
        Controller controller = getCachingController(initAttributes);
       
        // Run with swapping XSLT
        {
            IResource xml = resourceLocator.getFirst("/xml/carrot2-test.xml");
            processingAttributes.put(AttributeUtils
                .getKey(XmlDocumentSource.class, "xml"), xml);

            final int documentCount = runQuery(controller);
            assertEquals(2, documentCount);
            assertEquals(Lists.newArrayList("Snippet 0", "Snippet 1"), Lists.transform(
                getDocuments(), DOCUMENT_TO_TITLE));
            assertEquals(Lists.newArrayList("Title 0", "Title 1"), Lists.transform(
                getDocuments(), DOCUMENT_TO_SUMMARY));
        }

        // Run without XSLT
        {
            IResource xml = resourceLocator.getFirst("/xml/carrot2-test.xml");
            processingAttributes.put(AttributeUtils
                .getKey(XmlDocumentSource.class, "xml"), xml);
            processingAttributes.put(AttributeUtils.getKey(XmlDocumentSource.class,
                "xslt"), null);
View Full Code Here

    public void testRemoteUrl() throws MalformedURLException
    {
        String base = System.getProperty("carrot2.xml.feed.url.base");
        assumeTrue("carrot2.xml.feed.url.base property undefined.", !Strings.isNullOrEmpty(base));

        IResource xml = new URLResourceWithParams(new URL(base + "&q=${query}&results=${results}"));
        final String query = "apple computer";

        processingAttributes.put(AttributeUtils.getKey(XmlDocumentSource.class, "xml"),
            xml);
        processingAttributes.put(AttributeNames.QUERY, query);
View Full Code Here

TOP

Related Classes of org.carrot2.util.resource.IResource

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.