Java Code Examples for org.apache.commons.configuration2.BaseHierarchicalConfiguration

The following examples show how to use org.apache.commons.configuration2.BaseHierarchicalConfiguration. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@BeforeEach
void setUp() throws Exception {
    EntityManagerFactory entityManagerFactory = JPA_TEST_CLUSTER.getEntityManagerFactory();
    JPAMailboxSessionMapperFactory mapperFactory = new JPAMailboxSessionMapperFactory(entityManagerFactory,
        new JPAUidProvider(entityManagerFactory),
        new JPAModSeqProvider(entityManagerFactory));

    usersRepository = new JPAUsersRepository(NO_DOMAIN_LIST);
    usersRepository.setEntityManagerFactory(JPA_TEST_CLUSTER.getEntityManagerFactory());
    BaseHierarchicalConfiguration configuration = new BaseHierarchicalConfiguration();
    configuration.addProperty("enableVirtualHosting", "false");
    usersRepository.configure(configuration);

    mailboxManager = JpaMailboxManagerProvider.provideMailboxManager(JPA_TEST_CLUSTER);
    sessionProvider = mailboxManager.getSessionProvider();
    currentQuotaManager = new JpaCurrentQuotaManager(entityManagerFactory);

    userQuotaRootResolver = new DefaultUserQuotaRootResolver(sessionProvider, mapperFactory);

    CurrentQuotaCalculator currentQuotaCalculator = new CurrentQuotaCalculator(mapperFactory, userQuotaRootResolver);

    testee = new RecomputeCurrentQuotasService(usersRepository, currentQuotaManager, currentQuotaCalculator, userQuotaRootResolver, sessionProvider);
}
 
Example 2
private static GuiceJamesServer createJamesServer(Host cassandraHost, TemporaryFolder folder, DNSService dnsService) throws Exception {
    Configuration configuration = Configuration.builder()
        .workingDirectory(folder.newFolder())
        .configurationFromClasspath()
        .build();

    return GuiceJamesServer.forConfiguration(configuration)
        .combineWith(CassandraJamesServerMain.CASSANDRA_SERVER_CORE_MODULE,
            new CassandraBlobStoreModule(),
            SmtpTestRule.SMTP_PROTOCOL_MODULE,
            binder -> binder.bind(MailQueueItemDecoratorFactory.class).to(RawMailQueueItemDecoratorFactory.class),
            binder -> binder.bind(CamelMailetContainerModule.DefaultProcessorsConfigurationSupplier.class)
                .toInstance(BaseHierarchicalConfiguration::new))
        .overrideWith(
            binder -> binder.bind(ClusterConfiguration.class).toInstance(
                DockerCassandra.configurationBuilder(cassandraHost)
                    .build()),
            binder -> binder.bind(KeyspacesConfiguration.class)
                .toInstance(KeyspacesConfiguration.builder()
                    .keyspace(DockerCassandra.KEYSPACE)
                    .cacheKeyspace(DockerCassandra.CACHE_KEYSPACE)
                    .replicationFactor(1)
                    .disableDurableWrites()
                    .build()),
            binder -> binder.bind(DNSService.class).toInstance(dnsService));
}
 
Example 3
/**
 * Creates a configuration object describing a configuration source.
 *
 * @param reload a flag whether reload operations are supported
 * @return the configuration object
 */
private HierarchicalConfiguration<?> setUpConfig(final boolean reload)
{
    final HierarchicalConfiguration<?> config = new BaseHierarchicalConfiguration();
    config.addProperty(CombinedConfigurationBuilder.ATTR_RELOAD,
            Boolean.valueOf(reload));
    config.addProperty("[@throwExceptionOnMissing]", Boolean.TRUE);
    config.addProperty("[@path]",
            ConfigurationAssert.getTestFile("test.properties")
                    .getAbsolutePath());
    config.addProperty("listDelimiterHandler[@config-class]",
            DefaultListDelimiterHandler.class.getName());
    config.addProperty(
            "listDelimiterHandler.config-constrarg[@config-value]", ";");
    return config;
}
 
Example 4
/**
 * Tests whether constructor arguments can be queried.
 */
