You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "f2par0 (via GitHub)" <gi...@apache.org> on 2024/07/17 07:53:47 UTC

[PR] Add camel-bean-validator integration test [camel-karaf]

f2par0 opened a new pull request, #435:
URL: https://github.com/apache/camel-karaf/pull/435

   camel-bean-validator integration test
   Fix the component to add the code that was previously in camel-bean-validator-osgi which registers a default validator factory (as the hibernate one).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add camel-bean-validator integration test [camel-karaf]

Posted by "essobedo (via GitHub)" <gi...@apache.org>.
essobedo merged PR #435:
URL: https://github.com/apache/camel-karaf/pull/435


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add camel-bean-validator integration test [camel-karaf]

Posted by "essobedo (via GitHub)" <gi...@apache.org>.
essobedo commented on code in PR #435:
URL: https://github.com/apache/camel-karaf/pull/435#discussion_r1680647254


##########
tests/features/camel-bean-validator/src/test/java/org/apache/karaf/camel/itest/CamelBeanValidatorITest.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed 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.karaf.camel.itest;
+
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.karaf.camel.itests.AbstractCamelSingleFeatureResultMockBasedRouteITest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class CamelBeanValidatorITest extends AbstractCamelSingleFeatureResultMockBasedRouteITest {
+
+    @Override
+    public void configureMock(MockEndpoint mock) {
+        mock.expectedBodiesReceived("User[name=John, age=90]");
+    }
+
+    @Test
+    public void testResultMock() throws Exception {
+        assertMockEndpointsSatisfied();
+    }
+
+    /*@Override
+    protected List<String> installRequiredBundles() throws Exception {
+        List<String> result = super.installRequiredBundles();
+        result.add("mvn:org.hibernate.validator/hibernate-validator/8.0.1.Final");
+        return result;
+    }*/

Review Comment:
   Can we remove it?



##########
components/camel-bean-validator/pom.xml:
##########
@@ -34,11 +34,12 @@
 
     <properties>
         <camel.osgi.export>
-            org.apache.camel*;version=${camel-version}
+            org.apache.camel.component.bean.validator*;version=${camel-version}
         </camel.osgi.export>
         <camel.osgi.import>
-            *
+            !org.apache.camel.component.bean.validator,*

Review Comment:
   Warning all camel related imports, are managed by `camel-osgi-camel-import`, this cannot work



##########
tests/features/camel-bean-validator/pom.xml:
##########
@@ -0,0 +1,40 @@
+<?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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.camel.karaf</groupId>
+        <artifactId>camel-karaf-features-test</artifactId>
+        <version>4.7.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>camel-bean-validator-test</artifactId>
+    <name>Apache Camel :: Karaf :: Tests :: Features :: BeanValidator</name>

Review Comment:
   ```suggestion
       <name>Apache Camel :: Karaf :: Tests :: Features :: Bean validator</name>
   ```



##########
components/camel-bean-validator/pom.xml:
##########
@@ -34,11 +34,12 @@
 
     <properties>
         <camel.osgi.export>
-            org.apache.camel*;version=${camel-version}
+            org.apache.camel.component.bean.validator*;version=${camel-version}
         </camel.osgi.export>
         <camel.osgi.import>
-            *
+            !org.apache.camel.component.bean.validator,*

Review Comment:
   Check https://github.com/apache/camel-karaf/blob/main/pom.xml#L689C43-L689C66 for more details



##########
tests/features/camel-bean-validator/src/main/java/org/apache/karaf/camel/test/CamelBeanValidatorRouteSupplier.java:
##########
@@ -0,0 +1,50 @@
+/*
+ * 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.karaf.camel.test;
+
+import static org.apache.camel.builder.Builder.constant;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.model.RouteDefinition;
+import org.apache.karaf.camel.itests.AbstractCamelSingleFeatureResultMockBasedRouteSupplier;
+import org.osgi.service.component.annotations.Component;
+
+import jakarta.validation.constraints.Min;
+import jakarta.validation.constraints.NotNull;
+
+@Component(
+        name = "karaf-camel-bean-validator-test",
+        immediate = true,
+        service = CamelBeanValidatorRouteSupplier.class
+)
+public class CamelBeanValidatorRouteSupplier extends AbstractCamelSingleFeatureResultMockBasedRouteSupplier {
+
+    public record User(@NotNull String name, @Min(18) int age) {}
+
+    @Override
+    protected boolean consumerEnabled() {
+        return false;
+    }
+
+    @Override
+    protected void configureProducer(RouteBuilder builder, RouteDefinition producerRoute) {
+        producerRoute.setBody(constant(new User("John",90)))

Review Comment:
   ```suggestion
           producerRoute.setBody(constant(new User("John", 90)))
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add camel-bean-validator integration test [camel-karaf]

Posted by "f2par0 (via GitHub)" <gi...@apache.org>.
f2par0 commented on code in PR #435:
URL: https://github.com/apache/camel-karaf/pull/435#discussion_r1680706859


##########
components/camel-bean-validator/pom.xml:
##########
@@ -34,11 +34,12 @@
 
     <properties>
         <camel.osgi.export>
-            org.apache.camel*;version=${camel-version}
+            org.apache.camel.component.bean.validator*;version=${camel-version}
         </camel.osgi.export>
         <camel.osgi.import>
-            *
+            !org.apache.camel.component.bean.validator,*

Review Comment:
   Ok,,I moved it to camel-osgi-camel-import
   This  `!org.apache.camel.component.bean.validator,` is to avoid to have it in the import-packages section of the Manifest, which  lead sometimes to exception like `OsgiValidationProviderResolverFactory cannot be cast to ValidationProviderResolverFactory`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org