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 2010/11/08 10:17:47 UTC

svn commit: r1032501 - in /camel/trunk: platforms/karaf/features/ tests/camel-itest-osgi/ tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/ tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/validator/ tests/came...

Author: ningjiang
Date: Mon Nov  8 09:17:45 2010
New Revision: 1032501

URL: http://svn.apache.org/viewvc?rev=1032501&view=rev
Log:
CAMEL-3227 added the Camel-bean-validator OSGi test with thanks to Johan

Added:
    camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/
    camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/validator/
    camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/validator/BeanValidatorTest.java   (with props)
    camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/validator/Car.java   (with props)
    camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/validator/CarWithAnnotations.java   (with props)
    camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/validator/CarWithoutAnnotations.java   (with props)
    camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/validator/OptionalChecks.java   (with props)
    camel/trunk/tests/camel-itest-osgi/src/test/resources/META-INF/validation.xml   (with props)
    camel/trunk/tests/camel-itest-osgi/src/test/resources/constraints-car.xml   (with props)
Modified:
    camel/trunk/platforms/karaf/features/pom.xml
    camel/trunk/tests/camel-itest-osgi/pom.xml

Modified: camel/trunk/platforms/karaf/features/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/platforms/karaf/features/pom.xml?rev=1032501&r1=1032500&r2=1032501&view=diff
==============================================================================
--- camel/trunk/platforms/karaf/features/pom.xml (original)
+++ camel/trunk/platforms/karaf/features/pom.xml Mon Nov  8 09:17:45 2010
@@ -108,7 +108,7 @@
       <rome-bundle-version>1.0_1</rome-bundle-version>
       <saxon-bundle-version>9.1.0.1_3</saxon-bundle-version>
       <scala-bundle-version>2.8.0_1</scala-bundle-version>
-      <servicemix-specs-version>1.5.0</servicemix-specs-version>
+      <servicemix-specs-version>1.6-SNAPSHOT</servicemix-specs-version>
       <jaxws.api.version>2.1</jaxws.api.version>
       <servlet-api-2.5-version>1.1.2</servlet-api-2.5-version>
       <serp-bundle-version>1.13.1_2</serp-bundle-version>

Modified: camel/trunk/tests/camel-itest-osgi/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/pom.xml?rev=1032501&r1=1032500&r2=1032501&view=diff
==============================================================================
--- camel/trunk/tests/camel-itest-osgi/pom.xml (original)
+++ camel/trunk/tests/camel-itest-osgi/pom.xml Mon Nov  8 09:17:45 2010
@@ -209,7 +209,11 @@
         <artifactId>org.apache.felix.configadmin</artifactId>
         <scope>test</scope>
     </dependency>
-
+    <dependency>
+        <groupId>org.apache.camel</groupId>
+        <artifactId>camel-bean-validator</artifactId>
+        <scope>test</scope>
+    </dependency>
       <dependency>
           <groupId>org.apache.camel</groupId>
           <artifactId>camel-cxf</artifactId>