@Test
public void testGetConstructorArgs()
{
    final BaseHierarchicalConfiguration config = prepareNestedBeanDeclarations();
    final XMLBeanDeclaration decl = new XMLBeanDeclaration(config, KEY);
    final Collection<ConstructorArg> args = decl.getConstructorArgs();
    assertEquals("Wrong number of constructor arguments", 2, args.size());
    final Iterator<ConstructorArg> it = args.iterator();
    final ConstructorArg arg1 = it.next();
    assertTrue("No bean declaration", arg1.isNestedBeanDeclaration());
    checkProperties(arg1.getBeanDeclaration(), CTOR_COMPLEX_ATTRIBUTES,
            CTOR_COMPLEX_VALUES);
    assertNull("Got a type", arg1.getTypeName());
    assertEquals("Wrong class name", "TestClass", arg1.getBeanDeclaration()
            .getBeanClassName());
    final ConstructorArg arg2 = it.next();
    assertFalse("A bean declaration", arg2.isNestedBeanDeclaration());
    assertEquals("Wrong value", CTOR_ID, arg2.getValue());
    assertEquals("Wrong type", "long", arg2.getTypeName());
}
 
Example 5
/**
 * Tests whether event source support of level builder is possible even for a
 * mock builder.
 */
@Test
public void testEventSourceSupportMockBuilder()
{
    final BaseHierarchicalConfiguration conf =
            new BaseHierarchicalConfiguration();
    final ConfigurationBuilder<BaseHierarchicalConfiguration> builder =
            createBuilderMock(conf);
    final EventListenerTestImpl listener = new EventListenerTestImpl(null);
    builder.addEventListener(ConfigurationEvent.ANY, listener);
    EasyMock.replay(builder);

    final BuilderConfigurationWrapperFactory factory =
            new BuilderConfigurationWrapperFactory(EventSourceSupport.BUILDER);
    final EventSource src =
            (EventSource) factory.createBuilderConfigurationWrapper(
                    HierarchicalConfiguration.class, builder);
    src.addEventListener(ConfigurationEvent.ANY, listener);
    EasyMock.verify(builder);
}
 
Example 6
/**
 * Tests if the base path is correctly evaluated.
 */
@Test
public void testBasePathForChildConfigurations()
        throws ConfigurationException
{
    final BaseHierarchicalConfiguration defConfig =
            new BaseHierarchicalConfiguration();
    defConfig.addProperty("properties[@fileName]", "test.properties");
    final File deepDir = new File(ConfigurationAssert.TEST_DIR, "config/deep");
    builder.configure(new CombinedBuilderParametersImpl().setBasePath(
            deepDir.getAbsolutePath()).setDefinitionBuilder(
            new ConstantConfigurationBuilder(defConfig)));
    final CombinedConfiguration config = builder.getConfiguration();
    assertEquals("Wrong property value", "somevalue",
            config.getString("somekey"));
}
 
Example 7
/**
 * Tests the factory if support for EventSource is disabled.
 */
@Test
public void testEventSourceSupportNone()
{
    final BaseHierarchicalConfiguration conf =
            new BaseHierarchicalConfiguration();
    final ConfigurationBuilder<BaseHierarchicalConfiguration> builder =
            createBuilderMock(conf);
    EasyMock.replay(builder);
    final BuilderConfigurationWrapperFactory factory =
            new BuilderConfigurationWrapperFactory();
    final HierarchicalConfiguration<?> wrapper =
            factory.createBuilderConfigurationWrapper(
                    HierarchicalConfiguration.class, builder);
    assertFalse("EventSource support", wrapper instanceof EventSource);
}
 
Example 8
@Test
void getProcessortConfigurationShouldReturnEmptyWhenNoContextSection() throws Exception {
    ConfigurationProvider configurationProvider = mock(ConfigurationProvider.class);
    when(configurationProvider.getConfiguration("mailetcontainer"))
        .thenReturn(new BaseHierarchicalConfiguration());
    XMLConfiguration defaultConfiguration = FileConfigurationProvider.getConfig(new ByteArrayInputStream((
            "<processors>" +
            "  <key>value</key>" +
            "</processors>")
        .getBytes(StandardCharsets.UTF_8)));

    MailetModuleInitializationOperation testee = new MailetModuleInitializationOperation(configurationProvider,
        mock(CamelCompositeProcessor.class),
        NO_TRANSPORT_CHECKS,
        () -> defaultConfiguration,
        mock(DefaultCamelContext.class));

    assertThat(testee.getProcessorConfiguration())
        .isEqualTo(defaultConfiguration);
}
 
