You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2012/11/10 15:12:03 UTC

svn commit: r1407818 - in /camel/trunk/components/camel-test-blueprint/src: main/java/org/apache/camel/test/blueprint/ test/java/org/apache/camel/test/blueprint/ test/resources/org/apache/camel/test/blueprint/

Author: ningjiang
Date: Sat Nov 10 14:11:59 2012
New Revision: 1407818

URL: http://svn.apache.org/viewvc?rev=1407818&view=rev
Log:
CAMEL-5783 Added bundle directives in the generated test bundles by camel-test-blueprint with thanks to Aki

Added:
    camel/trunk/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/IgnoreDatatypesTest.java
    camel/trunk/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/ignoreDatatypes.xml
Modified:
    camel/trunk/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
    camel/trunk/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java

Modified: camel/trunk/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java?rev=1407818&r1=1407817&r2=1407818&view=diff
==============================================================================
--- camel/trunk/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java (original)
+++ camel/trunk/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java Sat Nov 10 14:11:59 2012
@@ -84,11 +84,16 @@ public final class CamelBlueprintHelper 
 
     public static BundleContext createBundleContext(String name, String descriptors, boolean includeTestBundle,
                                                     String bundleFilter, String testBundleVersion) throws Exception {
+        return createBundleContext(name, descriptors, includeTestBundle, bundleFilter, testBundleVersion, null);
+    }
+    
+    public static BundleContext createBundleContext(String name, String descriptors, boolean includeTestBundle,
+                                                    String bundleFilter, String testBundleVersion, String testBundleDirectives) throws Exception {
         TinyBundle bundle = null;
 
         if (includeTestBundle) {
             // add ourselves as a bundle
-            bundle = createTestBundle(name, testBundleVersion, descriptors);
+            bundle = createTestBundle(testBundleDirectives == null ? name : name + ';' + testBundleDirectives, testBundleVersion, descriptors);
         }
 
         return createBundleContext(name, bundleFilter, bundle);

Modified: camel/trunk/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java?rev=1407818&r1=1407817&r2=1407818&view=diff
==============================================================================
--- camel/trunk/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java (original)
+++ camel/trunk/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java Sat Nov 10 14:11:59 2012
@@ -39,7 +39,7 @@ public abstract class CamelBlueprintTest
     public void setUp() throws Exception {
         String symbolicName = getClass().getSimpleName();
         this.bundleContext = CamelBlueprintHelper.createBundleContext(symbolicName, getBlueprintDescriptor(),
-                true, getBundleFilter(), getBundleVersion());
+                true, getBundleFilter(), getBundleVersion(), getBundleDirectives());
 
         // must register override properties early in OSGi containers
         Properties extra = useOverridePropertiesWithPropertiesComponent();
@@ -102,6 +102,15 @@ public abstract class CamelBlueprintTest
         return CamelBlueprintHelper.BUNDLE_VERSION;
     }
 
+    /**
+     * Gets the bundle directives.
+     * Modify this method if you wish to add some directives.
+     * @return
+     */
+    protected String getBundleDirectives() {
+        return null;
+    }
+    
     @Override
     protected CamelContext createCamelContext() throws Exception {
         CamelContext answer = CamelBlueprintHelper.getOsgiService(bundleContext, CamelContext.class);

Added: camel/trunk/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/IgnoreDatatypesTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/IgnoreDatatypesTest.java?rev=1407818&view=auto
==============================================================================
--- camel/trunk/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/IgnoreDatatypesTest.java (added)
+++ camel/trunk/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/IgnoreDatatypesTest.java Sat Nov 10 14:11:59 2012
@@ -0,0 +1,45 @@
+/**
+ * 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.camel.test.blueprint;
+
+import org.junit.Test;
+
+/**
+ *
+ */
+public class IgnoreDatatypesTest extends CamelBlueprintTestSupport {
+
+    @Override
+    protected String getBlueprintDescriptor() {
+        return "org/apache/camel/test/blueprint/ignoreDatatypes.xml";
+    }
+
+    @Override
+    protected String getBundleDirectives() {
+        return "blueprint.aries.xml-validation:=false";
+    }
+
+    @Test
+    public void testConfigAdmin() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
+
+        template.sendBody("direct:start", "World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+}

Added: camel/trunk/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/ignoreDatatypes.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/ignoreDatatypes.xml?rev=1407818&view=auto
==============================================================================
--- camel/trunk/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/ignoreDatatypes.xml (added)
+++ camel/trunk/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/ignoreDatatypes.xml Sat Nov 10 14:11:59 2012
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+           xmlns:camel="http://camel.apache.org/schema/blueprint"
+           xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
+           xsi:schemaLocation="
+             http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.0.0.xsd
+             http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+
+  <!-- blueprint property placeholders -->
+  <cm:property-placeholder persistent-id="my-placeholders">
+    <cm:default-properties>
+      <cm:property name="level" value="INFO"/>
+    </cm:default-properties>
+  </cm:property-placeholder>
+
+  <camel:camelContext >
+    <camel:route>
+      <camel:from uri="direct:start"/>
+      <!-- use some syntactically constrained datatype such as int, boolean, enum, etc -->
+      <camel:log message="test" loggingLevel="${level}"/>
+      <camel:transform>
+        <camel:simple>Hello ${body}</camel:simple>
+      </camel:transform>
+      <camel:to uri="mock:result"/>
+    </camel:route>
+
+  </camel:camelContext>
+
+</blueprint>