https://github.com/apache/incubator-streams/pull/126 feedback
Project: http://git-wip-us.apache.org/repos/asf/incubator-streams/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-streams/commit/991b1707 Tree: http://git-wip-us.apache.org/repos/asf/incubator-streams/tree/991b1707 Diff: http://git-wip-us.apache.org/repos/asf/incubator-streams/diff/991b1707 Branch: refs/heads/master Commit: 991b17078be3a7fdb193f39786d829eeb6bfb586 Parents: 265562a Author: sblackmon <[email protected]> Authored: Mon Nov 17 14:28:16 2014 -0600 Committer: sblackmon <[email protected]> Committed: Mon Nov 17 14:28:16 2014 -0600 ---------------------------------------------------------------------- .../streams/config/ComponentConfigurator.java | 2 +- .../streams/config/StreamsConfigurator.java | 9 +++--- .../config/test/ComponentConfiguratorTest.java | 32 +++++++++++++++++--- .../config/test/StreamsConfiguratorTest.java | 25 +++++++++++++-- 4 files changed, 56 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/991b1707/streams-config/src/main/java/org/apache/streams/config/ComponentConfigurator.java ---------------------------------------------------------------------- diff --git a/streams-config/src/main/java/org/apache/streams/config/ComponentConfigurator.java b/streams-config/src/main/java/org/apache/streams/config/ComponentConfigurator.java index 7e3451d..42b70a6 100644 --- a/streams-config/src/main/java/org/apache/streams/config/ComponentConfigurator.java +++ b/streams-config/src/main/java/org/apache/streams/config/ComponentConfigurator.java @@ -63,7 +63,7 @@ public class ComponentConfigurator<T extends Serializable> { } public T detectConfiguration(String subConfig) { - Config streamsConfig = StreamsConfigurator.config; + Config streamsConfig = StreamsConfigurator.getConfig(); return detectConfiguration( streamsConfig.getConfig(subConfig)); } http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/991b1707/streams-config/src/main/java/org/apache/streams/config/StreamsConfigurator.java ---------------------------------------------------------------------- diff --git a/streams-config/src/main/java/org/apache/streams/config/StreamsConfigurator.java b/streams-config/src/main/java/org/apache/streams/config/StreamsConfigurator.java index 4a69456..9da0260 100644 --- a/streams-config/src/main/java/org/apache/streams/config/StreamsConfigurator.java +++ b/streams-config/src/main/java/org/apache/streams/config/StreamsConfigurator.java @@ -29,11 +29,10 @@ import org.slf4j.LoggerFactory; import java.io.Serializable; /** - * Created with IntelliJ IDEA. - * User: sblackmon - * Date: 9/23/13 - * Time: 10:44 AM - * To change this template use File | Settings | File Templates. + * StreamsConfigurator supplies the entire typesafe tree to runtimes and modules. + * + * StreamsConfigurator also supplies StreamsConfiguration POJO to runtimes and modules. + * */ public class StreamsConfigurator { http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/991b1707/streams-config/src/test/java/org/apache/streams/config/test/ComponentConfiguratorTest.java ---------------------------------------------------------------------- diff --git a/streams-config/src/test/java/org/apache/streams/config/test/ComponentConfiguratorTest.java b/streams-config/src/test/java/org/apache/streams/config/test/ComponentConfiguratorTest.java index 5b5c216..4acad9d 100644 --- a/streams-config/src/test/java/org/apache/streams/config/test/ComponentConfiguratorTest.java +++ b/streams-config/src/test/java/org/apache/streams/config/test/ComponentConfiguratorTest.java @@ -1,3 +1,21 @@ +/* + * 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 + * + * 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.streams.config.test; import com.fasterxml.jackson.databind.ObjectMapper; @@ -9,12 +27,18 @@ import org.apache.streams.config.ComponentConfiguration; import org.apache.streams.config.ComponentConfigurator; import org.apache.streams.config.StreamsConfigurator; import org.junit.Test; +import org.junit.runner.RunWith; import org.mockito.Mockito; import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; /** - * Created by sblackmon on 10/20/14. - */ +* Test for +* @see {@link org.apache.streams.config.ComponentConfigurator} +*/ +@RunWith(PowerMockRunner.class) +@PrepareForTest(StreamsConfigurator.class) public class ComponentConfiguratorTest { private final static ObjectMapper mapper = new ObjectMapper(); @@ -62,9 +86,9 @@ public class ComponentConfiguratorTest { Config config = ConfigFactory.load("componentTest"); - StreamsConfigurator mockStreamsConfigurator = Mockito.mock(StreamsConfigurator.class); + PowerMockito.mockStatic(StreamsConfigurator.class); - PowerMockito.when(mockStreamsConfigurator.getConfig()) + PowerMockito.when(StreamsConfigurator.getConfig()) .thenReturn(config); ComponentConfigurator<ComponentConfiguration> configurator = new ComponentConfigurator<>(ComponentConfiguration.class); http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/991b1707/streams-config/src/test/java/org/apache/streams/config/test/StreamsConfiguratorTest.java ---------------------------------------------------------------------- diff --git a/streams-config/src/test/java/org/apache/streams/config/test/StreamsConfiguratorTest.java b/streams-config/src/test/java/org/apache/streams/config/test/StreamsConfiguratorTest.java index 6f610c3..65dbd75 100644 --- a/streams-config/src/test/java/org/apache/streams/config/test/StreamsConfiguratorTest.java +++ b/streams-config/src/test/java/org/apache/streams/config/test/StreamsConfiguratorTest.java @@ -1,3 +1,21 @@ +/* + * 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 + * + * 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.streams.config.test; import com.fasterxml.jackson.databind.ObjectMapper; @@ -21,7 +39,8 @@ import java.util.Map; import java.util.Scanner; /** - * Created by sblackmon on 10/20/14. + * Test for + * @see {@link org.apache.streams.config.StreamsConfigurator} */ public class StreamsConfiguratorTest { @@ -32,7 +51,9 @@ public class StreamsConfiguratorTest { Config config = ConfigFactory.load(); - Config detected = StreamsConfigurator.config; + Config detected = StreamsConfigurator.getConfig(); + + junit.framework.Assert.assertEquals(config, detected); StreamsConfiguration defaultPojo = StreamsConfigurator.detectConfiguration();