Example 9
@Test
void fromShouldThrowWhenInvalidHookConfiguration() throws Exception {
    XMLConfiguration configuration = FileConfigurationProvider.getConfig(new ByteArrayInputStream((
        "<preDeletionHooks>" +
            "  <preDeletionHook>" +
            "    <class></class>" +
            "  </preDeletionHook>" +
            "</preDeletionHooks>")
        .getBytes(StandardCharsets.UTF_8)));

    HierarchicalConfiguration<ImmutableNode> invalidConfigurationEntry = new BaseHierarchicalConfiguration();
    configuration.addProperty(PreDeletionHooksConfiguration.CONFIGURATION_ENTRY_NAME, ImmutableList.of(invalidConfigurationEntry));

    assertThatThrownBy(() -> PreDeletionHooksConfiguration.from(configuration))
        .isInstanceOf(ConfigurationException.class);
}
 
Example 10
/**
 * Tests whether manipulations of a connected sub configuration trigger correct
 * events.
 */
@Test
public void testSubConfigurationChangedEventConnected()
{
    final HierarchicalConfiguration<ImmutableNode> sub =
            ((BaseHierarchicalConfiguration) config)
                    .configurationAt(EXIST_PROPERTY, true);
    sub.addProperty("newProp", "newValue");
    checkSubnodeEvent(
            listener.nextEvent(ConfigurationEvent.SUBNODE_CHANGED),
            true);
    checkSubnodeEvent(
            listener.nextEvent(ConfigurationEvent.SUBNODE_CHANGED),
            false);
    listener.done();
}
 
Example 11
/**
 * Tests whether the entity resolver is initialized with other XML-related
 * properties.
 */
@Test
public void testConfigureEntityResolverWithProperties()
        throws ConfigurationException
{
    final HierarchicalConfiguration<ImmutableNode> config = new BaseHierarchicalConfiguration();
    config.addProperty("header.entity-resolver[@config-class]",
            EntityResolverWithPropertiesTestImpl.class.getName());
    final XMLBuilderParametersImpl xmlParams = new XMLBuilderParametersImpl();
    final FileSystem fs = EasyMock.createMock(FileSystem.class);
    final String baseDir = ConfigurationAssert.OUT_DIR_NAME;
    xmlParams.setBasePath(baseDir);
    xmlParams.setFileSystem(fs);
    builder.configureEntityResolver(config, xmlParams);
    final EntityResolverWithPropertiesTestImpl resolver =
            (EntityResolverWithPropertiesTestImpl) xmlParams
                    .getEntityResolver();
    assertSame("File system not set", fs, resolver.getFileSystem());
    assertSame("Base directory not set", baseDir, resolver.getBaseDir());
}
 
Example 12
/**
 * Tests whether the factory method for creating nested bean declarations
 * gets called.
 */
@Test
public void testGetNestedBeanDeclarationsFactoryMethod()
{
    final BaseHierarchicalConfiguration config = prepareNestedBeanDeclarations();
    final XMLBeanDeclaration decl = new XMLBeanDeclaration(config, KEY)
    {
        @Override
        BeanDeclaration createBeanDeclaration(final NodeData<?> node)
        {
            return new XMLBeanDeclarationTestImpl(getConfiguration()
                    .configurationAt(node.nodeName()), node);
        }
    };
    final Map<String, Object> nested = decl.getNestedBeanDeclarations();
    for (final String element : COMPLEX_PROPS) {
        final Object d = nested.get(element);
        assertTrue("Wrong class for bean declaration: " + d,
                d instanceof XMLBeanDeclarationTestImpl);
    }
}
 
Example 13
/**
 * Tests whether the force-create attribute is taken into account.
 */
@Test
public void testLoadOptionalForceCreate() throws ConfigurationException
{
    final String name = "optionalConfig";
    final Map<String, Object> attrs = new HashMap<>();
    attrs.put("fileName", "nonExisting.xml");
    attrs.put("config-name", name);
    attrs.put("config-optional", Boolean.TRUE);
    attrs.put("config-forceCreate", Boolean.TRUE);
    final BaseHierarchicalConfiguration defConfig =
            createDefinitionConfig("xml", attrs);
    final BasicConfigurationBuilder<? extends BaseHierarchicalConfiguration> defBuilder =
            createDefinitionBuilder(defConfig);
    builder.configure(new CombinedBuilderParametersImpl()
            .setDefinitionBuilder(defBuilder));
    final CombinedConfiguration cc = builder.getConfiguration();
    assertEquals("Wrong number of configurations", 1,
            cc.getNumberOfConfigurations());
    assertTrue("Wrong configuration type",
            cc.getConfiguration(name) instanceof XMLConfiguration);
}
 
