brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [5/9] incubator-brooklyn git commit: BROOKLYN-162 convert camp-base and camp-server to org.apache prefix
Date Tue, 18 Aug 2015 13:25:53 GMT
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/resolve/PlanInterpreter.java
----------------------------------------------------------------------
diff --git a/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/resolve/PlanInterpreter.java b/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/resolve/PlanInterpreter.java
new file mode 100644
index 0000000..dbf20cc
--- /dev/null
+++ b/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/resolve/PlanInterpreter.java
@@ -0,0 +1,113 @@
+/*
+ * 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.brooklyn.camp.spi.resolve;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.brooklyn.camp.spi.resolve.interpret.PlanInterpretationNode;
+
+/** Interpreters modify the deployment plan, in a depth-first evaluation,
+ * typically by looking for items which begin with "$namespace:"
+ * <p>
+ * Most common usages simple need to supply {@link #applyYamlPrimitive(PlanInterpretationNode)} which can invoke
+ * {@link PlanInterpretationNode#setNewValue(Object)} to change.
+ * The {@link PlanInterpreterAdapter} makes this easy by supplying all methods but that.
+ * <p>
+ * For more sophisticated usages, to act on entire maps or lists,
+ * there are a number of other hook functions, described below.
+ *  */
+public interface PlanInterpreter {
+
+    /** guard to prevent any apply calls when an Interpreter is not interested in a node */
+    boolean isInterestedIn(PlanInterpretationNode node);
+    
+    /** provides an opportunity for an interpreter to change the value at a node,
+     * using {@link PlanInterpretationNode#get()} and {@link PlanInterpretationNode#setNewValue(Object)} */
+    void applyYamlPrimitive(PlanInterpretationNode node);
+
+    /** invoked at a Map node in a YAML tree, before any conversion to mapOut.
+     * mapIn is initially a copy of {@link PlanInterpretationNode#get()}, but it is mutable,
+     * and any mutations are passed to subsequent interpreters and used for recursion.
+     * <p>
+     * the return value indicates whether to recurse into the item.
+     * if any interpreters return false, the node is not recursed. 
+     * (callers may use {@link PlanInterpretationNode#setNewValue(Object)} to set a custom return value.) */
+    boolean applyMapBefore(PlanInterpretationNode node, Map<Object, Object> mapIn);
+
+    /** invoked at a Map node in a YAML tree, after {@link #applyMapBefore(PlanInterpretationNode, Map)},
+     * and after recursing into the value and then key arguments supplied here,
+     * but before inserting it into the mapOut for this node. 
+     * <p>
+     * the return value indicates whether to add this key-value to the mapOut.
+     * if any interpreters return false, the entry is not added. 
+     * (callers may modify mapOut to add/change values, or may modify key/value directly.) */
+    boolean applyMapEntry(PlanInterpretationNode node, Map<Object, Object> mapIn, Map<Object, Object> mapOut,
+                            PlanInterpretationNode key, PlanInterpretationNode value);
+
+    /** invoked at a Map node in a YAML tree, after all entries have been passed to all interpreters' 
+     * {@link #applyMapEntry(PlanInterpretationNode, Map, Map, PlanInterpretationNode, PlanInterpretationNode)}.
+     * mapOut can be modified yet further. */
+    void applyMapAfter(PlanInterpretationNode node, Map<Object, Object> mapIn, Map<Object, Object> mapOut);
+
+    /** as {@link #applyMapBefore(PlanInterpretationNode, Map)} but for lists */
+    boolean applyListBefore(PlanInterpretationNode node, List<Object> listIn);
+
+    /** as {@link #applyMapEntry(PlanInterpretationNode, Map, Map, PlanInterpretationNode, PlanInterpretationNode) but for lists */
+    boolean applyListEntry(PlanInterpretationNode node, List<Object> listIn, List<Object> listOut,
+                            PlanInterpretationNode value);
+
+    /** as {@link #applyMapAfter(PlanInterpretationNode, Map, Map)} but for lists  */
+    void applyListAfter(PlanInterpretationNode node, List<Object> listIn, List<Object> listOut);
+
+    
+    public abstract static class PlanInterpreterAdapter implements PlanInterpreter {
+
+        @Override
+        public boolean applyMapBefore(PlanInterpretationNode node, Map<Object, Object> mapIn) {
+            return true;
+        }
+
+        @Override
+        public boolean applyMapEntry(PlanInterpretationNode node, Map<Object, Object> mapIn, Map<Object, Object> mapOut,
+                                PlanInterpretationNode key, PlanInterpretationNode value) {
+            return true;
+        }
+
+        @Override
+        public void applyMapAfter(PlanInterpretationNode node, Map<Object, Object> mapIn, Map<Object, Object> mapOut) {
+        }
+
+        @Override
+        public boolean applyListBefore(PlanInterpretationNode node, List<Object> listIn) {
+            return true;
+        }
+
+        @Override
+        public boolean applyListEntry(PlanInterpretationNode node, List<Object> listIn, List<Object> listOut,
+                                PlanInterpretationNode value) {
+            return true;
+        }
+
+        @Override
+        public void applyListAfter(PlanInterpretationNode node, List<Object> listIn, List<Object> listOut) {
+        }
+        
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/resolve/interpret/PlanInterpretationContext.java
----------------------------------------------------------------------
diff --git a/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/resolve/interpret/PlanInterpretationContext.java b/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/resolve/interpret/PlanInterpretationContext.java
new file mode 100644
index 0000000..08053cb
--- /dev/null
+++ b/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/resolve/interpret/PlanInterpretationContext.java
@@ -0,0 +1,152 @@
+/*
+ * 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.brooklyn.camp.spi.resolve.interpret;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.brooklyn.camp.spi.resolve.PlanInterpreter;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+
+public class PlanInterpretationContext {
+
+    private final Map<String,Object> originalDeploymentPlan;
+    private final List<PlanInterpreter> interpreters;
+    private final PlanInterpreter allInterpreter;
+
+    public PlanInterpretationContext(Map<String,Object> originalDeploymentPlan, List<PlanInterpreter> interpreters) {
+        super();
+        this.originalDeploymentPlan = ImmutableMap.copyOf(originalDeploymentPlan);
+        this.interpreters = ImmutableList.copyOf(interpreters);
+        this.allInterpreter = new PlanInterpreter() {
+            @Override
+            public boolean isInterestedIn(PlanInterpretationNode node) {
+                return true;
+            }
+            
+            @Override
+            public void applyYamlPrimitive(PlanInterpretationNode node) {
+                for (PlanInterpreter i: PlanInterpretationContext.this.interpreters) {
+                    if (node.isExcluded())
+                        break;
+                    if (i.isInterestedIn(node)) {
+                        i.applyYamlPrimitive(node);
+                    }
+                }
+            }
+
+            @Override
+            public boolean applyMapBefore(PlanInterpretationNode node, Map<Object, Object> mapIn) {
+                boolean result = true;
+                for (PlanInterpreter i: PlanInterpretationContext.this.interpreters) {
+                    if (node.isExcluded())
+                        break;
+                    if (i.isInterestedIn(node)) {
+                        boolean ri= i.applyMapBefore(node, mapIn);
+                        result &= ri;
+                    }
+                }
+                return result;
+            }
+
+            @Override
+            public boolean applyMapEntry(PlanInterpretationNode node, Map<Object, Object> mapIn, Map<Object, Object> mapOut, 
+                                    PlanInterpretationNode key, PlanInterpretationNode value) {
+                boolean result = true;
+                for (PlanInterpreter i: PlanInterpretationContext.this.interpreters) { 
+                    if (node.isExcluded())
+                        break;
+                    if (i.isInterestedIn(key)) {
+                        boolean ri = i.applyMapEntry(node, mapIn, mapOut, key, value);
+                        result &= ri;
+                    }
+                }
+                return result;
+            }
+
+            @Override
+            public void applyMapAfter(PlanInterpretationNode node, Map<Object, Object> mapIn, Map<Object, Object> mapOut) {
+                for (PlanInterpreter i: PlanInterpretationContext.this.interpreters) { 
+                    if (node.isExcluded())
+                        break;
+                    if (i.isInterestedIn(node)) {
+                        i.applyMapAfter(node, mapIn, mapOut);
+                    }
+                }
+            }
+
+            @Override
+            public boolean applyListBefore(PlanInterpretationNode node, List<Object> listIn) {
+                boolean result = true;
+                for (PlanInterpreter i: PlanInterpretationContext.this.interpreters) { 
+                    if (node.isExcluded())
+                        break;
+                    if (i.isInterestedIn(node)) {
+                        boolean ri = i.applyListBefore(node, listIn);
+                        result &= ri;
+                    }
+                }
+                return result;
+            }
+
+            @Override
+            public boolean applyListEntry(PlanInterpretationNode node, List<Object> listIn, List<Object> listOut, 
+                                    PlanInterpretationNode value) {
+                boolean result = true;
+                for (PlanInterpreter i: PlanInterpretationContext.this.interpreters) { 
+                    if (node.isExcluded())
+                        break;
+                    if (i.isInterestedIn(value)) {
+                        boolean ri = i.applyListEntry(node, listIn, listOut, value);
+                        result &= ri;
+                    }
+                }
+                return result;
+            }
+
+            @Override
+            public void applyListAfter(PlanInterpretationNode node, List<Object> listIn, List<Object> listOut) {
+                for (PlanInterpreter i: PlanInterpretationContext.this.interpreters) { 
+                    if (node.isExcluded())
+                        break;
+                    if (i.isInterestedIn(node)) {
+                        i.applyListAfter(node, listIn, listOut);
+                    }
+                }
+            }
+
+        };
+    }
+
+    /** returns an interpreter which recurses through all interpreters */
+    PlanInterpreter getAllInterpreter() {
+        return allInterpreter;
+    }
+
+    public Map<String,Object> getOriginalDeploymentPlan() {
+        return originalDeploymentPlan;
+    }
+
+    public List<PlanInterpreter> getInterpreters() {
+        return interpreters;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/resolve/interpret/PlanInterpretationNode.java
----------------------------------------------------------------------
diff --git a/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/resolve/interpret/PlanInterpretationNode.java b/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/resolve/interpret/PlanInterpretationNode.java
new file mode 100644
index 0000000..43428ed
--- /dev/null
+++ b/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/resolve/interpret/PlanInterpretationNode.java
@@ -0,0 +1,262 @@
+/*
+ * 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.brooklyn.camp.spi.resolve.interpret;
+
+import java.util.Map;
+
+import org.apache.brooklyn.camp.spi.resolve.PlanInterpreter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import brooklyn.util.collections.MutableList;
+import brooklyn.util.collections.MutableMap;
+import brooklyn.util.text.StringPredicates;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Iterables;
+
+/** Helper class for {@link PlanInterpreter} instances, doing the recursive work */
+public class PlanInterpretationNode {
+
+    private static final Logger log = LoggerFactory.getLogger(PlanInterpretationNode.class);
+    
+    public enum Role { MAP_KEY, MAP_VALUE, LIST_ENTRY, YAML_PRIMITIVE }
+
+    protected final PlanInterpretationNode parent;
+    protected final Role roleInParent;
+    protected final Object originalValue;
+    protected final PlanInterpretationContext context;
+    protected Object newValue = null;
+    protected Boolean changed = null;
+    protected boolean excluded = false;
+    protected boolean immutable = false;
+
+    /** creates a root node with {@link #apply()} called */
+    public PlanInterpretationNode(PlanInterpretationContext context) {
+        this.parent = null;
+        this.roleInParent = null;
+        this.originalValue = context.getOriginalDeploymentPlan();
+        this.context = context;
+        apply();
+    }
+
+    /** internal use: creates an internal node on which {@link #apply()} has *not* been called */
+    protected PlanInterpretationNode(PlanInterpretationNode parent, Role roleInParent, Object originalItem) {
+        this.parent = parent;
+        this.roleInParent = roleInParent;
+        this.originalValue = originalItem;
+        this.context = parent.getContext();
+    }
+
+    public PlanInterpretationContext getContext() {
+        return context;
+    }
+
+    public PlanInterpretationNode getParent() {
+        return parent;
+    }
+    
+    public Role getRoleInParent() {
+        return roleInParent;
+    }
+    
+    protected void apply() {
+        if (changed!=null) throw new IllegalStateException("can only be applied once");
+
+        if (!excluded) {
+            if (originalValue instanceof Map) {
+                applyToMap();
+                immutable();
+            } else if (originalValue instanceof Iterable) {
+                applyToIterable();
+                immutable();
+            } else {
+                applyToYamlPrimitive();
+            }
+        }
+        
+        if (changed==null) changed = false;
+    }
+
+    /** convenience for interpreters, tests if nodes are not excluded, and if not:
+     * for string nodes, true iff the current value equals the given target;
+     * for nodes which are currently maps or lists,
+     * true iff not excluded and the value contains such an entry (key, in the case of map)
+     **/
+    public boolean matchesLiteral(String target) {
+        if (isExcluded()) return false; 
+        if (getNewValue() instanceof CharSequence)
+            return getNewValue().toString().equals(target);
+        if (getNewValue() instanceof Map)
+            return ((Map<?,?>)getOriginalValue()).containsKey(target);
+        if (getNewValue() instanceof Iterable)
+            return Iterables.contains((Iterable<?>)getOriginalValue(), target);
+        return false;
+    }
+
+    /** convenience for interpreters, tests if nodes are not excluded, and if not:
+     * for string nodes, true iff the current value starts with the given prefix;
+     * for nodes which are currently maps or lists,
+     * true iff not excluded and the value contains such an entry (key, in the case of map) */
+    public boolean matchesPrefix(String prefix) {
+        if (isExcluded()) return false; 
+        if (getNewValue() instanceof CharSequence)
+            return getNewValue().toString().startsWith(prefix);
+        if (getNewValue() instanceof Map)
+            return Iterables.tryFind(((Map<?,?>)getNewValue()).keySet(), StringPredicates.isStringStartingWith(prefix)).isPresent();
+        if (getNewValue() instanceof Iterable)
+            return Iterables.tryFind((Iterable<?>)getNewValue(), StringPredicates.isStringStartingWith(prefix)).isPresent();
+        return false;
+    }
+    
+    // TODO matchesRegex ?
+
+    public Object getOriginalValue() {
+        return originalValue;
+    }
+
+    public Object getNewValue() {
+        if (changed==null || !isChanged()) return originalValue;
+        return newValue;
+    }
+
+    public boolean isChanged() {
+        if (changed==null) throw new IllegalStateException("not yet applied");
+        return changed;
+    }
+
+    public boolean isExcluded() {
+        return excluded;
+    }
+    
+    /** indicates that a node should no longer be translated */
+    public PlanInterpretationNode exclude() {
+        this.excluded = true;
+        return this;
+    }
+    
+    public PlanInterpretationNode setNewValue(Object newItem) {
+        if (immutable)
+            throw new IllegalStateException("Node "+this+" has been set immutable");
+        this.newValue = newItem;
+        this.changed = true;
+        return this;
+    }
+
+    protected PlanInterpretationNode newPlanInterpretation(PlanInterpretationNode parent, Role roleInParent, Object item) {
+        return new PlanInterpretationNode(parent, roleInParent, item);
+    }
+
+    protected void applyToMap() {
+        Map<Object, Object> input = MutableMap.<Object,Object>copyOf((Map<?,?>)originalValue);
+        Map<Object, Object> result = MutableMap.<Object,Object>of();
+        newValue = result;
+
+        // first do a "whole-node" application
+        if (getContext().getAllInterpreter().applyMapBefore(this, input)) {
+
+            for (Map.Entry<Object,Object> entry: input.entrySet()) {
+                // then recurse in to this node and do various in-the-node applications
+                PlanInterpretationNode value = newPlanInterpretation(this, Role.MAP_VALUE, entry.getValue());
+                value.apply();
+
+                PlanInterpretationNode key = newPlanInterpretation(this, Role.MAP_KEY, entry.getKey());
+                key.apply();
+
+                if (key.isChanged() || value.isChanged()) 
+                    changed = true;
+
+                if (getContext().getAllInterpreter().applyMapEntry(this, input, result, key, value))
+                    result.put(key.getNewValue(), value.getNewValue());
+                else
+                    changed = true;
+            }
+
+            // finally try applying to this node again
+            getContext().getAllInterpreter().applyMapAfter(this, input, result);
+        }
+
+        if (changed==null) changed = false;
+    }
+
+    protected void applyToIterable() {
+        MutableList<Object> input = MutableList.copyOf((Iterable<?>)originalValue);
+        MutableList<Object> result = new MutableList<Object>();
+        newValue = result;
+
+        // first do a "whole-node" application
+        if (getContext().getAllInterpreter().applyListBefore(this, input)) {
+
+            for (Object entry: input) {
+                // then recurse in to this node and do various in-the-node applications
+                PlanInterpretationNode value = newPlanInterpretation(this, Role.LIST_ENTRY, entry);
+                value.apply();
+
+                if (value.isChanged()) 
+                    changed = true;
+
+                if (getContext().getAllInterpreter().applyListEntry(this, input, result, value))
+                    result.add(value.getNewValue());
+            }
+
+            // finally try applying to this node again
+            getContext().getAllInterpreter().applyListAfter(this, input, result);
+        }
+
+        if (changed==null) changed = false;
+    }
+
+    protected void applyToYamlPrimitive() {
+        getContext().getAllInterpreter().applyYamlPrimitive(this);
+    }
+
+    public void immutable() {
+        if (!isChanged()) {
+            if (!testCollectionImmutable(getNewValue())) {
+                // results of Yaml parse are not typically immutable,
+                // so force them to be changed so result of interpretation is immutable
+                changed = true;
+                setNewValue(immutable(getNewValue()));
+            }
+        } else {
+            setNewValue(immutable(getNewValue()));
+        }
+        checkImmutable(getNewValue());
+        immutable = true;
+    }
+    
+    private void checkImmutable(Object in) {
+        if (!testCollectionImmutable(in))
+            log.warn("Node original value "+in+" at "+this+" should be immutable");
+    }
+    
+    private static boolean testCollectionImmutable(Object in) {
+        if (in instanceof Map) return (in instanceof ImmutableMap);
+        if (in instanceof Iterable) return (in instanceof ImmutableList);
+        return true;
+    }
+
+    private static Object immutable(Object in) {
+        if (in instanceof Map) return ImmutableMap.copyOf((Map<?,?>)in);
+        if (in instanceof Iterable) return ImmutableList.copyOf((Iterable<?>)in);
+        return in;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/main/java/org/apache/brooklyn/camp/util/yaml/Yamls.java
----------------------------------------------------------------------
diff --git a/camp/camp-base/src/main/java/org/apache/brooklyn/camp/util/yaml/Yamls.java b/camp/camp-base/src/main/java/org/apache/brooklyn/camp/util/yaml/Yamls.java
new file mode 100644
index 0000000..1c2c379
--- /dev/null
+++ b/camp/camp-base/src/main/java/org/apache/brooklyn/camp/util/yaml/Yamls.java
@@ -0,0 +1,24 @@
+/*
+ * 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.brooklyn.camp.util.yaml;
+
+/** @deprecated since 0.7.0 use {@link brooklyn.util.yaml.Yamls} */
+@Deprecated
+public class Yamls extends brooklyn.util.yaml.Yamls {
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/test/java/io/brooklyn/camp/spi/pdp/DeploymentPlanToyInterpreterTest.java
----------------------------------------------------------------------
diff --git a/camp/camp-base/src/test/java/io/brooklyn/camp/spi/pdp/DeploymentPlanToyInterpreterTest.java b/camp/camp-base/src/test/java/io/brooklyn/camp/spi/pdp/DeploymentPlanToyInterpreterTest.java
deleted file mode 100644
index 29f8abf..0000000
--- a/camp/camp-base/src/test/java/io/brooklyn/camp/spi/pdp/DeploymentPlanToyInterpreterTest.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * 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 io.brooklyn.camp.spi.pdp;
-
-import io.brooklyn.camp.BasicCampPlatform;
-import io.brooklyn.camp.spi.resolve.PlanInterpreter.PlanInterpreterAdapter;
-import io.brooklyn.camp.spi.resolve.interpret.PlanInterpretationNode;
-
-import java.util.Map;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import brooklyn.util.stream.Streams;
-import brooklyn.util.text.Strings;
-import brooklyn.util.yaml.Yamls;
-
-@Test
-public class DeploymentPlanToyInterpreterTest {
-
-    private static final Logger log = LoggerFactory.getLogger(DeploymentPlanToyInterpreterTest.class);
-    
-    /**
-     * Allows testing:
-     * 
-     * $sample:foo becomes "bar"
-     * $sample:caps:x capitalises the argument x
-     * $sample:ignore as key causes key-value to be dropped (and value 0 for good measure)
-     * $sample:reset causes containing map or list to be cleared at that point
-     * $sample:remove as key causes argument as map to be dropped
-     */
-    public static class ToyInterpreter extends PlanInterpreterAdapter {
-        
-        @Override
-        public boolean isInterestedIn(PlanInterpretationNode node) {
-            return node.matchesPrefix("$sample:");
-        }
-        
-        @Override
-        public void applyYamlPrimitive(PlanInterpretationNode node) {
-            if (node.matchesLiteral("$sample:foo")) node.setNewValue("bar").exclude();
-            if (node.matchesPrefix("$sample:caps:")) {
-                node.setNewValue(Strings.removeFromStart(node.getNewValue().toString(), "$sample:caps:").toUpperCase()).exclude();
-            }
-        }
-
-        @Override
-        public boolean applyMapBefore(PlanInterpretationNode node, Map<Object, Object> mapIn) {
-            if (node.matchesLiteral("$sample:ignore"))
-                // replace
-                mapIn.put("$sample:ignore", 0);
-            return super.applyMapBefore(node, mapIn);
-        }
-        
-        @Override
-        public boolean applyMapEntry(PlanInterpretationNode node, Map<Object, Object> mapIn, Map<Object, Object> mapOut,
-                                PlanInterpretationNode key, PlanInterpretationNode value) {
-            if (key.matchesLiteral("$sample:ignore")) {
-                Assert.assertEquals(value.getNewValue(), 0);
-                return false;
-            }
-            if (key.matchesLiteral("$sample:reset")) {
-                mapOut.clear();
-                return false;
-            }
-            
-            return super.applyMapEntry(node, mapIn, mapOut, key, value);
-        }
-
-        @SuppressWarnings("rawtypes")
-        @Override
-        public void applyMapAfter(PlanInterpretationNode node, Map<Object, Object> mapIn, Map<Object, Object> mapOut) {
-            if (mapOut.containsKey("$sample:remove")) {
-                Map toRemove = (Map) mapOut.get("$sample:remove");
-                for (Object vv: toRemove.keySet()) mapOut.remove(vv);
-                mapOut.remove("$sample:remove");
-            }
-        }
-    }
-
-    @SuppressWarnings("unchecked")
-    public void testToyInterpreter() {
-        @SuppressWarnings("rawtypes")
-        Map y1 = Yamls.getAs( Yamls.parseAll( Streams.reader(getClass().getResourceAsStream("yaml-sample-toy-interpreter.yaml"))), Map.class );
-        log.info("pre-interpreter have: "+y1);
-        
-        BasicCampPlatform p = new BasicCampPlatform();
-        p.pdp().addInterpreter(new ToyInterpreter());
-        Map<String, Object> y2 = p.pdp().applyInterpreters(y1);
-        log.info("interpreter gives: "+y2);
-        
-        Map<String, Object> y3 = Yamls.getAs( Yamls.parseAll( Streams.reader(getClass().getResourceAsStream("yaml-sample-toy-interpreter-result.yaml"))), Map.class );
-        Assert.assertEquals(y2, y3);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/test/java/io/brooklyn/camp/spi/pdp/PdpYamlTest.java
----------------------------------------------------------------------
diff --git a/camp/camp-base/src/test/java/io/brooklyn/camp/spi/pdp/PdpYamlTest.java b/camp/camp-base/src/test/java/io/brooklyn/camp/spi/pdp/PdpYamlTest.java
deleted file mode 100644
index 70170d7..0000000
--- a/camp/camp-base/src/test/java/io/brooklyn/camp/spi/pdp/PdpYamlTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * 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 io.brooklyn.camp.spi.pdp;
-
-import io.brooklyn.camp.BasicCampPlatform;
-import io.brooklyn.camp.spi.AssemblyTemplate;
-import io.brooklyn.camp.test.mock.web.MockWebPlatform;
-
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.Reader;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import brooklyn.util.stream.Streams;
-
-public class PdpYamlTest {
-
-    private static final Logger log = LoggerFactory.getLogger(PdpYamlTest.class);
-    
-    @Test
-    public void testSimpleYamlArtifactParse() throws IOException {
-        BasicCampPlatform platform = MockWebPlatform.populate(new BasicCampPlatform());
-        Reader input = Streams.reader(getClass().getResourceAsStream("pdp-single-artifact.yaml"));
-        DeploymentPlan plan = platform.pdp().parseDeploymentPlan(input);
-        log.info("DP is:\n"+plan.toString());
-        Assert.assertEquals(plan.getName(), "sample");
-        Assert.assertEquals(plan.getArtifacts().size(), 1);
-        Assert.assertEquals(plan.getServices().size(), 0);
-        
-        Artifact artifact1 = plan.getArtifacts().iterator().next();
-        Assert.assertEquals(artifact1.getName(), "sample WAR");
-    }
-    
-    @Test
-    public void testSimpleYamlServiceParse() throws IOException {
-        BasicCampPlatform platform = MockWebPlatform.populate(new BasicCampPlatform());
-        Reader input = Streams.reader(getClass().getResourceAsStream("pdp-single-service.yaml"));
-        DeploymentPlan plan = platform.pdp().parseDeploymentPlan(input);
-        log.info("DP is:\n"+plan.toString());
-        Assert.assertEquals(plan.getName(), "sample");
-        Assert.assertEquals(plan.getArtifacts().size(), 0);
-        Assert.assertEquals(plan.getServices().size(), 1);
-        
-        Service service1 = plan.getServices().iterator().next();
-        Assert.assertEquals(service1.getName(), "Hello WAR");
-    }
-    
-    @Test
-    public void testSimpleYamlMatch() throws IOException {
-        BasicCampPlatform platform = MockWebPlatform.populate(new BasicCampPlatform());
-        Reader input = new InputStreamReader(getClass().getResourceAsStream("pdp-single-artifact.yaml"));
-        AssemblyTemplate at = platform.pdp().registerDeploymentPlan(input);
-        log.info("AT is:\n"+at.toString());
-        Assert.assertEquals(at.getApplicationComponentTemplates().links().size(), 1);
-        Assert.assertEquals(at.getName(), "sample");
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/test/java/io/brooklyn/camp/test/mock/web/MockAssemblyTemplateInstantiator.java
----------------------------------------------------------------------
diff --git a/camp/camp-base/src/test/java/io/brooklyn/camp/test/mock/web/MockAssemblyTemplateInstantiator.java b/camp/camp-base/src/test/java/io/brooklyn/camp/test/mock/web/MockAssemblyTemplateInstantiator.java
deleted file mode 100644
index 1d2628d..0000000
--- a/camp/camp-base/src/test/java/io/brooklyn/camp/test/mock/web/MockAssemblyTemplateInstantiator.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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 io.brooklyn.camp.test.mock.web;
-
-import io.brooklyn.camp.CampPlatform;
-import io.brooklyn.camp.spi.Assembly;
-import io.brooklyn.camp.spi.AssemblyTemplate;
-import io.brooklyn.camp.spi.instantiate.AssemblyTemplateInstantiator;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class MockAssemblyTemplateInstantiator implements AssemblyTemplateInstantiator {
-
-    private static final Logger log = LoggerFactory.getLogger(MockAssemblyTemplateInstantiator.class);
-    
-    public Assembly instantiate(AssemblyTemplate template, CampPlatform platform) {
-        log.debug("Ignoring request to instantiate "+template);
-        return null;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/test/java/io/brooklyn/camp/test/mock/web/MockWebPlatform.java
----------------------------------------------------------------------
diff --git a/camp/camp-base/src/test/java/io/brooklyn/camp/test/mock/web/MockWebPlatform.java b/camp/camp-base/src/test/java/io/brooklyn/camp/test/mock/web/MockWebPlatform.java
deleted file mode 100644
index 1e76380..0000000
--- a/camp/camp-base/src/test/java/io/brooklyn/camp/test/mock/web/MockWebPlatform.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * 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 io.brooklyn.camp.test.mock.web;
-
-import javax.annotation.Nullable;
-
-import brooklyn.util.guava.Maybe;
-import io.brooklyn.camp.BasicCampPlatform;
-import io.brooklyn.camp.spi.ApplicationComponentTemplate;
-import io.brooklyn.camp.spi.AssemblyTemplate;
-import io.brooklyn.camp.spi.PlatformComponentTemplate;
-import io.brooklyn.camp.spi.collection.BasicResourceLookup;
-import io.brooklyn.camp.spi.collection.ResolvableLink;
-import io.brooklyn.camp.spi.instantiate.AssemblyTemplateInstantiator;
-import io.brooklyn.camp.spi.pdp.Artifact;
-import io.brooklyn.camp.spi.pdp.AssemblyTemplateConstructor;
-import io.brooklyn.camp.spi.pdp.Service;
-import io.brooklyn.camp.spi.resolve.PdpMatcher;
-
-public class MockWebPlatform {
-
-    public static final ApplicationComponentTemplate WAR = 
-            ApplicationComponentTemplate.builder()
-                .name("io.camp.mock:WAR")
-                .description("Mock WAR")
-                .build();
-
-    public static final PlatformComponentTemplate APPSERVER = 
-            PlatformComponentTemplate.builder()
-                .name("io.camp.mock:AppServer")
-                .description("Mock Application Server")
-                .build();
-
-    public static final PlatformComponentTemplate DATABASE = 
-            PlatformComponentTemplate.builder()
-                .name("io.camp.mock:Database")
-                .description("Mock Database")
-                .build();
-
-    public static final AssemblyTemplate ASSEMBLY1 =
-            AssemblyTemplate.builder()
-                .name("WebAppAssembly1")
-                .description("Mock Web App Assembly Template")
-                .applicationComponentTemplates(BasicResourceLookup.of(WAR))
-                .instantiator(MockAssemblyTemplateInstantiator.class)
-                .build();
-
-    public static final PdpMatcher WAR_GETS_WAR_MATCHER = new PdpMatcher.ArtifactMatcher("com.java:WAR") {
-        public boolean apply(Object art, AssemblyTemplateConstructor atc) {
-            ApplicationComponentTemplate act = ApplicationComponentTemplate.builder()
-                    .name( ((Artifact)art).getName() )
-                    .description( ((Artifact)art).getDescription() )
-                    .customAttribute("implementation", WAR.getName())
-                    .customAttribute("artifactType", ((Artifact)art).getArtifactType())
-                    .build();
-
-            // TODO requirements, etc
-            
-            atc.add(act);
-            
-            return true;
-        }
-    };
-
-    public static final PdpMatcher newLiteralServiceTypeToPlatformComponentTemplateMatcher(final BasicCampPlatform platform, @Nullable final Class<? extends AssemblyTemplateInstantiator> instantiator) {
-        return new PdpMatcher() {
-            public boolean apply(Object item, AssemblyTemplateConstructor atc) {
-                if (!(item instanceof Service)) return false;
-                Service svc = (Service)item;
-                String type = svc.getServiceType();
-                
-                for (ResolvableLink<PlatformComponentTemplate> t: platform.platformComponentTemplates().links()) {
-                    if (type.equals(t.getName())) {
-                        PlatformComponentTemplate pct = PlatformComponentTemplate.builder()
-                            .name(svc.getName())
-                            .customAttribute("serviceType", type)
-                            .description(Maybe.fromNullable(svc.getDescription()).or(t.resolve().getDescription()))
-                            .build();
-                        if (atc!=null) {
-                            atc.add(pct);
-                            if (instantiator!=null)
-                                atc.instantiator(instantiator);
-                        }
-                        return true;
-                    }
-                }
-                return false;
-            }
-
-            @Override
-            public boolean accepts(Object deploymentPlanItem) {
-                return apply(deploymentPlanItem, null);
-            }
-        };
-    }
-    
-    public static <T extends BasicCampPlatform> T populate(T platform) {
-        return populate(platform, null);
-    }
-    public static <T extends BasicCampPlatform> T populate(T platform, @Nullable Class<? extends AssemblyTemplateInstantiator> instantiator) {
-        platform.platformComponentTemplates().addAll(APPSERVER, DATABASE);
-        platform.applicationComponentTemplates().add(WAR);
-        platform.assemblyTemplates().add(ASSEMBLY1);
-        
-        platform.pdp().addMatcher(WAR_GETS_WAR_MATCHER);
-        platform.pdp().addMatcher(newLiteralServiceTypeToPlatformComponentTemplateMatcher(platform, instantiator));
-        
-        return platform;
-    }
-
-    public static BasicCampPlatform newPlatform() {
-        return MockWebPlatform.populate(new BasicCampPlatform());
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/test/java/io/brooklyn/camp/test/platform/BasicCampPlatformTest.java
----------------------------------------------------------------------
diff --git a/camp/camp-base/src/test/java/io/brooklyn/camp/test/platform/BasicCampPlatformTest.java b/camp/camp-base/src/test/java/io/brooklyn/camp/test/platform/BasicCampPlatformTest.java
deleted file mode 100644
index d92bece..0000000
--- a/camp/camp-base/src/test/java/io/brooklyn/camp/test/platform/BasicCampPlatformTest.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * 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 io.brooklyn.camp.test.platform;
-
-import io.brooklyn.camp.BasicCampPlatform;
-import io.brooklyn.camp.spi.AbstractResource;
-import io.brooklyn.camp.spi.ApplicationComponentTemplate;
-import io.brooklyn.camp.spi.PlatformComponentTemplate;
-import io.brooklyn.camp.spi.collection.ResolvableLink;
-import io.brooklyn.camp.test.mock.web.MockWebPlatform;
-
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-public class BasicCampPlatformTest {
-
-    @Test
-    public void testEmptyPlatform() {
-        BasicCampPlatform p = new BasicCampPlatform();
-        assertResourceFieldsNotNull(p.root());
-        Assert.assertEquals(p.platformComponentTemplates().links().size(), 0);
-    }        
-
-    @Test
-    public void testWebPctSetup() {
-        BasicCampPlatform p = new BasicCampPlatform();
-        p.platformComponentTemplates().add(MockWebPlatform.APPSERVER);
-        
-        assertResourceFieldsNotNull(p.root());
-        
-        Assert.assertEquals(p.platformComponentTemplates().links().size(), 1);
-        ResolvableLink<PlatformComponentTemplate> l = p.platformComponentTemplates().links().get(0);
-        assertLinkFieldsNotNull(l);
-        Assert.assertEquals(l.getName(), "io.camp.mock:AppServer");
-        
-        PlatformComponentTemplate pct = l.resolve();
-        assertResourceFieldsNotNull(pct);
-    }        
-
-    @Test
-    public void testWarActSetup() {
-        BasicCampPlatform p = new BasicCampPlatform();
-        p.applicationComponentTemplates().add(MockWebPlatform.WAR);
-        
-        assertResourceFieldsNotNull(p.root());
-        
-        Assert.assertEquals(p.platformComponentTemplates().links().size(), 0);
-        Assert.assertEquals(p.applicationComponentTemplates().links().size(), 1);
-        ResolvableLink<ApplicationComponentTemplate> l = p.applicationComponentTemplates().links().get(0);
-        assertLinkFieldsNotNull(l);
-        Assert.assertEquals(l.getName(), "io.camp.mock:WAR");
-        
-        ApplicationComponentTemplate act = l.resolve();
-        assertResourceFieldsNotNull(act);
-    }        
-
-
-    public static void assertLinkFieldsNotNull(ResolvableLink<?> x) {
-        Assert.assertNotNull(x.getId());
-        Assert.assertNotNull(x.getName());
-    }
-
-    public static void assertResourceFieldsNotNull(AbstractResource x) {
-        Assert.assertNotNull(x.getId());
-        Assert.assertNotNull(x.getType());
-        Assert.assertNotNull(x.getCreated());
-        Assert.assertNotNull(x.getName());
-        Assert.assertNotNull(x.getTags());
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/test/java/org/apache/brooklyn/camp/spi/pdp/DeploymentPlanToyInterpreterTest.java
----------------------------------------------------------------------
diff --git a/camp/camp-base/src/test/java/org/apache/brooklyn/camp/spi/pdp/DeploymentPlanToyInterpreterTest.java b/camp/camp-base/src/test/java/org/apache/brooklyn/camp/spi/pdp/DeploymentPlanToyInterpreterTest.java
new file mode 100644
index 0000000..c87641f
--- /dev/null
+++ b/camp/camp-base/src/test/java/org/apache/brooklyn/camp/spi/pdp/DeploymentPlanToyInterpreterTest.java
@@ -0,0 +1,113 @@
+/*
+ * 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.brooklyn.camp.spi.pdp;
+
+import java.util.Map;
+
+import org.apache.brooklyn.camp.BasicCampPlatform;
+import org.apache.brooklyn.camp.spi.resolve.PlanInterpreter.PlanInterpreterAdapter;
+import org.apache.brooklyn.camp.spi.resolve.interpret.PlanInterpretationNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import brooklyn.util.stream.Streams;
+import brooklyn.util.text.Strings;
+import brooklyn.util.yaml.Yamls;
+
+@Test
+public class DeploymentPlanToyInterpreterTest {
+
+    private static final Logger log = LoggerFactory.getLogger(DeploymentPlanToyInterpreterTest.class);
+    
+    /**
+     * Allows testing:
+     * 
+     * $sample:foo becomes "bar"
+     * $sample:caps:x capitalises the argument x
+     * $sample:ignore as key causes key-value to be dropped (and value 0 for good measure)
+     * $sample:reset causes containing map or list to be cleared at that point
+     * $sample:remove as key causes argument as map to be dropped
+     */
+    public static class ToyInterpreter extends PlanInterpreterAdapter {
+        
+        @Override
+        public boolean isInterestedIn(PlanInterpretationNode node) {
+            return node.matchesPrefix("$sample:");
+        }
+        
+        @Override
+        public void applyYamlPrimitive(PlanInterpretationNode node) {
+            if (node.matchesLiteral("$sample:foo")) node.setNewValue("bar").exclude();
+            if (node.matchesPrefix("$sample:caps:")) {
+                node.setNewValue(Strings.removeFromStart(node.getNewValue().toString(), "$sample:caps:").toUpperCase()).exclude();
+            }
+        }
+
+        @Override
+        public boolean applyMapBefore(PlanInterpretationNode node, Map<Object, Object> mapIn) {
+            if (node.matchesLiteral("$sample:ignore"))
+                // replace
+                mapIn.put("$sample:ignore", 0);
+            return super.applyMapBefore(node, mapIn);
+        }
+        
+        @Override
+        public boolean applyMapEntry(PlanInterpretationNode node, Map<Object, Object> mapIn, Map<Object, Object> mapOut,
+                                PlanInterpretationNode key, PlanInterpretationNode value) {
+            if (key.matchesLiteral("$sample:ignore")) {
+                Assert.assertEquals(value.getNewValue(), 0);
+                return false;
+            }
+            if (key.matchesLiteral("$sample:reset")) {
+                mapOut.clear();
+                return false;
+            }
+            
+            return super.applyMapEntry(node, mapIn, mapOut, key, value);
+        }
+
+        @SuppressWarnings("rawtypes")
+        @Override
+        public void applyMapAfter(PlanInterpretationNode node, Map<Object, Object> mapIn, Map<Object, Object> mapOut) {
+            if (mapOut.containsKey("$sample:remove")) {
+                Map toRemove = (Map) mapOut.get("$sample:remove");
+                for (Object vv: toRemove.keySet()) mapOut.remove(vv);
+                mapOut.remove("$sample:remove");
+            }
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    public void testToyInterpreter() {
+        @SuppressWarnings("rawtypes")
+        Map y1 = Yamls.getAs( Yamls.parseAll( Streams.reader(getClass().getResourceAsStream("yaml-sample-toy-interpreter.yaml"))), Map.class );
+        log.info("pre-interpreter have: "+y1);
+        
+        BasicCampPlatform p = new BasicCampPlatform();
+        p.pdp().addInterpreter(new ToyInterpreter());
+        Map<String, Object> y2 = p.pdp().applyInterpreters(y1);
+        log.info("interpreter gives: "+y2);
+        
+        Map<String, Object> y3 = Yamls.getAs( Yamls.parseAll( Streams.reader(getClass().getResourceAsStream("yaml-sample-toy-interpreter-result.yaml"))), Map.class );
+        Assert.assertEquals(y2, y3);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/test/java/org/apache/brooklyn/camp/spi/pdp/PdpYamlTest.java
----------------------------------------------------------------------
diff --git a/camp/camp-base/src/test/java/org/apache/brooklyn/camp/spi/pdp/PdpYamlTest.java b/camp/camp-base/src/test/java/org/apache/brooklyn/camp/spi/pdp/PdpYamlTest.java
new file mode 100644
index 0000000..8cb88e0
--- /dev/null
+++ b/camp/camp-base/src/test/java/org/apache/brooklyn/camp/spi/pdp/PdpYamlTest.java
@@ -0,0 +1,80 @@
+/*
+ * 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.brooklyn.camp.spi.pdp;
+
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+
+import org.apache.brooklyn.camp.BasicCampPlatform;
+import org.apache.brooklyn.camp.spi.AssemblyTemplate;
+import org.apache.brooklyn.camp.spi.pdp.Artifact;
+import org.apache.brooklyn.camp.spi.pdp.DeploymentPlan;
+import org.apache.brooklyn.camp.spi.pdp.Service;
+import org.apache.brooklyn.camp.test.mock.web.MockWebPlatform;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import brooklyn.util.stream.Streams;
+
+public class PdpYamlTest {
+
+    private static final Logger log = LoggerFactory.getLogger(PdpYamlTest.class);
+    
+    @Test
+    public void testSimpleYamlArtifactParse() throws IOException {
+        BasicCampPlatform platform = MockWebPlatform.populate(new BasicCampPlatform());
+        Reader input = Streams.reader(getClass().getResourceAsStream("pdp-single-artifact.yaml"));
+        DeploymentPlan plan = platform.pdp().parseDeploymentPlan(input);
+        log.info("DP is:\n"+plan.toString());
+        Assert.assertEquals(plan.getName(), "sample");
+        Assert.assertEquals(plan.getArtifacts().size(), 1);
+        Assert.assertEquals(plan.getServices().size(), 0);
+        
+        Artifact artifact1 = plan.getArtifacts().iterator().next();
+        Assert.assertEquals(artifact1.getName(), "sample WAR");
+    }
+    
+    @Test
+    public void testSimpleYamlServiceParse() throws IOException {
+        BasicCampPlatform platform = MockWebPlatform.populate(new BasicCampPlatform());
+        Reader input = Streams.reader(getClass().getResourceAsStream("pdp-single-service.yaml"));
+        DeploymentPlan plan = platform.pdp().parseDeploymentPlan(input);
+        log.info("DP is:\n"+plan.toString());
+        Assert.assertEquals(plan.getName(), "sample");
+        Assert.assertEquals(plan.getArtifacts().size(), 0);
+        Assert.assertEquals(plan.getServices().size(), 1);
+        
+        Service service1 = plan.getServices().iterator().next();
+        Assert.assertEquals(service1.getName(), "Hello WAR");
+    }
+    
+    @Test
+    public void testSimpleYamlMatch() throws IOException {
+        BasicCampPlatform platform = MockWebPlatform.populate(new BasicCampPlatform());
+        Reader input = new InputStreamReader(getClass().getResourceAsStream("pdp-single-artifact.yaml"));
+        AssemblyTemplate at = platform.pdp().registerDeploymentPlan(input);
+        log.info("AT is:\n"+at.toString());
+        Assert.assertEquals(at.getApplicationComponentTemplates().links().size(), 1);
+        Assert.assertEquals(at.getName(), "sample");
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/test/java/org/apache/brooklyn/camp/test/mock/web/MockAssemblyTemplateInstantiator.java
----------------------------------------------------------------------
diff --git a/camp/camp-base/src/test/java/org/apache/brooklyn/camp/test/mock/web/MockAssemblyTemplateInstantiator.java b/camp/camp-base/src/test/java/org/apache/brooklyn/camp/test/mock/web/MockAssemblyTemplateInstantiator.java
new file mode 100644
index 0000000..a358eed
--- /dev/null
+++ b/camp/camp-base/src/test/java/org/apache/brooklyn/camp/test/mock/web/MockAssemblyTemplateInstantiator.java
@@ -0,0 +1,37 @@
+/*
+ * 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.brooklyn.camp.test.mock.web;
+
+import org.apache.brooklyn.camp.CampPlatform;
+import org.apache.brooklyn.camp.spi.Assembly;
+import org.apache.brooklyn.camp.spi.AssemblyTemplate;
+import org.apache.brooklyn.camp.spi.instantiate.AssemblyTemplateInstantiator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class MockAssemblyTemplateInstantiator implements AssemblyTemplateInstantiator {
+
+    private static final Logger log = LoggerFactory.getLogger(MockAssemblyTemplateInstantiator.class);
+    
+    public Assembly instantiate(AssemblyTemplate template, CampPlatform platform) {
+        log.debug("Ignoring request to instantiate "+template);
+        return null;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/test/java/org/apache/brooklyn/camp/test/mock/web/MockWebPlatform.java
----------------------------------------------------------------------
diff --git a/camp/camp-base/src/test/java/org/apache/brooklyn/camp/test/mock/web/MockWebPlatform.java b/camp/camp-base/src/test/java/org/apache/brooklyn/camp/test/mock/web/MockWebPlatform.java
new file mode 100644
index 0000000..29aabd3
--- /dev/null
+++ b/camp/camp-base/src/test/java/org/apache/brooklyn/camp/test/mock/web/MockWebPlatform.java
@@ -0,0 +1,132 @@
+/*
+ * 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.brooklyn.camp.test.mock.web;
+
+import javax.annotation.Nullable;
+
+import org.apache.brooklyn.camp.BasicCampPlatform;
+import org.apache.brooklyn.camp.spi.ApplicationComponentTemplate;
+import org.apache.brooklyn.camp.spi.AssemblyTemplate;
+import org.apache.brooklyn.camp.spi.PlatformComponentTemplate;
+import org.apache.brooklyn.camp.spi.collection.BasicResourceLookup;
+import org.apache.brooklyn.camp.spi.collection.ResolvableLink;
+import org.apache.brooklyn.camp.spi.instantiate.AssemblyTemplateInstantiator;
+import org.apache.brooklyn.camp.spi.pdp.Artifact;
+import org.apache.brooklyn.camp.spi.pdp.AssemblyTemplateConstructor;
+import org.apache.brooklyn.camp.spi.pdp.Service;
+import org.apache.brooklyn.camp.spi.resolve.PdpMatcher;
+
+import brooklyn.util.guava.Maybe;
+
+public class MockWebPlatform {
+
+    public static final ApplicationComponentTemplate WAR = 
+            ApplicationComponentTemplate.builder()
+                .name("io.camp.mock:WAR")
+                .description("Mock WAR")
+                .build();
+
+    public static final PlatformComponentTemplate APPSERVER = 
+            PlatformComponentTemplate.builder()
+                .name("io.camp.mock:AppServer")
+                .description("Mock Application Server")
+                .build();
+
+    public static final PlatformComponentTemplate DATABASE = 
+            PlatformComponentTemplate.builder()
+                .name("io.camp.mock:Database")
+                .description("Mock Database")
+                .build();
+
+    public static final AssemblyTemplate ASSEMBLY1 =
+            AssemblyTemplate.builder()
+                .name("WebAppAssembly1")
+                .description("Mock Web App Assembly Template")
+                .applicationComponentTemplates(BasicResourceLookup.of(WAR))
+                .instantiator(MockAssemblyTemplateInstantiator.class)
+                .build();
+
+    public static final PdpMatcher WAR_GETS_WAR_MATCHER = new PdpMatcher.ArtifactMatcher("com.java:WAR") {
+        public boolean apply(Object art, AssemblyTemplateConstructor atc) {
+            ApplicationComponentTemplate act = ApplicationComponentTemplate.builder()
+                    .name( ((Artifact)art).getName() )
+                    .description( ((Artifact)art).getDescription() )
+                    .customAttribute("implementation", WAR.getName())
+                    .customAttribute("artifactType", ((Artifact)art).getArtifactType())
+                    .build();
+
+            // TODO requirements, etc
+            
+            atc.add(act);
+            
+            return true;
+        }
+    };
+
+    public static final PdpMatcher newLiteralServiceTypeToPlatformComponentTemplateMatcher(final BasicCampPlatform platform, @Nullable final Class<? extends AssemblyTemplateInstantiator> instantiator) {
+        return new PdpMatcher() {
+            public boolean apply(Object item, AssemblyTemplateConstructor atc) {
+                if (!(item instanceof Service)) return false;
+                Service svc = (Service)item;
+                String type = svc.getServiceType();
+                
+                for (ResolvableLink<PlatformComponentTemplate> t: platform.platformComponentTemplates().links()) {
+                    if (type.equals(t.getName())) {
+                        PlatformComponentTemplate pct = PlatformComponentTemplate.builder()
+                            .name(svc.getName())
+                            .customAttribute("serviceType", type)
+                            .description(Maybe.fromNullable(svc.getDescription()).or(t.resolve().getDescription()))
+                            .build();
+                        if (atc!=null) {
+                            atc.add(pct);
+                            if (instantiator!=null)
+                                atc.instantiator(instantiator);
+                        }
+                        return true;
+                    }
+                }
+                return false;
+            }
+
+            @Override
+            public boolean accepts(Object deploymentPlanItem) {
+                return apply(deploymentPlanItem, null);
+            }
+        };
+    }
+    
+    public static <T extends BasicCampPlatform> T populate(T platform) {
+        return populate(platform, null);
+    }
+    public static <T extends BasicCampPlatform> T populate(T platform, @Nullable Class<? extends AssemblyTemplateInstantiator> instantiator) {
+        platform.platformComponentTemplates().addAll(APPSERVER, DATABASE);
+        platform.applicationComponentTemplates().add(WAR);
+        platform.assemblyTemplates().add(ASSEMBLY1);
+        
+        platform.pdp().addMatcher(WAR_GETS_WAR_MATCHER);
+        platform.pdp().addMatcher(newLiteralServiceTypeToPlatformComponentTemplateMatcher(platform, instantiator));
+        
+        return platform;
+    }
+
+    public static BasicCampPlatform newPlatform() {
+        return MockWebPlatform.populate(new BasicCampPlatform());
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/test/java/org/apache/brooklyn/camp/test/platform/BasicCampPlatformTest.java
----------------------------------------------------------------------
diff --git a/camp/camp-base/src/test/java/org/apache/brooklyn/camp/test/platform/BasicCampPlatformTest.java b/camp/camp-base/src/test/java/org/apache/brooklyn/camp/test/platform/BasicCampPlatformTest.java
new file mode 100644
index 0000000..ccebaa6
--- /dev/null
+++ b/camp/camp-base/src/test/java/org/apache/brooklyn/camp/test/platform/BasicCampPlatformTest.java
@@ -0,0 +1,86 @@
+/*
+ * 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.brooklyn.camp.test.platform;
+
+import org.apache.brooklyn.camp.BasicCampPlatform;
+import org.apache.brooklyn.camp.spi.AbstractResource;
+import org.apache.brooklyn.camp.spi.ApplicationComponentTemplate;
+import org.apache.brooklyn.camp.spi.PlatformComponentTemplate;
+import org.apache.brooklyn.camp.spi.collection.ResolvableLink;
+import org.apache.brooklyn.camp.test.mock.web.MockWebPlatform;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public class BasicCampPlatformTest {
+
+    @Test
+    public void testEmptyPlatform() {
+        BasicCampPlatform p = new BasicCampPlatform();
+        assertResourceFieldsNotNull(p.root());
+        Assert.assertEquals(p.platformComponentTemplates().links().size(), 0);
+    }        
+
+    @Test
+    public void testWebPctSetup() {
+        BasicCampPlatform p = new BasicCampPlatform();
+        p.platformComponentTemplates().add(MockWebPlatform.APPSERVER);
+        
+        assertResourceFieldsNotNull(p.root());
+        
+        Assert.assertEquals(p.platformComponentTemplates().links().size(), 1);
+        ResolvableLink<PlatformComponentTemplate> l = p.platformComponentTemplates().links().get(0);
+        assertLinkFieldsNotNull(l);
+        Assert.assertEquals(l.getName(), "io.camp.mock:AppServer");
+        
+        PlatformComponentTemplate pct = l.resolve();
+        assertResourceFieldsNotNull(pct);
+    }        
+
+    @Test
+    public void testWarActSetup() {
+        BasicCampPlatform p = new BasicCampPlatform();
+        p.applicationComponentTemplates().add(MockWebPlatform.WAR);
+        
+        assertResourceFieldsNotNull(p.root());
+        
+        Assert.assertEquals(p.platformComponentTemplates().links().size(), 0);
+        Assert.assertEquals(p.applicationComponentTemplates().links().size(), 1);
+        ResolvableLink<ApplicationComponentTemplate> l = p.applicationComponentTemplates().links().get(0);
+        assertLinkFieldsNotNull(l);
+        Assert.assertEquals(l.getName(), "io.camp.mock:WAR");
+        
+        ApplicationComponentTemplate act = l.resolve();
+        assertResourceFieldsNotNull(act);
+    }        
+
+
+    public static void assertLinkFieldsNotNull(ResolvableLink<?> x) {
+        Assert.assertNotNull(x.getId());
+        Assert.assertNotNull(x.getName());
+    }
+
+    public static void assertResourceFieldsNotNull(AbstractResource x) {
+        Assert.assertNotNull(x.getId());
+        Assert.assertNotNull(x.getType());
+        Assert.assertNotNull(x.getCreated());
+        Assert.assertNotNull(x.getName());
+        Assert.assertNotNull(x.getTags());
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/test/resources/io/brooklyn/camp/spi/pdp/pdp-single-artifact.yaml
----------------------------------------------------------------------
diff --git a/camp/camp-base/src/test/resources/io/brooklyn/camp/spi/pdp/pdp-single-artifact.yaml b/camp/camp-base/src/test/resources/io/brooklyn/camp/spi/pdp/pdp-single-artifact.yaml
deleted file mode 100644
index 0b4518b..0000000
--- a/camp/camp-base/src/test/resources/io/brooklyn/camp/spi/pdp/pdp-single-artifact.yaml
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# 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.
-#
-name: sample
-description: Tomcat sample JSP and servlet application.
-origin: http://www.oracle.com/nCAMP/Hand
-artifacts:
-  -
-    type: com.java:WAR
-    content: { href: sample.war }
-    name: sample WAR
-    description: Tomcat sample WAR file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/test/resources/io/brooklyn/camp/spi/pdp/pdp-single-service.yaml
----------------------------------------------------------------------
diff --git a/camp/camp-base/src/test/resources/io/brooklyn/camp/spi/pdp/pdp-single-service.yaml b/camp/camp-base/src/test/resources/io/brooklyn/camp/spi/pdp/pdp-single-service.yaml
deleted file mode 100644
index fe052d6..0000000
--- a/camp/camp-base/src/test/resources/io/brooklyn/camp/spi/pdp/pdp-single-service.yaml
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# 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.
-#
-name: sample
-description: Tomcat sample JSP and servlet application.
-origin: http://www.oracle.com/nCAMP/Hand
-services:
-  -
-    type: brooklyn:WebAppCluster
-    name: Hello WAR
-    wars:
-        /: hello.war
-    controller.spec:
-        port: 80

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/test/resources/io/brooklyn/camp/spi/pdp/yaml-sample-toy-interpreter-result.yaml
----------------------------------------------------------------------
diff --git a/camp/camp-base/src/test/resources/io/brooklyn/camp/spi/pdp/yaml-sample-toy-interpreter-result.yaml b/camp/camp-base/src/test/resources/io/brooklyn/camp/spi/pdp/yaml-sample-toy-interpreter-result.yaml
deleted file mode 100644
index 71b0ba8..0000000
--- a/camp/camp-base/src/test/resources/io/brooklyn/camp/spi/pdp/yaml-sample-toy-interpreter-result.yaml
+++ /dev/null
@@ -1,22 +0,0 @@
-#
-# 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.
-#
-keep: 1
-mess:
-  a: bar
-  b: [ c, D ]

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/test/resources/io/brooklyn/camp/spi/pdp/yaml-sample-toy-interpreter.yaml
----------------------------------------------------------------------
diff --git a/camp/camp-base/src/test/resources/io/brooklyn/camp/spi/pdp/yaml-sample-toy-interpreter.yaml b/camp/camp-base/src/test/resources/io/brooklyn/camp/spi/pdp/yaml-sample-toy-interpreter.yaml
deleted file mode 100644
index 8aa01d2..0000000
--- a/camp/camp-base/src/test/resources/io/brooklyn/camp/spi/pdp/yaml-sample-toy-interpreter.yaml
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# 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.
-#
-$sample:ignore: 1
-keep: 1
-mess:
-  2: z
-  $sample:reset: 
-  $sample:ignore: z
-  a: $sample:foo
-  b: [ c, "$sample:caps:d" ]
-  3: $sample:caps:x
-  $sample:remove: {3: X}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/test/resources/org/apache/brooklyn/camp/spi/pdp/pdp-single-artifact.yaml
----------------------------------------------------------------------
diff --git a/camp/camp-base/src/test/resources/org/apache/brooklyn/camp/spi/pdp/pdp-single-artifact.yaml b/camp/camp-base/src/test/resources/org/apache/brooklyn/camp/spi/pdp/pdp-single-artifact.yaml
new file mode 100644
index 0000000..0b4518b
--- /dev/null
+++ b/camp/camp-base/src/test/resources/org/apache/brooklyn/camp/spi/pdp/pdp-single-artifact.yaml
@@ -0,0 +1,27 @@
+#
+# 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.
+#
+name: sample
+description: Tomcat sample JSP and servlet application.
+origin: http://www.oracle.com/nCAMP/Hand
+artifacts:
+  -
+    type: com.java:WAR
+    content: { href: sample.war }
+    name: sample WAR
+    description: Tomcat sample WAR file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/test/resources/org/apache/brooklyn/camp/spi/pdp/pdp-single-service.yaml
----------------------------------------------------------------------
diff --git a/camp/camp-base/src/test/resources/org/apache/brooklyn/camp/spi/pdp/pdp-single-service.yaml b/camp/camp-base/src/test/resources/org/apache/brooklyn/camp/spi/pdp/pdp-single-service.yaml
new file mode 100644
index 0000000..fe052d6
--- /dev/null
+++ b/camp/camp-base/src/test/resources/org/apache/brooklyn/camp/spi/pdp/pdp-single-service.yaml
@@ -0,0 +1,29 @@
+#
+# 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.
+#
+name: sample
+description: Tomcat sample JSP and servlet application.
+origin: http://www.oracle.com/nCAMP/Hand
+services:
+  -
+    type: brooklyn:WebAppCluster
+    name: Hello WAR
+    wars:
+        /: hello.war
+    controller.spec:
+        port: 80

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/test/resources/org/apache/brooklyn/camp/spi/pdp/yaml-sample-toy-interpreter-result.yaml
----------------------------------------------------------------------
diff --git a/camp/camp-base/src/test/resources/org/apache/brooklyn/camp/spi/pdp/yaml-sample-toy-interpreter-result.yaml b/camp/camp-base/src/test/resources/org/apache/brooklyn/camp/spi/pdp/yaml-sample-toy-interpreter-result.yaml
new file mode 100644
index 0000000..71b0ba8
--- /dev/null
+++ b/camp/camp-base/src/test/resources/org/apache/brooklyn/camp/spi/pdp/yaml-sample-toy-interpreter-result.yaml
@@ -0,0 +1,22 @@
+#
+# 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.
+#
+keep: 1
+mess:
+  a: bar
+  b: [ c, D ]

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-base/src/test/resources/org/apache/brooklyn/camp/spi/pdp/yaml-sample-toy-interpreter.yaml
----------------------------------------------------------------------
diff --git a/camp/camp-base/src/test/resources/org/apache/brooklyn/camp/spi/pdp/yaml-sample-toy-interpreter.yaml b/camp/camp-base/src/test/resources/org/apache/brooklyn/camp/spi/pdp/yaml-sample-toy-interpreter.yaml
new file mode 100644
index 0000000..8aa01d2
--- /dev/null
+++ b/camp/camp-base/src/test/resources/org/apache/brooklyn/camp/spi/pdp/yaml-sample-toy-interpreter.yaml
@@ -0,0 +1,28 @@
+#
+# 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.
+#
+$sample:ignore: 1
+keep: 1
+mess:
+  2: z
+  $sample:reset: 
+  $sample:ignore: z
+  a: $sample:foo
+  b: [ c, "$sample:caps:d" ]
+  3: $sample:caps:x
+  $sample:remove: {3: X}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7d782f34/camp/camp-server/src/main/java/io/brooklyn/camp/CampRestResources.java
----------------------------------------------------------------------
diff --git a/camp/camp-server/src/main/java/io/brooklyn/camp/CampRestResources.java b/camp/camp-server/src/main/java/io/brooklyn/camp/CampRestResources.java
deleted file mode 100644
index 830f646..0000000
--- a/camp/camp-server/src/main/java/io/brooklyn/camp/CampRestResources.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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 io.brooklyn.camp;
-
-import io.brooklyn.camp.rest.resource.AbstractCampRestResource;
-import io.brooklyn.camp.rest.resource.ApidocRestResource;
-import io.brooklyn.camp.rest.resource.ApplicationComponentRestResource;
-import io.brooklyn.camp.rest.resource.ApplicationComponentTemplateRestResource;
-import io.brooklyn.camp.rest.resource.AssemblyRestResource;
-import io.brooklyn.camp.rest.resource.AssemblyTemplateRestResource;
-import io.brooklyn.camp.rest.resource.PlatformComponentRestResource;
-import io.brooklyn.camp.rest.resource.PlatformComponentTemplateRestResource;
-import io.brooklyn.camp.rest.resource.PlatformRestResource;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.brooklyn.rest.apidoc.ApidocHelpMessageBodyWriter;
-
-import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
-import com.google.common.collect.Iterables;
-
-public class CampRestResources {
-
-    public static Iterable<AbstractCampRestResource> getCampRestResources() {
-        List<AbstractCampRestResource> resources = new ArrayList<AbstractCampRestResource>();
-        resources.add(new PlatformRestResource());
-        resources.add(new AssemblyTemplateRestResource());
-        resources.add(new PlatformComponentTemplateRestResource());
-        resources.add(new ApplicationComponentTemplateRestResource());
-        resources.add(new AssemblyRestResource());
-        resources.add(new PlatformComponentRestResource());
-        resources.add(new ApplicationComponentRestResource());
-        return resources;
-    }
-
-    public static Iterable<Object> getApidocResources() {
-        List<Object> resources = new ArrayList<Object>();
-        resources.add(new ApidocHelpMessageBodyWriter());
-        resources.add(new ApidocRestResource());
-        return resources;
-    }
-
-    public static Iterable<Object> getMiscResources() {
-        List<Object> resources = new ArrayList<Object>();
-        resources.add(new JacksonJsonProvider());
-        return resources;
-    }
-
-    public static Iterable<Object> getAllResources() {
-        return Iterables.concat(getCampRestResources(), getApidocResources(), getMiscResources());
-    }
-
-}


Mime
View raw message