org.apache.commons.configuration2.PropertiesConfiguration Java Examples
The following examples show how to use
org.apache.commons.configuration2.PropertiesConfiguration.
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
Source File: TestCombinedConfigurationBuilder.java From commons-configuration with Apache License 2.0 | 7 votes |
/** * Tests if the configuration was correctly created by the builder. * * @return the combined configuration obtained from the builder */ private CombinedConfiguration checkConfiguration() throws ConfigurationException { final CombinedConfiguration compositeConfiguration = builder.getConfiguration(); assertEquals("Number of configurations", 3, compositeConfiguration.getNumberOfConfigurations()); assertEquals(PropertiesConfiguration.class, compositeConfiguration .getConfiguration(0).getClass()); assertEquals(XMLPropertiesConfiguration.class, compositeConfiguration .getConfiguration(1).getClass()); assertEquals(XMLConfiguration.class, compositeConfiguration .getConfiguration(2).getClass()); // check the first configuration final PropertiesConfiguration pc = (PropertiesConfiguration) compositeConfiguration .getConfiguration(0); assertNotNull("No properties configuration", pc); // check some properties checkProperties(compositeConfiguration); return compositeConfiguration; }
Example #2
Source File: TestFileBasedConfigurationBuilder.java From commons-configuration with Apache License 2.0 | 6 votes |
/** * Tests whether auto save mode works with a properties configuration. * This is related to CONFIGURATION-646. */ @Test public void testAutoSaveWithPropertiesConfiguration() throws ConfigurationException, IOException { final File file = folder.newFile(); final FileBasedConfigurationBuilder<PropertiesConfiguration> builder = new FileBasedConfigurationBuilder<>( PropertiesConfiguration.class) .configure(new FileBasedBuilderParametersImpl() .setFile(file)); builder.setAutoSave(true); final PropertiesConfiguration config = builder.getConfiguration(); config.setProperty(PROP, 1); checkSavedConfig(file, 1); }
Example #3
Source File: TestFileBasedConfigurationBuilder.java From commons-configuration with Apache License 2.0 | 6 votes |
/** * Tests whether the location can be changed after a configuration has been * created. */ @Test public void testChangeLocationAfterCreation() throws ConfigurationException { final File file1 = createTestFile(1); final File file2 = createTestFile(2); final FileBasedConfigurationBuilder<PropertiesConfiguration> builder = new FileBasedConfigurationBuilder<>( PropertiesConfiguration.class) .configure(new FileBasedBuilderParametersImpl() .setFile(file1)); builder.getConfiguration(); builder.getFileHandler().setFile(file2); builder.resetResult(); final PropertiesConfiguration config = builder.getConfiguration(); assertEquals("Not read from file 2", 2, config.getInt(PROP)); }
Example #4
Source File: TestFileBasedConfigurationBuilder.java From commons-configuration with Apache License 2.0 | 6 votes |
/** * Tests whether HomeDirectoryLocationStrategy can be properly initialized * and that it shouldn't throw {@code ConfigurationException} when * everything is correctly in place. Without the code fix for * <a href="https://issues.apache.org/jira/browse/CONFIGURATION-634">CONFIGURATION-634</a>, * this test will throw {@code ConfigurationException} * @throws IOException Shouldn't happen * @throws ConfigurationException Shouldn't happen */ @Test public void testFileBasedConfigurationBuilderWithHomeDirectoryLocationStrategy() throws IOException, ConfigurationException { final String folderName = "test"; final String fileName = "sample.properties"; folder.newFolder(folderName); folder.newFile(folderName + File.separatorChar + fileName); final FileBasedConfigurationBuilder<FileBasedConfiguration> homeDirConfigurationBuilder = new FileBasedConfigurationBuilder<>( PropertiesConfiguration.class); final PropertiesBuilderParameters homeDirProperties = new Parameters().properties(); final HomeDirectoryLocationStrategy strategy = new HomeDirectoryLocationStrategy( folder.getRoot().getAbsolutePath(), true); final FileBasedConfigurationBuilder<FileBasedConfiguration> builder = homeDirConfigurationBuilder.configure(homeDirProperties .setLocationStrategy(strategy).setBasePath(folderName) .setListDelimiterHandler( new DefaultListDelimiterHandler(',')) .setFileName(fileName)); builder.getConfiguration(); }
Example #5
Source File: TestFileHandler.java From commons-configuration with Apache License 2.0 | 6 votes |
/** * Tests a successful locate() operation. */ @Test public void testLocateSuccess() throws ConfigurationException { final FileHandler handler = new FileHandler(); handler.setFileName(TEST_FILENAME); assertTrue("Wrong result", handler.locate()); final FileLocator locator = handler.getFileLocator(); assertNotNull("URL not filled", locator.getSourceURL()); assertNotNull("Base path not filled", locator.getBasePath()); assertEquals("Wrong file name", TEST_FILENAME, locator.getFileName()); // check whether the correct URL was obtained final PropertiesConfiguration config = new PropertiesConfiguration(); final FileHandler h2 = new FileHandler(config); h2.setURL(locator.getSourceURL()); h2.load(); assertTrue("Configuration not loaded", config.getBoolean("configuration.loaded")); }
Example #6
Source File: TestBasicConfigurationBuilderEvents.java From commons-configuration with Apache License 2.0 | 6 votes |
/** * Tests whether a configuration request event is generated. */ @Test public void testConfigurationRequestEvent() throws ConfigurationException { final BasicConfigurationBuilder<PropertiesConfiguration> builder = new BasicConfigurationBuilder<>( PropertiesConfiguration.class); builder.getConfiguration(); final BuilderEventListenerImpl listener = new BuilderEventListenerImpl(); builder.addEventListener(ConfigurationBuilderEvent.ANY, listener); builder.getConfiguration(); final ConfigurationBuilderEvent event = listener.nextEvent(ConfigurationBuilderEvent.CONFIGURATION_REQUEST); assertSame("Wrong builder", builder, event.getSource()); listener.assertNoMoreEvents(); }
Example #7
Source File: InjectorTest.java From elepy with Apache License 2.0 | 6 votes |
@Test void testPropertyInjection() { final var propertiesConfiguration = new PropertiesConfiguration(); propertiesConfiguration.addProperty("smtp.server", "ryan"); propertiesConfiguration.addProperty("test", true); defaultElepyContext.registerDependency(Configuration.class, propertiesConfiguration); final var props = sut.initializeAndInject(Props.class); assertThat(props.getSmtpServer()) .isEqualTo("ryan"); assertThat(props.isTestBoolean()) .isTrue(); assertThat(props.getWithDefault()) .isEqualTo("isAvailable"); }
Example #8
Source File: TestFileBasedConfigurationBuilder.java From commons-configuration with Apache License 2.0 | 6 votes |
/** * Tests that the location in the FileHandler remains the same if the * builder's result is reset. */ @Test public void testLocationSurvivesResetResult() throws ConfigurationException { final File file = createTestFile(1); final FileBasedConfigurationBuilder<PropertiesConfiguration> builder = new FileBasedConfigurationBuilder<>( PropertiesConfiguration.class) .configure(new FileBasedBuilderParametersImpl() .setFile(file)); final PropertiesConfiguration config = builder.getConfiguration(); builder.resetResult(); final PropertiesConfiguration config2 = builder.getConfiguration(); assertNotSame("Same configuration", config, config2); assertEquals("Not read from file", 1, config2.getInt(PROP)); }
Example #9
Source File: TestFileBasedConfigurationBuilder.java From commons-configuration with Apache License 2.0 | 6 votes |
/** * Tests whether a reset of the builder's initialization parameters also * resets the file location. */ @Test public void testResetLocation() throws ConfigurationException { final File file = createTestFile(1); final FileBasedConfigurationBuilder<PropertiesConfiguration> builder = new FileBasedConfigurationBuilder<>( PropertiesConfiguration.class) .configure(new FileBasedBuilderParametersImpl() .setFile(file)); builder.getConfiguration(); builder.reset(); final PropertiesConfiguration config = builder.getConfiguration(); assertTrue("Configuration was read from file", config.isEmpty()); assertFalse("FileHandler has location", builder.getFileHandler() .isLocationDefined()); }
Example #10
Source File: RabbitMQConfigurationTest.java From james-project with Apache License 2.0 | 6 votes |
@Test void fromShouldReturnTheConfigurationWhenRequiredParametersAreGiven() { PropertiesConfiguration configuration = new PropertiesConfiguration(); String amqpUri = "amqp://james:james@rabbitmq_host:5672"; configuration.addProperty("uri", amqpUri); String managementUri = "http://james:james@rabbitmq_host:15672/api/"; configuration.addProperty("management.uri", managementUri); configuration.addProperty("management.user", DEFAULT_USER); configuration.addProperty("management.password", DEFAULT_PASSWORD_STRING); assertThat(RabbitMQConfiguration.from(configuration)) .isEqualTo(RabbitMQConfiguration.builder() .amqpUri(URI.create(amqpUri)) .managementUri(URI.create(managementUri)) .managementCredentials(DEFAULT_MANAGEMENT_CREDENTIAL) .build()); }
Example #11
Source File: TestPropertiesBuilderParametersImpl.java From commons-configuration with Apache License 2.0 | 6 votes |
/** * Tests whether properties can be inherited. */ @Test public void testInheritFrom() { final PropertiesConfiguration.IOFactory factory = EasyMock.createMock(PropertiesConfiguration.IOFactory.class); final ConfigurationConsumer<ConfigurationException> includeListener = EasyMock.createMock(ConfigurationConsumer.class); params.setIOFactory(factory) .setIncludeListener(includeListener) .setIncludesAllowed(false) .setLayout(new PropertiesConfigurationLayout()) .setThrowExceptionOnMissing(true); final PropertiesBuilderParametersImpl params2 = new PropertiesBuilderParametersImpl(); params2.inheritFrom(params.getParameters()); final Map<String, Object> parameters = params2.getParameters(); assertEquals("Exception flag not set", Boolean.TRUE, parameters.get("throwExceptionOnMissing")); assertEquals("IncludeListener not set", includeListener, parameters.get("includeListener")); assertEquals("IOFactory not set", factory, parameters.get("IOFactory")); assertEquals("Include flag not set", Boolean.FALSE, parameters.get("includesAllowed")); assertNull("Layout was copied", parameters.get("layout")); }
Example #12
Source File: SwiftKeystone3ConfigurationReaderTest.java From james-project with Apache License 2.0 | 6 votes |
@Test void readProjectOfDomainNameScopedKeystone3Configuration() throws Exception { PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.read(new StringReader(StringUtils.joinWith("\n", CONFIG_ENDPOINT, CONFIG_CREDENTIALS, CONFIG_USER_NAME, CONFIG_USER_DOMAIN_NAME, CONFIG_SCOPE_PROJECT_NAME, CONFIG_SCOPE_PROJECT_DOMAIN_NAME, CONFIG_REGION))); assertThat(SwiftKeystone3ConfigurationReader.readSwiftConfiguration(configuration)) .isEqualTo( SwiftKeystone3ObjectStorage.configBuilder() .endpoint(URI.create(ENDPOINT)) .credentials(Credentials.of(CREDENTIALS)) .identity(IdentityV3.of( DomainName.of(USER_DOMAIN_NAME), UserName.of(USER_NAME))) .region(Optional.of(Region.of(REGION))) .project(Project.of( ProjectName.of(SCOPE_PROJECT_NAME), DomainName.of(SCOPE_PROJECT_DOMAIN_NAME))) .build() ); }
Example #13
Source File: TestBasicConfigurationBuilder.java From commons-configuration with Apache License 2.0 | 6 votes |
/** * Tests whether configuration listeners can be added. */ @Test public void testAddConfigurationListener() throws ConfigurationException { final EventListener<ConfigurationEvent> l1 = createEventListener(); final EventListener<ConfigurationEvent> l2 = createEventListener(); EasyMock.replay(l1, l2); final BasicConfigurationBuilder<PropertiesConfiguration> builder = new BasicConfigurationBuilder<>( PropertiesConfiguration.class); builder.addEventListener(ConfigurationEvent.ANY, l1); final PropertiesConfiguration config = builder.getConfiguration(); builder.addEventListener(ConfigurationEvent.ANY, l2); final Collection<EventListener<? super ConfigurationEvent>> listeners = config.getEventListeners(ConfigurationEvent.ANY); assertTrue("Listener 1 not registered", listeners.contains(l1)); assertTrue("Listener 2 not registered", listeners.contains(l2)); }
Example #14
Source File: SwiftTmpAuthConfigurationReaderTest.java From james-project with Apache License 2.0 | 6 votes |
@Test void readTempAuthConfigurationWithCustomTempAuthHeaders() throws Exception { PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.read(new StringReader(StringUtils.joinWith("\n", CONFIG_ENDPOINT, CONFIG_CREDENTIALS, CONFIG_USER_NAME, CONFIG_TENANT_NAME, CONFIG_USER_HEADER_NAME, CONFIG_PASS_HEADER_NAME))); assertThat(SwiftTmpAuthConfigurationReader.readSwiftConfiguration(configuration)) .isEqualTo( SwiftTempAuthObjectStorage.configBuilder() .endpoint(URI.create(ENDPOINT)) .credentials(Credentials.of(CREDENTIALS)) .tenantName(TenantName.of(TENANT_NAME)) .userName(UserName.of(USER_NAME)) .tempAuthHeaderUserName(UserHeaderName.of(USER_HEADER_NAME)) .tempAuthHeaderPassName(PassHeaderName.of(PASS_HEADER_NAME)) .build() ); }
Example #15
Source File: TestReloadingFileBasedConfigurationBuilder.java From commons-configuration with Apache License 2.0 | 6 votes |
/** * Tests whether a custom reloading detector factory can be installed. */ @Test public void testCreateReloadingDetectoryCustomFactory() throws ConfigurationException { final ReloadingDetector detector = EasyMock.createMock(ReloadingDetector.class); final ReloadingDetectorFactory factory = EasyMock.createMock(ReloadingDetectorFactory.class); final FileHandler handler = new FileHandler(); final FileBasedBuilderParametersImpl params = new FileBasedBuilderParametersImpl(); EasyMock.expect(factory.createReloadingDetector(handler, params)) .andReturn(detector); EasyMock.replay(detector, factory); params.setReloadingDetectorFactory(factory); final ReloadingFileBasedConfigurationBuilder<PropertiesConfiguration> builder = new ReloadingFileBasedConfigurationBuilder<>( PropertiesConfiguration.class); assertSame("Wrong detector", detector, builder.createReloadingDetector(handler, params)); EasyMock.verify(factory); }
Example #16
Source File: TestFileBasedConfigurationBuilder.java From commons-configuration with Apache License 2.0 | 6 votes |
/** * Tests whether it is possible to permanently change the location after a * reset of parameters. */ @Test public void testChangeLocationAfterReset() throws ConfigurationException { final File file1 = createTestFile(1); final File file2 = createTestFile(2); final FileBasedConfigurationBuilder<PropertiesConfiguration> builder = new FileBasedConfigurationBuilder<>( PropertiesConfiguration.class) .configure(new FileBasedBuilderParametersImpl() .setFile(file1)); builder.getConfiguration(); builder.getFileHandler().setFile(file2); builder.reset(); builder.configure(new FileBasedBuilderParametersImpl().setFile(file1)); PropertiesConfiguration config = builder.getConfiguration(); assertEquals("Not read from file 1", 1, config.getInt(PROP)); builder.getFileHandler().setFile(file2); builder.resetResult(); config = builder.getConfiguration(); assertEquals("Not read from file 2", 2, config.getInt(PROP)); }
Example #17
Source File: SwiftKeystone3ConfigurationReaderTest.java From james-project with Apache License 2.0 | 6 votes |
@Test void readProjectScopedKeystone3Configuration() throws Exception { PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.read(new StringReader(StringUtils.joinWith("\n", CONFIG_ENDPOINT, CONFIG_CREDENTIALS, CONFIG_USER_NAME, CONFIG_USER_DOMAIN_NAME, CONFIG_SCOPE_PROJECT_NAME, CONFIG_REGION))); assertThat(SwiftKeystone3ConfigurationReader.readSwiftConfiguration(configuration)) .isEqualTo( SwiftKeystone3ObjectStorage.configBuilder() .endpoint(URI.create(ENDPOINT)) .credentials(Credentials.of(CREDENTIALS)) .identity(IdentityV3.of(DomainName.of(USER_DOMAIN_NAME), UserName.of(USER_NAME))) .region(Optional.of(Region.of(REGION))) .project(Project.of(ProjectName.of(SCOPE_PROJECT_NAME))) .build() ); }
Example #18
Source File: TestReloadingBuilderSupportListener.java From commons-configuration with Apache License 2.0 | 6 votes |
/** * Tests that the controller's reloading state is reset when a new result * object is created. */ @SuppressWarnings("unchecked") @Test public void testResetReloadingStateOnResultCreation() throws ConfigurationException { final ReloadingController controller = EasyMock.createMock(ReloadingController.class); controller.addEventListener(EasyMock.eq(ReloadingEvent.ANY), EasyMock.anyObject(EventListener.class)); controller.resetReloadingState(); EasyMock.replay(controller); final BasicConfigurationBuilder<Configuration> builder = new BasicConfigurationBuilder<>( PropertiesConfiguration.class); final ReloadingBuilderSupportListener listener = ReloadingBuilderSupportListener.connect(builder, controller); assertNotNull("No listener returned", listener); builder.getConfiguration(); EasyMock.verify(controller); }
Example #19
Source File: ElasticSearchConfigurationTest.java From james-project with Apache License 2.0 | 6 votes |
@Test void getSSLConfigurationShouldReturnConfiguredValue() throws Exception { PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.addProperty("elasticsearch.hosts", "127.0.0.1"); String trustStorePath = "src/test/resources/auth-es/server.jks"; String trustStorePassword = "secret"; configuration.addProperty("elasticsearch.hostScheme.https.sslValidationStrategy", "override"); configuration.addProperty("elasticsearch.hostScheme.https.trustStorePath", trustStorePath); configuration.addProperty("elasticsearch.hostScheme.https.trustStorePassword", trustStorePassword); configuration.addProperty("elasticsearch.hostScheme.https.hostNameVerifier", "default"); assertThat(ElasticSearchConfiguration.fromProperties(configuration) .getSslConfiguration()) .isEqualTo(SSLConfiguration.builder() .strategyOverride(SSLTrustStore.of(trustStorePath, trustStorePassword)) .defaultHostNameVerifier() .build()); }
Example #20
Source File: TikaConfigurationReaderTest.java From james-project with Apache License 2.0 | 6 votes |
@Test public void readTikaConfigurationShouldReturnDefaultOnMissingPort() throws Exception { PropertiesConfiguration configuration = newConfiguration(); configuration.read(new StringReader( "tika.enabled=true\n" + "tika.host=172.0.0.5\n" + "tika.timeoutInMillis=500\n")); assertThat(TikaConfigurationReader.readTikaConfiguration(configuration)) .isEqualTo( TikaConfiguration.builder() .enabled() .host("172.0.0.5") .port(9998) .timeoutInMillis(500) .build()); }
Example #21
Source File: TikaConfigurationReaderTest.java From james-project with Apache License 2.0 | 6 votes |
@Test public void readTikaConfigurationShouldReturnDefaultOnMissingHost() throws Exception { PropertiesConfiguration configuration = newConfiguration(); configuration.read(new StringReader( "tika.enabled=true\n" + "tika.port=889\n" + "tika.timeoutInMillis=500\n")); assertThat(TikaConfigurationReader.readTikaConfiguration(configuration)) .isEqualTo( TikaConfiguration.builder() .enabled() .host("127.0.0.1") .port(889) .timeoutInMillis(500) .build()); }
Example #22
Source File: TestFileBasedConfigurationBuilder.java From commons-configuration with Apache License 2.0 | 5 votes |
/** * Tests whether a configuration can be created if no location is set. */ @Test public void testGetConfigurationNoLocation() throws ConfigurationException { final Map<String, Object> params = new HashMap<>(); params.put("throwExceptionOnMissing", Boolean.TRUE); final FileBasedConfigurationBuilder<PropertiesConfiguration> builder = new FileBasedConfigurationBuilder<>( PropertiesConfiguration.class, params); final PropertiesConfiguration conf = builder.getConfiguration(); assertTrue("Property not set", conf.isThrowExceptionOnMissing()); assertTrue("Not empty", conf.isEmpty()); }
Example #23
Source File: TestParameters.java From commons-configuration with Apache License 2.0 | 5 votes |
/** * Tests whether a parameters object for a properties configuration can be * created. */ @Test public void testProperties() { final PropertiesConfiguration.IOFactory factory = EasyMock.createMock(PropertiesConfiguration.IOFactory.class); final ConfigurationConsumer<ConfigurationException> includeListener = EasyMock.createMock(ConfigurationConsumer.class); // @formatter:off final Map<String, Object> map = new Parameters().properties() .setThrowExceptionOnMissing(true) .setFileName("test.properties") .setIncludeListener(includeListener) .setIOFactory(factory) .setListDelimiterHandler(listHandler) .setIncludesAllowed(false) .getParameters(); // @formatter:on checkBasicProperties(map); final FileBasedBuilderParametersImpl fbp = FileBasedBuilderParametersImpl.fromParameters(map); assertEquals("Wrong file name", "test.properties", fbp.getFileHandler() .getFileName()); assertEquals("Wrong includes flag", Boolean.FALSE, map.get("includesAllowed")); assertSame("Wrong include listener", includeListener, map.get("includeListener")); assertSame("Wrong factory", factory, map.get("IOFactory")); }
Example #24
Source File: BlobStoreConfigurationTest.java From james-project with Apache License 2.0 | 5 votes |
@Test void cacheEnabledShouldBeFalseWhenSpecified() { PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.addProperty("implementation", BlobStoreConfiguration.BlobStoreImplName.OBJECTSTORAGE.getName()); configuration.addProperty("cache.enable", false); assertThat(BlobStoreConfiguration.from(configuration).cacheEnabled()) .isFalse(); }
Example #25
Source File: TestBasicConfigurationBuilder.java From commons-configuration with Apache License 2.0 | 5 votes |
/** * Tests a full reset of the builder. */ @Test public void testReset() throws ConfigurationException { final BasicConfigurationBuilder<PropertiesConfiguration> builder = new BasicConfigurationBuilder<>( PropertiesConfiguration.class, createTestParameters()); final PropertiesConfiguration config = builder.getConfiguration(); builder.reset(); final PropertiesConfiguration config2 = builder.getConfiguration(); assertNotSame("No new result", config, config2); assertFalse("Parameters not reset", config2.isThrowExceptionOnMissing()); }
Example #26
Source File: TestPropertiesBuilderParametersImpl.java From commons-configuration with Apache License 2.0 | 5 votes |
/** * Tests whether the IO factory can be set. */ @Test public void testSetIOFactory() { final PropertiesConfiguration.IOFactory factory = EasyMock.createMock(PropertiesConfiguration.IOFactory.class); EasyMock.replay(factory); assertSame("Wrong result", params, params.setIOFactory(factory)); assertSame("Factory not set", factory, params.getParameters().get("IOFactory")); }
Example #27
Source File: SwiftKeystone3ConfigurationReaderTest.java From james-project with Apache License 2.0 | 5 votes |
@Test void failsToReadKeystone3ConfigurationWithoutUserDomainName() throws Exception { PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.read(new StringReader(StringUtils.joinWith("\n", CONFIG_ENDPOINT, CONFIG_CREDENTIALS, CONFIG_USER_NAME))); assertThatThrownBy(() -> SwiftKeystone3ConfigurationReader.readSwiftConfiguration(configuration)) .isInstanceOf(IllegalArgumentException.class); }
Example #28
Source File: ElasticSearchConfigurationTest.java From james-project with Apache License 2.0 | 5 votes |
@Test void getHostsShouldReturnConfiguredHostsWhenNoPort() throws ConfigurationException { PropertiesConfiguration configuration = new PropertiesConfiguration(); String hostname = "myHost"; configuration.addProperty("elasticsearch.hosts", hostname); ElasticSearchConfiguration elasticSearchConfiguration = ElasticSearchConfiguration.fromProperties(configuration); assertThat(elasticSearchConfiguration.getHosts()) .containsOnly(Host.from(hostname, ElasticSearchConfiguration.DEFAULT_PORT)); }
Example #29
Source File: AwsS3ConfigurationReaderTest.java From james-project with Apache License 2.0 | 5 votes |
@Test void fromShouldThrowWhenSecretKeyIsNull() { Configuration configuration = new PropertiesConfiguration(); configuration.addProperty(AwsS3ConfigurationReader.OBJECTSTORAGE_ENDPOINT, "myEndpoint"); configuration.addProperty(AwsS3ConfigurationReader.OBJECTSTORAGE_ACCESKEYID, "myAccessKeyId"); assertThatThrownBy(() -> AwsS3ConfigurationReader.from(configuration)) .isInstanceOf(NullPointerException.class) .hasMessage("'secretKey' is mandatory"); }
Example #30
Source File: ElasticSearchConfigurationTest.java From james-project with Apache License 2.0 | 5 votes |
@Test void getMaxRetriesShouldReturnDefaultValueWhenMissing() throws ConfigurationException { PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.addProperty("elasticsearch.hosts", "127.0.0.1"); ElasticSearchConfiguration elasticSearchConfiguration = ElasticSearchConfiguration.fromProperties(configuration); assertThat(elasticSearchConfiguration.getMaxRetries()) .isEqualTo(ElasticSearchConfiguration.DEFAULT_CONNECTION_MAX_RETRIES); }