Added: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/validator/BeanValidatorTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/validator/BeanValidatorTest.java?rev=1032501&view=auto
==============================================================================
--- camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/validator/BeanValidatorTest.java (added)
+++ camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/validator/BeanValidatorTest.java Mon Nov  8 09:17:45 2010
@@ -0,0 +1,92 @@
+/**
+ * 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.itest.osgi.bean.validator;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.itest.osgi.OSGiIntegrationTestSupport;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.swissbox.tinybundles.dp.Constants;
+
+import static org.ops4j.pax.exam.CoreOptions.equinox;
+import static org.ops4j.pax.exam.CoreOptions.felix;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.provision;
+import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.profile;
+import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.scanFeatures;
+import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.workingDirectory;
+import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.newBundle;
+import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.withBnd;
+
+@RunWith(JUnit4TestRunner.class)
+public class BeanValidatorTest extends OSGiIntegrationTestSupport {
+
+    @Test
+    public void testBeanValidatorRoute() throws Exception {
+        Exchange exchange = template.request("bean-validator://x", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setBody(createCar("BMW", "DD-AB-123"));
+            }
+        });
+
+        assertNotNull(exchange);
+    }
+
+    @Test
+    public void validateShouldSuccessWithExpliciteDefaultGroup() throws Exception {
+        Exchange exchange = template.request("bean-validator://x?group=javax.validation.groups.Default", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setBody(createCar("BMW", "DD-AB-123"));
+            }
+        });
+
+        assertNotNull(exchange);
+    }
+
+    Car createCar(String manufacturer, String licencePlate) {
+        return new CarWithAnnotations(manufacturer, licencePlate);
+    }
+
+    @Configuration
+    public static Option[] configure() {
+        Option[] options = options(
+                // install the spring dm profile
+                profile("spring.dm").version("1.2.0"),
+                // this is how you set the default log level when using pax logging (logProfile)
+                org.ops4j.pax.exam.CoreOptions.systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("DEBUG"),
+
+                // using the features to install the camel components
+                scanFeatures(getCamelKarafFeatureUrl(), "camel-core", "camel-test", "camel-bean-validator"),
+
+                //workingDirectory("target/paxrunner/"),
+                //provision(newBundle()
+                //        .add("META-INF/validation.xml", BeanValidatorTest.class.getClassLoader().getResource("META-INF/validation.xml"))
+                //        .add("constraints-car.xml", BeanValidatorTest.class.getClassLoader().getResource("constraints-car.xml"))
+                //        .set(Constants.BUNDLE_SYMBOLICNAME, "validation-fragment")
+                //        .set(Constants.FRAGMENT_HOST, "org.apache.servicemix.specs.jsr303-api-1.0.0")
+                //        .build(withBnd())),
+
+                felix(), equinox());
+
+        return options;
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/validator/BeanValidatorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/validator/BeanValidatorTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/validator/Car.java
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/validator/Car.java?rev=1032501&view=auto
==============================================================================
--- camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/validator/Car.java (added)
+++ camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/validator/Car.java Mon Nov  8 09:17:45 2010
@@ -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.
+ */
+
+package org.apache.camel.itest.osgi.bean.validator;
+
+public interface Car {
+
+    String getManufacturer();
+
+    void setManufacturer(String manufacturer);
+
+    String getLicensePlate();
+
+    void setLicensePlate(String licensePlate);
+}

