Search in sources :

Example 86 with Configuration

use of org.apache.commons.configuration.Configuration in project wcomponents by BorderTech.

the class ResponseCacheInterceptor_Test method testOverrideDefaultNoCache.

@Test
public void testOverrideDefaultNoCache() {
    /**
     * Original config.
     */
    Configuration originalConfig;
    originalConfig = Config.getInstance();
    String override = "OVERRIDE NO CACHE";
    try {
        // Test override cache settings
        Configuration config = Config.copyConfiguration(originalConfig);
        config.setProperty(ConfigurationProperties.RESPONSE_NO_CACHE_SETTINGS, override);
        Config.setConfiguration(config);
        // Create interceptor
        ResponseCacheInterceptor interceptor = new ResponseCacheInterceptor(CacheType.CONTENT_NO_CACHE);
        interceptor.setBackingComponent(new WText());
        // Mock Response
        MockResponse response = new MockResponse();
        interceptor.attachResponse(response);
        // Render phase
        interceptor.paint(new WebXmlRenderContext(response.getWriter()));
        // Check Override
        Assert.assertEquals("Cache-Control header not overriden correctly for NO CACHE", override, response.getHeaders().get("Cache-Control"));
    } finally {
        // Remove overrides
        Config.setConfiguration(originalConfig);
    }
}
Also used : WebXmlRenderContext(com.github.bordertech.wcomponents.servlet.WebXmlRenderContext) MockResponse(com.github.bordertech.wcomponents.util.mock.MockResponse) Configuration(org.apache.commons.configuration.Configuration) WText(com.github.bordertech.wcomponents.WText) Test(org.junit.Test)

Example 87 with Configuration

use of org.apache.commons.configuration.Configuration in project wcomponents by BorderTech.

the class ResponseCacheInterceptor_Test method testOverrideContentCache.

@Test
public void testOverrideContentCache() {
    /**
     * Original config.
     */
    Configuration originalConfig;
    originalConfig = Config.getInstance();
    String override = "OVERRIDE CONTENT CACHE";
    try {
        // Test override cache settings
        Configuration config = Config.copyConfiguration(originalConfig);
        config.setProperty(ConfigurationProperties.RESPONSE_CACHE_SETTINGS, override);
        Config.setConfiguration(config);
        // Create interceptor
        ResponseCacheInterceptor interceptor = new ResponseCacheInterceptor(CacheType.CONTENT_CACHE);
        interceptor.setBackingComponent(new WText());
        // Mock Response
        MockResponse response = new MockResponse();
        interceptor.attachResponse(response);
        // Render phase
        interceptor.paint(new WebXmlRenderContext(response.getWriter()));
        // Check Override
        Assert.assertEquals("Cache-Control header not overriden correctly for CONTENT CACHE", override, response.getHeaders().get("Cache-Control"));
    } finally {
        // Remove overrides
        Config.setConfiguration(originalConfig);
    }
}
Also used : WebXmlRenderContext(com.github.bordertech.wcomponents.servlet.WebXmlRenderContext) MockResponse(com.github.bordertech.wcomponents.util.mock.MockResponse) Configuration(org.apache.commons.configuration.Configuration) WText(com.github.bordertech.wcomponents.WText) Test(org.junit.Test)

Example 88 with Configuration

use of org.apache.commons.configuration.Configuration in project wcomponents by BorderTech.

the class WApplicationRenderer_Test method testRendererTracking.

@Test
public void testRendererTracking() throws IOException, SAXException, XpathException {
    // No tracking
    WApplication application = new WApplication();
    assertSchemaMatch(application);
    assertXpathNotExists("//ui:application/ui:analytic", application);
    // Want to test with "tracking details set"
    Configuration originalConfig = Config.getInstance();
    Configuration config = Config.copyConfiguration(originalConfig);
    config.setProperty(ConfigurationProperties.TRACKING_CLIENT_ID, "CID");
    config.setProperty(ConfigurationProperties.TRACKING_APPLICATION_NAME, "APPL");
    config.setProperty(ConfigurationProperties.TRACKING_COOKIE_DOMAIN, "CD");
    config.setProperty(ConfigurationProperties.TRACKING_DATA_COLLECTION_DOMAIN, "DCD");
    Config.setConfiguration(config);
    try {
        assertSchemaMatch(application);
        assertXpathEvaluatesTo("CID", "//ui:application/ui:analytic/@clientId", application);
        assertXpathEvaluatesTo("APPL", "//ui:application/ui:analytic/@name", application);
        assertXpathEvaluatesTo("CD", "//ui:application/ui:analytic/@cd", application);
        assertXpathEvaluatesTo("DCD", "//ui:application/ui:analytic/@dcd", application);
    } finally {
        // Remove overrides
        Config.setConfiguration(originalConfig);
    }
}
Also used : Configuration(org.apache.commons.configuration.Configuration) WApplication(com.github.bordertech.wcomponents.WApplication) Test(org.junit.Test)

Example 89 with Configuration

use of org.apache.commons.configuration.Configuration in project janusgraph by JanusGraph.

the class JanusGraphFactory method open.

/**
 * Opens a {@link JanusGraph} database configured according to the provided configuration.
 * This method shouldn't be called by end users; it is used by internal server processes to
 * open graphs defined at server start that do not include the graphname property.
 *
 * @param configuration Configuration for the graph database
 * @param backupName Backup name for graph
 * @return JanusGraph graph database
 */
