summaryrefslogtreecommitdiffstats
path: root/container-di/src/test/java/demo/ComponentConfigTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'container-di/src/test/java/demo/ComponentConfigTest.java')
-rw-r--r--container-di/src/test/java/demo/ComponentConfigTest.java48
1 files changed, 48 insertions, 0 deletions
diff --git a/container-di/src/test/java/demo/ComponentConfigTest.java b/container-di/src/test/java/demo/ComponentConfigTest.java
new file mode 100644
index 00000000000..5b3be2f549a
--- /dev/null
+++ b/container-di/src/test/java/demo/ComponentConfigTest.java
@@ -0,0 +1,48 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package demo;
+
+import com.yahoo.config.test.ThreadPoolConfig;
+import com.yahoo.container.di.componentgraph.Provider;
+import org.junit.Test;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import static org.junit.Assert.assertNotNull;
+
+
+/**
+ * @author tonytv
+ * @author gjoranv
+ */
+public class ComponentConfigTest extends Base {
+ public static class ThreadPoolExecutorProvider implements Provider<Executor> {
+ private ExecutorService executor;
+
+ public ThreadPoolExecutorProvider(ThreadPoolConfig config) {
+ executor = Executors.newFixedThreadPool(config.numThreads());
+ }
+
+ @Override
+ public Executor get() {
+ return executor;
+ }
+
+ @Override
+ public void deconstruct() {
+ executor.shutdown();
+ }
+ }
+
+ @Test
+ public void require_that_non_components_can_be_configured() {
+ register(ThreadPoolExecutorProvider.class);
+ addConfig(new ThreadPoolConfig(new ThreadPoolConfig.Builder().numThreads(4)),
+ toId(ThreadPoolExecutorProvider.class));
+ complete();
+
+ Executor executor = getInstance(Executor.class);
+ assertNotNull(executor);
+ }
+}