[Component-DSL] Adding Probe for tests

Also include the component-dsl classes in the test package so testing
internal classes is possible.

git-svn-id: https://svn.apache.org/repos/asf/aries/trunk@1811727 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/itests-run/itest.bndrun b/itests-run/itest.bndrun
index 223b8a0..0e16356 100644
--- a/itests-run/itest.bndrun
+++ b/itests-run/itest.bndrun
@@ -23,7 +23,6 @@
 -runproperties:
 -runbundles: \
   org.apache.aries.component-dsl.itests; version='[0.0.1,0.0.2)',\
-  org.apache.aries.component-dsl.component-dsl; version='[0.0.1,0.0.2)',\
   org.apache.felix.configadmin; version='[1.8.8,1.8.9)',\
   osgi.enroute.hamcrest.wrapper; version='[1.3.0,1.3.1)',\
   osgi.enroute.junit.wrapper; version='[4.12.0,4.12.1)'
diff --git a/itests/bnd.bnd b/itests/bnd.bnd
index 3517d96..aceb986 100644
--- a/itests/bnd.bnd
+++ b/itests/bnd.bnd
@@ -1,5 +1,10 @@
 Bundle-Description: Integration Test bundle for component DSL
 
+Private-Package:\
+	org.apache.aries.functional,\
+	org.apache.aries.osgi.functional,\
+	org.apache.aries.osgi.functional.internal
+
 Test-Cases: \
     ${classes;CONCRETE;EXTENDS;junit.framework.TestCase},\
     ${classes;CONCRETE;ANNOTATED;org.junit.Test}
diff --git a/itests/src/main/java/org/apache/aries/osgi/functional/internal/ProbeImpl.java b/itests/src/main/java/org/apache/aries/osgi/functional/internal/ProbeImpl.java
new file mode 100644
index 0000000..43b0965
--- /dev/null
+++ b/itests/src/main/java/org/apache/aries/osgi/functional/internal/ProbeImpl.java
@@ -0,0 +1,71 @@
+/*
+ * 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.aries.osgi.functional.internal;
+
+import org.apache.aries.osgi.functional.Event;
+import org.apache.aries.osgi.functional.SentEvent;
+import org.osgi.framework.BundleContext;
+
+import java.util.function.Consumer;
+import java.util.function.Function;
+
+/**
+ * @author Carlos Sierra Andrés
+ */
+public class ProbeImpl<T> extends OSGiImpl<T> {
+
+    public ProbeImpl() {
+        super(new ProbeOperationImpl<>());
+    }
+
+    public Function<T, SentEvent<T>> getOperation() {
+        return (t) -> {
+            Tuple<T> tuple = Tuple.create(t);
+
+            ((ProbeOperationImpl<T>)_operation)._op.accept(tuple);
+
+            return new SentEvent<T>() {
+                @Override
+                public Event<T> getEvent() {
+                    return tuple;
+                }
+
+                @Override
+                public void terminate() {
+                    tuple.terminate();
+                }
+            };
+        };
+    }
+
+    private static class ProbeOperationImpl<T> implements OSGiOperationImpl<T> {
+
+        BundleContext _bundleContext;
+        Consumer<Tuple<T>> _op;
+
+        @Override
+        public OSGiResultImpl run(
+            BundleContext bundleContext, Consumer<Tuple<T>> op) {
+            _bundleContext = bundleContext;
+            _op = op;
+
+            return new OSGiResultImpl(NOOP, NOOP);
+        }
+    }
+
+}
diff --git a/itests/src/main/java/org/apache/aries/osgi/functional/internal/ProbeTests.java b/itests/src/main/java/org/apache/aries/osgi/functional/internal/ProbeTests.java
new file mode 100644
index 0000000..0264c32
--- /dev/null
+++ b/itests/src/main/java/org/apache/aries/osgi/functional/internal/ProbeTests.java
@@ -0,0 +1,77 @@
+/*
+ * 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.aries.osgi.functional.internal;
+
+import org.apache.aries.osgi.functional.OSGi;
+import org.apache.aries.osgi.functional.SentEvent;
+import org.apache.aries.osgi.functional.test.DSLTest;
+import org.junit.Test;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.function.Function;
+
+import static org.apache.aries.osgi.functional.OSGi.just;
+import static org.apache.aries.osgi.functional.OSGi.onClose;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * @author Carlos Sierra Andrés
+ */
+public class ProbeTests {
+
+    static BundleContext bundleContext =
+        FrameworkUtil.getBundle(DSLTest.class).getBundleContext();
+
+    @Test
+    public void testProbe() {
+        AtomicInteger result = new AtomicInteger();
+
+        ProbeImpl<Integer> probeA = new ProbeImpl<>();
+
+        Function<Integer, SentEvent<Integer>> opA = probeA.getOperation();
+        OSGi<Integer> just10 = just(10);
+
+        OSGi<Integer> program = probeA.flatMap(a ->
+            onClose(result::incrementAndGet).then(
+                just10.flatMap(b ->
+                    onClose(result::incrementAndGet).then(
+                        just(a + b)
+                    ))));
+
+        program.run(bundleContext, result::set);
+        assertEquals(0, result.get());
+
+        SentEvent<Integer> sentA = opA.apply(5);
+        assertEquals(15, result.get());
+
+        sentA.terminate();
+        assertEquals(17, result.get());
+
+        sentA.terminate();
+        assertEquals(17, result.get());
+
+        sentA = opA.apply(10);
+        assertEquals(20, result.get());
+
+        sentA.terminate();
+        assertEquals(22, result.get());
+    }
+
+}
diff --git a/itests/src/main/java/org/apache/aries/osgi/functional/test/DSLTest.java b/itests/src/main/java/org/apache/aries/osgi/functional/test/DSLTest.java
index 9a123e8..450d208 100644
--- a/itests/src/main/java/org/apache/aries/osgi/functional/test/DSLTest.java
+++ b/itests/src/main/java/org/apache/aries/osgi/functional/test/DSLTest.java
@@ -19,7 +19,6 @@
 
 import org.apache.aries.osgi.functional.OSGi;
 import org.apache.aries.osgi.functional.OSGiResult;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.FrameworkUtil;