Package org.exist.xmldb

Examples of org.exist.xmldb.IndexQueryService


    /** test a trigger fired by storing a new Document  */
    @Test
    public void documentCreate() throws XMLDBException {
        // configure the Collection with the trigger under test
        final IndexQueryService idxConf = (IndexQueryService)
        testCollection.getService("IndexQueryService", "1.0");
        idxConf.configureCollection(COLLECTION_CONFIG);

        // this will fire the trigger
        final XMLResource doc = (XMLResource) testCollection.createResource(DOCUMENT_NAME, "XMLResource" );
        doc.setContent(DOCUMENT_CONTENT);
        testCollection.storeResource(doc);

        // remove the trigger for the Collection under test
        idxConf.configureCollection(EMPTY_COLLECTION_CONFIG);

        final XPathQueryService service = (XPathQueryService) testCollection.getService("XPathQueryService", "1.0");

        ResourceSet result = service.query(BEFORE+CREATE+DOCUMENT+documentURI);
        assertEquals(1, result.getSize());
View Full Code Here


    }

    /** test a trigger fired by a Document Update */
    @Test
    public void documentUpdate() throws XMLDBException {
        final IndexQueryService idxConf = (IndexQueryService)
            testCollection.getService("IndexQueryService", "1.0");
        idxConf.configureCollection(COLLECTION_CONFIG);

        final XMLResource doc = (XMLResource) testCollection.createResource(DOCUMENT_NAME, "XMLResource" );
        doc.setContent(DOCUMENT_CONTENT);
        testCollection.storeResource(doc);

        //TODO : trigger UPDATE events !
        final XUpdateQueryService update = (XUpdateQueryService) testCollection.getService("XUpdateQueryService", "1.0");
        update.updateResource(DOCUMENT_NAME, DOCUMENT_UPDATE);

        idxConf.configureCollection(EMPTY_COLLECTION_CONFIG);

        final XPathQueryService service = (XPathQueryService) testCollection
            .getService("XPathQueryService", "1.0");
        // this is necessary to compare with MODIFIED_DOCUMENT_CONTENT ; TODO better compare with XML diff tool
        service.setProperty(OutputKeys.INDENT, "no");
View Full Code Here

    }

    /** test a trigger fired by a Document Delete */
    @Test
    public void documentDelete() throws XMLDBException {
        final IndexQueryService idxConf = (IndexQueryService)
            testCollection.getService("IndexQueryService", "1.0");
        idxConf.configureCollection(COLLECTION_CONFIG);

        final XMLResource doc = (XMLResource) testCollection.createResource(DOCUMENT_NAME, "XMLResource" );
            doc.setContent(DOCUMENT_CONTENT);
        testCollection.storeResource(doc);

        testCollection.removeResource(testCollection.getResource(DOCUMENT_NAME));

        idxConf.configureCollection(EMPTY_COLLECTION_CONFIG);

        final XPathQueryService service = (XPathQueryService) testCollection
            .getService("XPathQueryService", "1.0");

        service.setProperty(OutputKeys.INDENT, "no");
View Full Code Here

   
  /** test a trigger fired by creating a new Binary Document  */
    @Test
    public void documentBinaryCreate() throws XMLDBException {
        // configure the Collection with the trigger under test
        final IndexQueryService idxConf = (IndexQueryService)
            testCollection.getService("IndexQueryService", "1.0");
        idxConf.configureCollection(COLLECTION_CONFIG);

        // this will fire the trigger
        final Resource res = testCollection.createResource(BINARY_DOCUMENT_NAME, "BinaryResource");
        Base64Decoder dec = new Base64Decoder();
        dec.translate(BINARY_DOCUMENT_CONTENT);
        res.setContent(dec.getByteArray());
        testCollection.storeResource(res);

        // remove the trigger for the Collection under test
        idxConf.configureCollection(EMPTY_COLLECTION_CONFIG);

        final XPathQueryService service = (XPathQueryService) testCollection.getService("XPathQueryService", "1.0");
        //TODO : understand why it is necessary !
        service.setProperty(OutputKeys.INDENT, "no");

View Full Code Here

    }

    /** test a trigger fired by a Binary Document Delete */
    @Test
    public void documentBinaryDelete() throws XMLDBException {
        final IndexQueryService idxConf = (IndexQueryService)
            testCollection.getService("IndexQueryService", "1.0");
        idxConf.configureCollection(COLLECTION_CONFIG);

        // this will fire the trigger
        final Resource res = testCollection.createResource(BINARY_DOCUMENT_NAME, "BinaryResource");
        final Base64Decoder dec = new Base64Decoder();
        dec.translate(BINARY_DOCUMENT_CONTENT);
        res.setContent(dec.getByteArray());
        testCollection.storeResource(res);

        testCollection.removeResource(testCollection.getResource(BINARY_DOCUMENT_NAME));

        idxConf.configureCollection(EMPTY_COLLECTION_CONFIG);

        final XPathQueryService service = (XPathQueryService) testCollection
            .getService("XPathQueryService", "1.0");

        service.setProperty(OutputKeys.INDENT, "no");
View Full Code Here

    }
   
    /** test a trigger fired by a Collection manipulations */
    @Test
    public void collectionCreate() throws XMLDBException {
        final IndexQueryService idxConf = (IndexQueryService) root.getService("IndexQueryService", "1.0");
        idxConf.configureCollection(COLLECTION_CONFIG);

        final CollectionManagementService service = (CollectionManagementService) testCollection.getService("CollectionManagementService", "1.0");
        final Collection collection = service.createCollection("test");
        assertNotNull(collection);

        // remove the trigger for the Collection under test
        idxConf.configureCollection(EMPTY_COLLECTION_CONFIG);

        final XPathQueryService query = (XPathQueryService) root.getService("XPathQueryService", "1.0");

        ResourceSet result = query.query(BEFORE+CREATE+COLLECTION+testCollectionURI);
        assertEquals(1, result.getSize());
View Full Code Here

    }

    /** test a trigger fired by a Collection manipulations */
    @Test @Ignore
    public void collectionCopy() throws XMLDBException, URISyntaxException {
        final IndexQueryService idxConf = (IndexQueryService) root.getService("IndexQueryService", "1.0");
        idxConf.configureCollection(COLLECTION_CONFIG);

        final XmldbURI srcURI = XmldbURI.xmldbUriFor("/db/testXQueryTrigger/test");
        final XmldbURI dstURI = XmldbURI.xmldbUriFor("/db/testXQueryTrigger/test-dst");

        final CollectionManagementServiceImpl service = (CollectionManagementServiceImpl) testCollection.getService("CollectionManagementService", "1.0");
        final Collection src = service.createCollection("test");
        assertNotNull(src);

        final Collection dst = service.createCollection("test-dst");
        assertNotNull(dst);

        service.copy(srcURI, dstURI, null);

        // remove the trigger for the Collection under test
        idxConf.configureCollection(EMPTY_COLLECTION_CONFIG);

        final XPathQueryService query = (XPathQueryService) root.getService("XPathQueryService", "1.0");

        ResourceSet result = query.query(BEFORE+CREATE+COLLECTION+testCollectionURI);
        assertEquals(1, result.getSize());
View Full Code Here

    }
   
    /** test a trigger fired by a Collection manipulations */
    @Test
    public void collectionMove() throws XMLDBException, URISyntaxException {
        final IndexQueryService idxConf = (IndexQueryService) root.getService("IndexQueryService", "1.0");
        idxConf.configureCollection(COLLECTION_CONFIG);

        XmldbURI srcURI = XmldbURI.xmldbUriFor("/db/testXQueryTrigger/test");
        XmldbURI dstURI = XmldbURI.xmldbUriFor("/db/testXQueryTrigger/test-dst");

        final CollectionManagementServiceImpl service = (CollectionManagementServiceImpl) testCollection.getService("CollectionManagementService", "1.0");
        final Collection src = service.createCollection("test");
        assertNotNull(src);

        final Collection dst = service.createCollection("test-dst");
        assertNotNull(dst);

        service.move(srcURI, dstURI, null);

        // remove the trigger for the Collection under test
        idxConf.configureCollection(EMPTY_COLLECTION_CONFIG);

        final XPathQueryService query = (XPathQueryService) root.getService("XPathQueryService", "1.0");

        ResourceSet result = query.query(BEFORE+CREATE+COLLECTION+testCollectionURI);
        assertEquals(1, result.getSize());
View Full Code Here

    }
   
    /** test a trigger fired by a Collection manipulations */
    @Test
    public void collectionDelete() throws XMLDBException {
        final IndexQueryService idxConf = (IndexQueryService) testCollection.getService("IndexQueryService", "1.0");
        idxConf.configureCollection(COLLECTION_CONFIG);

        final CollectionManagementService service = (CollectionManagementService) testCollection.getService("CollectionManagementService", "1.0");
        final Collection collection = service.createCollection("test");
        assertNotNull(collection);

        service.removeCollection("test");

        // remove the trigger for the Collection under test
        idxConf.configureCollection(EMPTY_COLLECTION_CONFIG);

        final XPathQueryService query = (XPathQueryService) root.getService("XPathQueryService", "1.0");

        ResourceSet result = query.query(BEFORE+CREATE+COLLECTION+testCollectionURI);
        assertEquals(1, result.getSize());
View Full Code Here

        ((EXistResource)invalidModule).setMimeType("application/xquery");
        invalidModule.setContent(INVALID_MODULE.getBytes());
        testCollection.storeResource(invalidModule);

        // configure the Collection with the trigger under test
        final IndexQueryService idxConf = (IndexQueryService)testCollection.getService("IndexQueryService", "1.0");
        idxConf.configureCollection(COLLECTION_CONFIG);
       
        final int max_store_attempts = 10;
        int count_prepare_exceptions = 0;
        for(int i = 0; i < max_store_attempts; i++) {
            try {
View Full Code Here

TOP

Related Classes of org.exist.xmldb.IndexQueryService

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.