Example 14
/**
 * Tests whether the returned configuration correctly wraps the builder.
 */
@Test
public void testConfigurationBuilderWrapper()
{
    final BaseHierarchicalConfiguration conf =
            new BaseHierarchicalConfiguration();
    final ConfigurationBuilder<BaseHierarchicalConfiguration> builder =
            createBuilderMock(conf);
    EasyMock.replay(builder);
    conf.addProperty("test1", "value1");
    conf.addProperty("test2", "42");
    final BuilderConfigurationWrapperFactory factory =
            new BuilderConfigurationWrapperFactory();
    final HierarchicalConfiguration<?> wrapper =
            factory.createBuilderConfigurationWrapper(
                    HierarchicalConfiguration.class, builder);
    assertEquals("Wrong value (1)", "value1", wrapper.getString("test1"));
    assertEquals("Wrong value (2)", 42, wrapper.getInt("test2"));
    assertSame("Wrong root node", conf.getNodeModel().getNodeHandler()
            .getRootNode(), wrapper.getNodeModel().getNodeHandler()
            .getRootNode());
}
 
Example 15
Source Project: commons-configuration   Source File: TestUnionCombiner.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Tests combinations of elements with attributes.
 */
@Test
public void testSimpleValuesWithAttributes() throws ConfigurationException
{
    final BaseHierarchicalConfiguration config = createCombinedConfiguration();
    assertEquals("Too few level elements", 1, config
            .getMaxIndex("gui.level"));
    assertEquals("Wrong value of first element", 1, config
            .getInt("gui.level(0)"));
    assertEquals("Wrong value of second element", 4, config
            .getInt("gui.level(1)"));
    assertEquals("Wrong value of first attribute", 2, config
            .getInt("gui.level(0)[@default]"));
    assertFalse("Found wrong attribute", config
            .containsKey("gui.level(0)[@min]"));
    assertEquals("Wrong value of second attribute", 1, config
            .getInt("gui.level(1)[@min]"));
}
 
Example 16
Source Project: commons-configuration   Source File: TestUnionCombiner.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Tests combination of lists.
 */
@Test
public void testLists() throws ConfigurationException
{
    final BaseHierarchicalConfiguration config = createCombinedConfiguration();
    assertEquals("Too few list elements", 2, config
            .getMaxIndex("net.service.url"));
    assertEquals("Wrong first service", "http://service1.org", config
            .getString("net.service.url(0)"));
    assertEquals("Wrong second service", "http://service2.org", config
            .getString("net.service.url(1)"));
    assertEquals("Wrong service attribute", 2, config
            .getInt("net.service.url(2)[@type]"));
    assertEquals("Wrong number of server elements", 3, config
            .getMaxIndex("net.server.url"));
}
 
Example 17
/**
 * Helper method for checking the combined table structure.
 *
 * @param config the config
 * @return the node for the table element
 */
private ImmutableNode checkTable(final BaseHierarchicalConfiguration config)
{
    assertEquals("Wrong number of tables", 0, config
            .getMaxIndex("database.tables.table"));
    final HierarchicalConfiguration<ImmutableNode> c = config
            .configurationAt("database.tables.table");
    assertEquals("Wrong table name", "documents", c.getString("name"));
    assertEquals("Wrong number of fields", 2, c
            .getMaxIndex("fields.field.name"));
    assertEquals("Wrong field", "docname", c
            .getString("fields.field(1).name"));

    final NodeHandler<ImmutableNode> nodeHandler = config.getNodeModel().getNodeHandler();
    final List<QueryResult<ImmutableNode>> nds =
            config.getExpressionEngine().query(nodeHandler.getRootNode(),
                    "database.tables.table",
                    nodeHandler);
    assertFalse("No node found", nds.isEmpty());
    assertFalse("An attribute result", nds.get(0).isAttributeResult());
    return nds.get(0).getNode();
}
 
Example 18
/**
 * Tests if the base path is correctly evaluated.
 */
