Package org.exist

Examples of org.exist.TestDataGenerator


            transaction = transact.beginTransaction();
            System.out.println("Transaction started ...");

            System.out.println("Replacing resources ...");
            TestDataGenerator generator = new TestDataGenerator("xdb", COUNT);
            System.out.println("Generating " + COUNT + " files...");
            File[] files = generator.generate(broker, test, generateXQ);

            int j = 0;
            for (Iterator<DocumentImpl> i = test.iterator(broker); i.hasNext() && j < files.length; j++) {
                DocumentImpl doc = i.next();
                InputSource is = new InputSource(files[j].toURI().toASCIIString());
                assertNotNull(is);
                IndexInfo info = test.validateXMLResource(transaction, broker, doc.getURI(), is);
                assertNotNull(info);
                test.store(transaction, broker, info, is, false);
            }
            generator.releaseAll();
            transact.commit(transaction);
            System.out.println("Transaction committed ...");
      } catch (Exception e) {
            e.printStackTrace();
            fail(e.getMessage());
View Full Code Here


        test.store(transaction, broker, info, is, false);
        transact.commit(transaction);
        System.out.println("Transaction commited ...");

        transaction = transact.beginTransaction();
        TestDataGenerator generator = new TestDataGenerator("xdb", COUNT);
        System.out.println("Generating " + COUNT + " files...");
        File[] files = generator.generate(broker, test, generateXQ);
        for (int i = 0; i < files.length; i++) {
            File file = files[i];
            is = new InputSource(file.toURI().toASCIIString());
            assertNotNull(is);
            info = test.validateXMLResource(transaction, broker, XmldbURI.create(file.getName()), is);
            assertNotNull(info);
            test.store(transaction, broker, info, is, false);
        }
        generator.releaseAll();
        transact.commit(transaction);
        System.out.println("Transaction commited ...");
        return test;
    }
View Full Code Here

      try {
        broker = pool.get(pool.getSecurityManager().getSystemSubject());
        transact = pool.getTransactionManager();
        assertNotNull(transact);

        TestDataGenerator generator = new TestDataGenerator("xdb", docCount);
        Collection coll;
        int fileCount = 0;
        for (int i = 0; i < collectionCount; i++) {
                    transaction = transact.beginTransaction();
                    coll = broker.getOrCreateCollection(transaction,
              TestConstants.TEST_COLLECTION_URI.append(Integer
                  .toString(i)));
          assertNotNull(coll);
          broker.saveCollection(transaction, coll);
                    transact.commit(transaction);

                    transaction = transact.beginTransaction();
                    System.out.println("Generating " + docCount + " files...");
          File[] files = generator.generate(broker, coll, generateXQ);
          for (int j = 0; j < files.length; j++, fileCount++) {
            InputSource is = new InputSource(files[j].toURI()
                .toASCIIString());
            assertNotNull(is);
            IndexInfo info = coll.validateXMLResource(transaction,
                broker, XmldbURI.create("test" + fileCount
                    + ".xml"), is);
            assertNotNull(info);
            coll.store(transaction, broker, info, is, false);
                        transact.commit(transaction);
                    }
          generator.releaseAll();
        }
      } catch (Exception e) {
        transact.abort(transaction);
        e.printStackTrace();
//        fail(e.getMessage());
View Full Code Here

            hamlet.setContent(new File("samples/shakespeare/hamlet.xml"));
            collection.storeResource(hamlet);

            mgmt = (CollectionManagementService) collection.getService("CollectionManagementService", "1.0");
           
            TestDataGenerator generator = new TestDataGenerator("xdb", DOCUMENT_COUNT);
            for (int i = 0; i < COLLECTION_COUNT; i++) {
                Collection currentColl = mgmt.createCollection("test" + i);
                System.out.println("Generating " + DOCUMENT_COUNT + " files...");
                File[] files = generator.generate(currentColl, generateXQ);
                for (int j = 0; j < files.length; j++) {
                    XMLResource resource = (XMLResource) currentColl.createResource("xdb" + j + ".xml", "XMLResource");
                    resource.setContent(files[j]);
                    currentColl.storeResource(resource);
                }
View Full Code Here

        Resource resource = test.createResource("strings.xml", "XMLResource");
        resource.setContent(new File("samples/shakespeare/macbeth.xml"));
        test.storeResource(resource);
       
        TestDataGenerator generator = new TestDataGenerator("xdb", DOC_COUNT);
        File[] files = generator.generate(test, generateXQ);
        for (int i = 0; i < files.length; i++) {
            resource = test.createResource(files[i].getName(), "XMLResource");
            resource.setContent(files[i]);
            test.storeResource(resource);
        }
        generator.releaseAll();
    }
View Full Code Here

TOP

Related Classes of org.exist.TestDataGenerator

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.