public static JanusGraph open(ReadConfiguration configuration, String backupName) {
    final ModifiableConfiguration config = new ModifiableConfiguration(ROOT_NS, (WriteConfiguration) configuration, BasicConfiguration.Restriction.NONE);
    final String graphName = config.has(GRAPH_NAME) ? config.get(GRAPH_NAME) : backupName;
    final JanusGraphManager jgm = JanusGraphManagerUtility.getInstance();
    if (null != graphName) {
        Preconditions.checkState(jgm != null, JANUS_GRAPH_MANAGER_EXPECTED_STATE_MSG);
        return (JanusGraph) jgm.openGraph(graphName, gName -> new StandardJanusGraph(new GraphDatabaseConfiguration(configuration)));
    } else {
        if (jgm != null) {
            log.warn("You should supply \"graph.graphname\" in your .properties file configuration if you are opening " + "a graph that has not already been opened at server start, i.e. it was " + "defined in your YAML file. This will ensure the graph is tracked by the JanusGraphManager, " + "which will enable autocommit and rollback functionality upon all gremlin script executions. " + "Note that JanusGraphFactory#open(String === shortcut notation) does not support consuming the property " + "\"graph.graphname\" so these graphs should be accessed dynamically by supplying a .properties file here " + "or by using the ConfiguredGraphFactory.");
        }
        return new StandardJanusGraph(new GraphDatabaseConfiguration(configuration));
    }
}
Also used : Configuration(org.apache.commons.configuration.Configuration) StringUtils(org.apache.commons.lang.StringUtils) java.util(java.util) StandardStoreManager(org.janusgraph.diskstorage.StandardStoreManager) Graph(org.apache.tinkerpop.gremlin.structure.Graph) LoggerFactory(org.slf4j.LoggerFactory) Backend(org.janusgraph.diskstorage.Backend) Iterators(com.google.common.collect.Iterators) StandardTransactionLogProcessor(org.janusgraph.graphdb.log.StandardTransactionLogProcessor) org.janusgraph.diskstorage.configuration(org.janusgraph.diskstorage.configuration) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) JANUS_GRAPH_MANAGER_EXPECTED_STATE_MSG(org.janusgraph.graphdb.management.JanusGraphManager.JANUS_GRAPH_MANAGER_EXPECTED_STATE_MSG) BaseConfiguration(org.apache.commons.configuration.BaseConfiguration) TransactionRecovery(org.janusgraph.core.log.TransactionRecovery) BackendException(org.janusgraph.diskstorage.BackendException) Logger(org.slf4j.Logger) LoggerUtil.sanitizeAndLaunder(org.janusgraph.util.system.LoggerUtil.sanitizeAndLaunder) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph) CommonsConfiguration(org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration) IOUtils(org.janusgraph.util.system.IOUtils) Instant(java.time.Instant) File(java.io.File) LogProcessorFramework(org.janusgraph.core.log.LogProcessorFramework) JanusGraphManager(org.janusgraph.graphdb.management.JanusGraphManager) GraphDatabaseConfiguration(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration) Preconditions(com.google.common.base.Preconditions) Pattern(java.util.regex.Pattern) StandardLogProcessorFramework(org.janusgraph.graphdb.log.StandardLogProcessorFramework) ConfigurationException(org.apache.commons.configuration.ConfigurationException) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph) JanusGraphManager(org.janusgraph.graphdb.management.JanusGraphManager) GraphDatabaseConfiguration(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph)

Example 90 with Configuration

use of org.apache.commons.configuration.Configuration in project opennms by OpenNMS.

the class DefaultRemedyConfigDao method getProperties.

/**
 * Retrieves the properties defined in the remedy.properties file.
 *
 * @param remedyTicketerPlugin
 * @return a
 *         <code>java.util.Properties object containing remedy plugin defined properties
 */
private Configuration getProperties() {
    if (m_config != null)
        return m_config;
    String propsFile = new String(System.getProperty("opennms.home") + "/etc/remedy.properties");
    LOG.debug("loading properties from: {}", propsFile);
    Configuration config = null;
    try {
        config = new PropertiesConfiguration(propsFile);
    } catch (final ConfigurationException e) {
        LOG.debug("Unable to load properties from {}", propsFile, e);
    }
    m_config = config;
    return config;
}
Also used : Configuration(org.apache.commons.configuration.Configuration) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) ConfigurationException(org.apache.commons.configuration.ConfigurationException) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration)

Aggregations

Configuration (org.apache.commons.configuration.Configuration)185 Test (org.junit.Test)51 PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)44 ZapXmlConfiguration (org.zaproxy.zap.utils.ZapXmlConfiguration)23 Test (org.testng.annotations.Test)22 File (java.io.File)14 AbstractConfiguration (org.apache.commons.configuration.AbstractConfiguration)13 MidpointConfiguration (com.evolveum.midpoint.common.configuration.api.MidpointConfiguration)11 Properties (java.util.Properties)10 HashMap (java.util.HashMap)9 AtlasException (org.apache.atlas.AtlasException)9 CompositeConfiguration (org.apache.commons.configuration.CompositeConfiguration)9 ArrayList (java.util.ArrayList)8 ZkUtils (kafka.utils.ZkUtils)8 ConfigurationException (org.apache.commons.configuration.ConfigurationException)8 IndexLoadingConfigMetadata (com.linkedin.pinot.common.metadata.segment.IndexLoadingConfigMetadata)7 AtlasClient (org.apache.atlas.AtlasClient)6 BeforeClass (org.testng.annotations.BeforeClass)6 MockResponse (com.github.bordertech.wcomponents.util.mock.MockResponse)5 IOException (java.io.IOException)5