Search in sources :

Example 6 with Configuration

use of org.exist.util.Configuration in project exist by eXist-db.

the class DatabaseImpl method configure.

/**
 * In embedded mode: configure the database instance
 *
 * @throws XMLDBException Description of the Exception
 */
private void configure(final String instanceName) throws XMLDBException {
    try {
        final Configuration config = new Configuration(configuration, Optional.empty());
        if (dataDir != null) {
            config.setProperty(BrokerPool.PROPERTY_DATA_DIR, Paths.get(dataDir));
        }
        if (journalDir != null) {
            config.setProperty(Journal.PROPERTY_RECOVERY_JOURNAL_DIR, Paths.get(journalDir));
        }
        BrokerPool.configure(instanceName, 1, 5, config);
        if (shutdown != null) {
            BrokerPool.getInstance(instanceName).registerShutdownListener(shutdown);
        }
        currentInstanceName = instanceName;
    } catch (final Exception e) {
        throw new XMLDBException(ErrorCodes.VENDOR_ERROR, "configuration error: " + e.getMessage(), e);
    }
}
Also used : Configuration(org.exist.util.Configuration) XMLDBException(org.xmldb.api.base.XMLDBException) URISyntaxException(java.net.URISyntaxException) EXistException(org.exist.EXistException) XMLDBException(org.xmldb.api.base.XMLDBException) AuthenticationException(org.exist.security.AuthenticationException) MalformedURLException(java.net.MalformedURLException)

Example 7 with Configuration

use of org.exist.util.Configuration in project exist by eXist-db.

the class DatabaseInsertResources_NoValidation_Test method insertValidationResources_dtd.

@Test
public void insertValidationResources_dtd() throws IOException {
    final Configuration config = existEmbeddedServer.getBrokerPool().getConfiguration();
    config.setProperty(XMLReaderObjectFactory.PROPERTY_VALIDATION_MODE, "no");
    try (final InputStream is = SAMPLES.getSample("validation/dtd/hamlet.dtd")) {
        TestTools.insertDocumentToURL(is, "xmldb:exist://" + VALIDATION_HOME_COLLECTION_URI + "/" + TestTools.VALIDATION_DTD_COLLECTION + "/hamlet.dtd");
    }
    try (final InputStream is = SAMPLES.getSample("validation/dtd/catalog.xml")) {
        TestTools.insertDocumentToURL(is, "xmldb:exist://" + VALIDATION_HOME_COLLECTION_URI + "/" + TestTools.VALIDATION_DTD_COLLECTION + "/catalog.xml");
    }
    try (final InputStream is = SAMPLES.getSample("validation/dtd/hamlet_valid.xml")) {
        TestTools.insertDocumentToURL(is, "xmldb:exist://" + VALIDATION_HOME_COLLECTION_URI + "/hamlet_valid.xml");
    }
    try (final InputStream is = SAMPLES.getSample("validation/dtd/hamlet_invalid.xml")) {
        TestTools.insertDocumentToURL(is, "xmldb:exist://" + VALIDATION_HOME_COLLECTION_URI + "/hamlet_invalid.xml");
    }
}
Also used : Configuration(org.exist.util.Configuration) InputStream(java.io.InputStream) Test(org.junit.Test)

Example 8 with Configuration

use of org.exist.util.Configuration in project exist by eXist-db.

the class DatabaseInsertResources_NoValidation_Test method insertValidationResource_dtd_badDocType.

@Test
public void insertValidationResource_dtd_badDocType() throws IOException {
    final Configuration config = existEmbeddedServer.getBrokerPool().getConfiguration();
    config.setProperty(XMLReaderObjectFactory.PROPERTY_VALIDATION_MODE, "no");
    try (final InputStream is = SAMPLES.getSample("validation/dtd/hamlet_nodoctype.xml")) {
        TestTools.insertDocumentToURL(is, "xmldb:exist://" + VALIDATION_HOME_COLLECTION_URI + "/hamlet_nodoctype.xml");
    }
    try (final InputStream is = SAMPLES.getSample("validation/dtd/hamlet_wrongdoctype.xml")) {
        TestTools.insertDocumentToURL(is, "xmldb:exist://" + VALIDATION_HOME_COLLECTION_URI + "/hamlet_wrongdoctype.xml");
    }
}
Also used : Configuration(org.exist.util.Configuration) InputStream(java.io.InputStream) Test(org.junit.Test)

Example 9 with Configuration

use of org.exist.util.Configuration in project exist by eXist-db.

the class DatabaseInsertResources_NoValidation_Test method insertValidationResources_xsd.

/**
 * Insert all documents into database, switch of validation.
 */
@Test
public void insertValidationResources_xsd() throws IOException {
    final Configuration config = existEmbeddedServer.getBrokerPool().getConfiguration();
    config.setProperty(XMLReaderObjectFactory.PROPERTY_VALIDATION_MODE, "no");
    try (final InputStream is = SAMPLES.getSample("validation/addressbook/addressbook.xsd")) {
        TestTools.insertDocumentToURL(is, "xmldb:exist://" + VALIDATION_HOME_COLLECTION_URI + "/" + TestTools.VALIDATION_XSD_COLLECTION + "/addressbook.xsd");
    }
    try (final InputStream is = SAMPLES.getSample("validation/addressbook/catalog.xml")) {
        TestTools.insertDocumentToURL(is, "xmldb:exist://" + VALIDATION_HOME_COLLECTION_URI + "/" + TestTools.VALIDATION_XSD_COLLECTION + "/catalog.xml");
    }
    try (final InputStream is = SAMPLES.getSample("validation/addressbook/addressbook_valid.xml")) {
        TestTools.insertDocumentToURL(is, "xmldb:exist://" + VALIDATION_HOME_COLLECTION_URI + "/addressbook_valid.xml");
    }
    try (final InputStream is = SAMPLES.getSample("validation/addressbook/addressbook_invalid.xml")) {
        TestTools.insertDocumentToURL(is, "xmldb:exist://" + VALIDATION_HOME_COLLECTION_URI + "/addressbook_invalid.xml");
    }
}
Also used : Configuration(org.exist.util.Configuration) InputStream(java.io.InputStream) Test(org.junit.Test)

Example 10 with Configuration

use of org.exist.util.Configuration in project exist by eXist-db.

the class JavaFunctionsTest method setUp.

@Before
public void setUp() throws Exception {
    // Check the configuration file to see if Java binding is enabled
    // if it is not enabled then we expect an exception when trying to
    // perform Java binding.
    Configuration config = new Configuration();
    String javabinding = (String) config.getProperty(FunctionFactory.PROPERTY_ENABLE_JAVA_BINDING);
    if (javabinding != null) {
        if (javabinding.equals("yes")) {
            javabindingenabled = true;
        }
    }
}
Also used : Configuration(org.exist.util.Configuration) Before(org.junit.Before)

Aggregations

Configuration (org.exist.util.Configuration)30 Test (org.junit.Test)10 Path (java.nio.file.Path)9 EXistException (org.exist.EXistException)8 IOException (java.io.IOException)7 BrokerPool (org.exist.storage.BrokerPool)6 DatabaseConfigurationException (org.exist.util.DatabaseConfigurationException)6 InputStream (java.io.InputStream)4 Scheduler (org.exist.scheduler.Scheduler)4 DBBroker (org.exist.storage.DBBroker)4 Paths (java.nio.file.Paths)3 PermissionDeniedException (org.exist.security.PermissionDeniedException)3 Subject (org.exist.security.Subject)3 MalformedURLException (java.net.MalformedURLException)2 Map (java.util.Map)2 ServletException (javax.servlet.ServletException)2 Database (org.exist.Database)2 AuthenticationException (org.exist.security.AuthenticationException)2 SecurityManager (org.exist.security.SecurityManager)2 Ignore (org.junit.Ignore)2