@Test
public void testSetConfigurationBasePath() throws ConfigurationException
{
    final File deepDir = new File(ConfigurationAssert.TEST_DIR, "config/deep");
    final Map<String, Object> params = new HashMap<>();
    params.put("fileName", "test.properties");
    final BaseHierarchicalConfiguration defConfig =
            createDefinitionConfig("properties", params);
    defConfig.addProperty("override.properties.fileSystem[@config-class]",
            VFSFileSystem.class.getName());
    final BasicConfigurationBuilder<? extends HierarchicalConfiguration<ImmutableNode>> defBuilder =
            createDefinitionBuilder(defConfig);
    builder.configure(new CombinedBuilderParametersImpl()
            .setDefinitionBuilder(defBuilder).setBasePath(
                    deepDir.getAbsolutePath()));
    final Configuration config = builder.getConfiguration();
    assertEquals("Wrong property value", "somevalue",
            config.getString("somekey"));
}
 
Example 19
Source Project: obevo   Source File: PackageMetadataReader.java    License: Apache License 2.0 5 votes vote down vote up
private ImmutableHierarchicalConfiguration getConfig(String configContent) {
    if (configContent == null) {
        return new BaseHierarchicalConfiguration();
    }

    Properties props = new Properties();
    try {
        props.load(new StringReader(configContent));
        return ConfigurationUtils.convertToHierarchical(ConfigurationConverter.getConfiguration(props));
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
Example 20
@Override
public ConfigurationBuilder<? extends Configuration> getConfigurationBuilder(
        final ConfigurationDeclaration decl) throws ConfigurationException
{
    final BaseHierarchicalConfiguration config =
            new BaseHierarchicalConfiguration();
    config.addProperty(getPropertyKey(), Boolean.TRUE);
    return new ConstantConfigurationBuilder(config);
}
 
Example 21
/**
 * Tests whether a constructor argument with a null value can be defined.
 */
@Test
public void testGetConstructorArgsNullArg()
{
    final BaseHierarchicalConfiguration config = new BaseHierarchicalConfiguration();
    setupBeanDeclaration(config, KEY, TEST_PROPS, TEST_VALUES);
    config.addProperty(KEY + ".config-constrarg", "");
    final XMLBeanDeclaration decl = new XMLBeanDeclaration(config, KEY);
    final Collection<ConstructorArg> args = decl.getConstructorArgs();
    assertEquals("Wrong number of constructor arguments", 1, args.size());
    final ConstructorArg arg = args.iterator().next();
    assertFalse("A bean declaration", arg.isNestedBeanDeclaration());
    assertNull("Got a value", arg.getValue());
}
 
Example 22
@Test
void emptyConfigurationShouldHaveDefaults() throws ConfigurationException {
    BaseHierarchicalConfiguration configuration = new BaseHierarchicalConfiguration();
    RecipientRewriteTableConfiguration recipientRewriteTableConfiguration = RecipientRewriteTableConfiguration.fromConfiguration(configuration);

    assertThat(recipientRewriteTableConfiguration.getMappingLimit())
        .isEqualTo(10);
    assertThat(recipientRewriteTableConfiguration.isRecursive())
        .isTrue();
}
 
Example 23
@Test
void goodConfigurationShouldPopulateTheConfiguration() throws ConfigurationException {
    BaseHierarchicalConfiguration configuration = new BaseHierarchicalConfiguration();
    configuration.addProperty("recursiveMapping", "true");
    configuration.addProperty("mappingLimit", 42);
    RecipientRewriteTableConfiguration recipientRewriteTableConfiguration = RecipientRewriteTableConfiguration.fromConfiguration(configuration);

    assertThat(recipientRewriteTableConfiguration.getMappingLimit())
        .isEqualTo(42);
    assertThat(recipientRewriteTableConfiguration.isRecursive())
        .isTrue();
}
 
Example 24
@Test
void goodConfigurationWithoutMappingShouldHaveANullMappingLevel() throws ConfigurationException {
    BaseHierarchicalConfiguration configuration = new BaseHierarchicalConfiguration();
    configuration.addProperty("recursiveMapping", "false");
    configuration.addProperty("mappingLimit", 42);
    RecipientRewriteTableConfiguration recipientRewriteTableConfiguration = RecipientRewriteTableConfiguration.fromConfiguration(configuration);

    assertThat(recipientRewriteTableConfiguration.getMappingLimit())
        .isEqualTo(0);
    assertThat(recipientRewriteTableConfiguration.isRecursive())
        .isFalse();
}
 
Example 25
/**
 * Tests whether interpolation is done on constructor arguments.
 */
@Test
public void testGetInterpolatedConstructorArgs()
{
    final BaseHierarchicalConfiguration config = new BaseHierarchicalConfiguration();
    final String expectedValue = "ctorArg";
    config.addProperty("value", expectedValue);
    setupBeanDeclaration(config, KEY, TEST_PROPS, TEST_VALUES);
    config.addProperty(KEY + ".config-constrarg[@config-value]", "${value}");
    final XMLBeanDeclaration decl = new XMLBeanDeclaration(config, KEY);
    final Collection<ConstructorArg> args = decl.getConstructorArgs();
    final ConstructorArg arg = args.iterator().next();
    assertEquals("Wrong interpolated value", expectedValue, arg.getValue());
}
 
Example 26
/**
 * Tries to create a wrapper without passing an interface class.
 */
@Test(expected = IllegalArgumentException.class)
public void testCreateBuilderConfigurationWrapperNoClass()
{
    final BuilderConfigurationWrapperFactory factory =
            new BuilderConfigurationWrapperFactory(
                    EventSourceSupport.BUILDER);
    factory.createBuilderConfigurationWrapper(null,
            createBuilderMock(new BaseHierarchicalConfiguration()));
}
 
Example 27
Source Project: james-project   Source File: JpaUsersRepositoryTest.java    License: Apache License 2.0 5 votes vote down vote up
private static JPAUsersRepository getUsersRepository(DomainList domainList, boolean enableVirtualHosting) throws Exception {
    JPAUsersRepository repos = new JPAUsersRepository(domainList);
    repos.setEntityManagerFactory(JPA_TEST_CLUSTER.getEntityManagerFactory());
    BaseHierarchicalConfiguration configuration = new BaseHierarchicalConfiguration();
    configuration.addProperty("enableVirtualHosting", String.valueOf(enableVirtualHosting));
    repos.configure(configuration);
    return repos;
}
 
Example 28
Source Project: james-project   Source File: MailRepositoriesRoutesTest.java    License: Apache License 2.0 5 votes vote down vote up
private void createMailRepositoryStore() throws Exception {
    MemoryMailRepositoryUrlStore urlStore = new MemoryMailRepositoryUrlStore();
    MailRepositoryStoreConfiguration configuration = MailRepositoryStoreConfiguration.forItems(
        new MailRepositoryStoreConfiguration.Item(
            ImmutableList.of(new Protocol("memory")),
            MemoryMailRepository.class.getName(),
            new BaseHierarchicalConfiguration()),
        new MailRepositoryStoreConfiguration.Item(
            ImmutableList.of(new Protocol("other")),
            MemoryMailRepository.class.getName(),
            new BaseHierarchicalConfiguration()));
    mailRepositoryStore = new MemoryMailRepositoryStore(urlStore, new SimpleMailRepositoryLoader(), configuration);

    mailRepositoryStore.init();
}
 
Example 29
Source Project: james-project   Source File: ReprocessingServiceTest.java    License: Apache License 2.0 5 votes vote down vote up
private MemoryMailRepositoryStore createMemoryMailRepositoryStore() throws Exception {
    MemoryMailRepositoryUrlStore urlStore = new MemoryMailRepositoryUrlStore();
    MailRepositoryStoreConfiguration configuration = MailRepositoryStoreConfiguration.forItems(
        new MailRepositoryStoreConfiguration.Item(
            ImmutableList.of(new Protocol("memory")),
            MemoryMailRepository.class.getName(),
            new BaseHierarchicalConfiguration()));

    MemoryMailRepositoryStore mailRepositoryStore = new MemoryMailRepositoryStore(urlStore, new SimpleMailRepositoryLoader(), configuration);
    mailRepositoryStore.init();
    return mailRepositoryStore;
}
 
Example 30
Source Project: james-project   Source File: IMAPServerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void getImapConfigurationShouldReturnDefaultValuesWhenEmpty() throws Exception {
    ImapConfiguration imapConfiguration = IMAPServer.getImapConfiguration(new BaseHierarchicalConfiguration());

    ImapConfiguration expectImapConfiguration = ImapConfiguration.builder()
            .enableIdle(ImapConfiguration.DEFAULT_ENABLE_IDLE)
            .idleTimeInterval(ImapConfiguration.DEFAULT_HEARTBEAT_INTERVAL_IN_SECONDS)
            .idleTimeIntervalUnit(ImapConfiguration.DEFAULT_HEARTBEAT_INTERVAL_UNIT)
            .disabledCaps(ImmutableSet.<String>of())
            .build();

    assertThat(imapConfiguration).isEqualTo(expectImapConfiguration);
}