Propchange: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/validator/Car.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/validator/Car.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/validator/CarWithAnnotations.java
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/validator/CarWithAnnotations.java?rev=1032501&view=auto
==============================================================================
--- camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/validator/CarWithAnnotations.java (added)
+++ camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/validator/CarWithAnnotations.java Mon Nov  8 09:17:45 2010
@@ -0,0 +1,53 @@
+/**
+ * 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.itest.osgi.bean.validator;
+
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+
+public class CarWithAnnotations implements Car {
+
+    @NotNull
+    private String manufacturer;
+
+    @NotNull
+    @Size(min = 5, max = 14, groups = OptionalChecks.class)
+    private String licensePlate;
+
+    public CarWithAnnotations(String manufacturer, String licencePlate) {
+        this.manufacturer = manufacturer;
+        this.licensePlate = licencePlate;
+    }
+
+    public String getManufacturer() {
+        return manufacturer;
+    }
+
+    public void setManufacturer(String manufacturer) {
+        this.manufacturer = manufacturer;
+    }
+
+    public String getLicensePlate() {
+        return licensePlate;
+    }
+
+    public void setLicensePlate(String licensePlate) {
+        this.licensePlate = licensePlate;
+    }
+}

Propchange: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/validator/CarWithAnnotations.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/validator/CarWithAnnotations.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/validator/CarWithoutAnnotations.java
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/validator/CarWithoutAnnotations.java?rev=1032501&view=auto
==============================================================================
--- camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/validator/CarWithoutAnnotations.java (added)
+++ camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/validator/CarWithoutAnnotations.java Mon Nov  8 09:17:45 2010
@@ -0,0 +1,46 @@
+/**
+ * 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.itest.osgi.bean.validator;
+
+public class CarWithoutAnnotations implements Car {
+
+    private String manufacturer;
+
+    private String licensePlate;
+
+    public CarWithoutAnnotations(String manufacturer, String licencePlate) {
+        this.manufacturer = manufacturer;
+        this.licensePlate = licencePlate;
+    }
+
+    public String getManufacturer() {
+        return manufacturer;
+    }
+
+    public void setManufacturer(String manufacturer) {
+        this.manufacturer = manufacturer;
+    }
+
+    public String getLicensePlate() {
+        return licensePlate;
+    }
+
+    public void setLicensePlate(String licensePlate) {
+        this.licensePlate = licensePlate;
+    }
+}

Propchange: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/validator/CarWithoutAnnotations.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/validator/CarWithoutAnnotations.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/validator/OptionalChecks.java
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/validator/OptionalChecks.java?rev=1032501&view=auto
==============================================================================
--- camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/validator/OptionalChecks.java (added)
+++ camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/validator/OptionalChecks.java Mon Nov  8 09:17:45 2010
@@ -0,0 +1,21 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance 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.itest.osgi.bean.validator;
+
+public interface OptionalChecks {
+}

Propchange: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/validator/OptionalChecks.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/bean/validator/OptionalChecks.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/tests/camel-itest-osgi/src/test/resources/META-INF/validation.xml
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/resources/META-INF/validation.xml?rev=1032501&view=auto
==============================================================================
--- camel/trunk/tests/camel-itest-osgi/src/test/resources/META-INF/validation.xml (added)
+++ camel/trunk/tests/camel-itest-osgi/src/test/resources/META-INF/validation.xml Mon Nov  8 09:17:45 2010
@@ -0,0 +1,27 @@
+<?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.
+-->
+<validation-config xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
+                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+                   xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configuration">
+
+    <default-provider>org.hibernate.validator.HibernateValidator</default-provider>
+    <message-interpolator>org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator</message-interpolator>
+    <traversable-resolver>org.hibernate.validator.engine.resolver.DefaultTraversableResolver</traversable-resolver>
+    <constraint-validator-factory>org.hibernate.validator.engine.ConstraintValidatorFactoryImpl</constraint-validator-factory>
+    <constraint-mapping>/constraints-car.xml</constraint-mapping>
+
+</validation-config>
\ No newline at end of file

Propchange: camel/trunk/tests/camel-itest-osgi/src/test/resources/META-INF/validation.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/tests/camel-itest-osgi/src/test/resources/META-INF/validation.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/tests/camel-itest-osgi/src/test/resources/META-INF/validation.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: camel/trunk/tests/camel-itest-osgi/src/test/resources/constraints-car.xml
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/resources/constraints-car.xml?rev=1032501&view=auto
==============================================================================
--- camel/trunk/tests/camel-itest-osgi/src/test/resources/constraints-car.xml (added)
+++ camel/trunk/tests/camel-itest-osgi/src/test/resources/constraints-car.xml Mon Nov  8 09:17:45 2010
@@ -0,0 +1,39 @@
+<?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.
+-->
+<constraint-mappings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/mapping validation-mapping-1.0.xsd"
+	xmlns="http://jboss.org/xml/ns/javax/validation/mapping">
+	<default-package>org.apache.camel.itest.osgi.bean.validator</default-package>
+
+	<bean class="CarWithoutAnnotations" ignore-annotations="true">
+		<field name="manufacturer">
+			<constraint annotation="javax.validation.constraints.NotNull" />
+		</field>
+
+		<field name="licensePlate">
+			<constraint annotation="javax.validation.constraints.NotNull" />
+
+			<constraint annotation="javax.validation.constraints.Size">
+				<groups>
+					<value>org.apache.camel.itest.osgi.bean.validator.OptionalChecks</value>
+				</groups>
+				<element name="min">5</element>
+				<element name="max">14</element>
+			</constraint>
+		</field>
+	</bean>
+</constraint-mappings>
\ No newline at end of file

Propchange: camel/trunk/tests/camel-itest-osgi/src/test/resources/constraints-car.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/tests/camel-itest-osgi/src/test/resources/constraints-car.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/tests/camel-itest-osgi/src/test/resources/constraints-car.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml