You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2018/10/31 01:49:49 UTC
[31/33] james-project git commit: JAMES-2525 Extract fake properties
provider to common package
JAMES-2525 Extract fake properties provider to common package
the fake properties provider was deemed useful enough in code review to
be raised from its internal class status to a public common component.
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/2f545f40
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/2f545f40
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/2f545f40
Branch: refs/heads/master
Commit: 2f545f40be1fa87a6dce927ec7af16c8170aecc1
Parents: 37d33c2
Author: Jean Helou <jh...@codamens.fr>
Authored: Mon Oct 15 13:51:12 2018 +0200
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Wed Oct 31 08:48:47 2018 +0700
----------------------------------------------------------------------
.../objectstorage/FakePropertiesProvider.java | 75 ++++++++++++++++++++
.../objectstorage/PayloadCodecProviderTest.java | 53 --------------
2 files changed, 75 insertions(+), 53 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/2f545f40/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/FakePropertiesProvider.java
----------------------------------------------------------------------
diff --git a/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/FakePropertiesProvider.java b/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/FakePropertiesProvider.java
new file mode 100644
index 0000000..cff47ee
--- /dev/null
+++ b/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/FakePropertiesProvider.java
@@ -0,0 +1,75 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.james.modules.objectstorage;
+
+import java.io.FileNotFoundException;
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.james.utils.PropertiesProvider;
+
+import com.google.common.collect.ImmutableMap;
+
+public class FakePropertiesProvider extends PropertiesProvider {
+ private ImmutableMap<String, Configuration> configurations;
+
+ public FakePropertiesProvider(ImmutableMap<String, Configuration> configurations) {
+ super(null);
+ this.configurations = configurations;
+ }
+
+
+ @Override
+ public Configuration getConfiguration(String fileName) throws FileNotFoundException, ConfigurationException {
+ if (configurations.containsKey(fileName)) {
+ return configurations.get(fileName);
+ } else {
+ throw new FileNotFoundException(
+ "no configuration defined for " +
+ fileName +
+ " know configurations are (" +
+ StringUtils.join(configurations.keySet(), ",") +
+ ")");
+ }
+ }
+
+ public static FakePropertiesProviderBuilder builder() {
+ return new FakePropertiesProviderBuilder();
+ }
+
+ static class FakePropertiesProviderBuilder {
+ private final ImmutableMap.Builder<String, Configuration> configurations;
+
+ public FakePropertiesProviderBuilder() {
+ configurations = new ImmutableMap.Builder<>();
+ }
+
+ public FakePropertiesProviderBuilder register(String filename,
+ Configuration configuration) {
+ configurations.put(filename, configuration);
+ return this;
+ }
+
+ public FakePropertiesProvider build() {
+ return new FakePropertiesProvider(configurations.build());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/2f545f40/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/PayloadCodecProviderTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/PayloadCodecProviderTest.java b/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/PayloadCodecProviderTest.java
index 32c0036..b09ebf1 100644
--- a/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/PayloadCodecProviderTest.java
+++ b/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/PayloadCodecProviderTest.java
@@ -22,18 +22,10 @@ package org.apache.james.modules.objectstorage;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import java.io.FileNotFoundException;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.commons.configuration.Configuration;
-import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.MapConfiguration;
-import org.apache.commons.lang3.StringUtils;
import org.apache.james.blob.objectstorage.AESPayloadCodec;
import org.apache.james.blob.objectstorage.DefaultPayloadCodec;
import org.apache.james.blob.objectstorage.PayloadCodec;
-import org.apache.james.utils.PropertiesProvider;
import org.junit.jupiter.api.Test;
import com.google.common.collect.ImmutableMap;
@@ -157,51 +149,6 @@ class PayloadCodecProviderTest {
return new MapConfigurationBuilder();
}
- private static class FakePropertiesProvider extends PropertiesProvider {
- private Map<String, Configuration> configurations;
-
- public FakePropertiesProvider(Map<String, Configuration> configurations) {
- super(null);
- this.configurations = configurations;
- }
-
-
- @Override
- public Configuration getConfiguration(String fileName) throws FileNotFoundException, ConfigurationException {
- if (configurations.containsKey(fileName)) {
- return configurations.get(fileName);
- } else {
- throw new FileNotFoundException(
- "no configuration defined for " +
- fileName +
- " know configurations are (" +
- StringUtils.join(configurations.keySet(), ",") +
- ")");
- }
- }
-
- public static FakePropertiesProviderBuilder builder() {
- return new FakePropertiesProviderBuilder();
- }
-
- static class FakePropertiesProviderBuilder {
- private final Map<String, Configuration> configurations;
-
- public FakePropertiesProviderBuilder() {
- configurations = new HashMap<>();
- }
-
- public FakePropertiesProviderBuilder register(String objectstorage, Configuration configuration) {
- configurations.put(objectstorage, configuration);
- return this;
- }
-
- public FakePropertiesProvider build() {
- return new FakePropertiesProvider(configurations);
- }
- }
- }
-
private static class MapConfigurationBuilder {
private ImmutableMap.Builder<String, Object> config;
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org