stataru8 commented on code in PR #317:
URL: https://github.com/apache/camel-karaf/pull/317#discussion_r1625927319


##########
tooling/camel-karaf-feature-maven-plugin/src/test/java/org/apache/camel/karaf/feature/maven/EnsureWrapBundleVersionMojoTest.java:
##########
@@ -0,0 +1,142 @@
+/*
+ * 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.karaf.feature.maven;
+
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.junit.jupiter.api.Test;
+
+public class EnsureWrapBundleVersionMojoTest {
+
+    private final EnsureWrapBundleVersionMojo ensureVersionMojo = new 
EnsureWrapBundleVersionMojo();
+
+    @Test
+    void modifyLocationTest() throws Exception {
+        // add bundle version at the end
+        String location = "wrap:mvn:org.apache.olingo/odata-server-core/5.0.0";
+        String expected = 
"wrap:mvn:org.apache.olingo/odata-server-core/5.0.0$Bundle-Version=5.0.0";
+        assertEquals(expected, ensureVersionMojo.processLocation(location));
+
+        location = 
"wrap:mvn:org.apache.olingo/odata-server-core/5.0.0$overwrite=merge";
+        expected = 
"wrap:mvn:org.apache.olingo/odata-server-core/5.0.0$overwrite=merge&Bundle-Version=5.0.0";
+        assertEquals(expected, ensureVersionMojo.processLocation(location));
+
+        location = 
"wrap:mvn:org.apache.olingo/odata-server-core/5.0.0$overwrite=merge&Export-Package=org.apache.olingo.*;version=5.0.0";
+        expected = 
"wrap:mvn:org.apache.olingo/odata-server-core/5.0.0$overwrite=merge&Bundle-Version=5.0.0&Export-Package=org.apache.olingo.*;version=5.0.0";
+        assertEquals(expected, ensureVersionMojo.processLocation(location));
+
+        // original version won't work in the karaf container
+        location = 
"wrap:mvn:com.google.apis/google-api-services-storage/v1-rev20240209-2.0.0";
+        expected = 
"wrap:mvn:com.google.apis/google-api-services-storage/v1-rev20240209-2.0.0$Bundle-Version=0.0.0.v1-rev20240209-2_0_0";
+        assertEquals(expected, ensureVersionMojo.processLocation(location));
+
+        // bundle version header is present but it won't work in the karaf 
container
+        location = "mvn:commons-io/commons-io/2.15.1$Bundle-Version=2.15.0";
+        expected = "mvn:commons-io/commons-io/2.15.1$Bundle-Version=2.15.0";
+        ;

Review Comment:
   I added another test scenario instead



##########
tooling/camel-karaf-feature-maven-plugin/src/test/java/org/apache/camel/karaf/feature/maven/EnsureWrapBundleVersionMojoTest.java:
##########
@@ -0,0 +1,142 @@
+/*
+ * 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.karaf.feature.maven;
+
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.junit.jupiter.api.Test;
+
+public class EnsureWrapBundleVersionMojoTest {
+
+    private final EnsureWrapBundleVersionMojo ensureVersionMojo = new 
EnsureWrapBundleVersionMojo();
+
+    @Test
+    void modifyLocationTest() throws Exception {
+        // add bundle version at the end
+        String location = "wrap:mvn:org.apache.olingo/odata-server-core/5.0.0";
+        String expected = 
"wrap:mvn:org.apache.olingo/odata-server-core/5.0.0$Bundle-Version=5.0.0";
+        assertEquals(expected, ensureVersionMojo.processLocation(location));
+
+        location = 
"wrap:mvn:org.apache.olingo/odata-server-core/5.0.0$overwrite=merge";
+        expected = 
"wrap:mvn:org.apache.olingo/odata-server-core/5.0.0$overwrite=merge&Bundle-Version=5.0.0";
+        assertEquals(expected, ensureVersionMojo.processLocation(location));
+
+        location = 
"wrap:mvn:org.apache.olingo/odata-server-core/5.0.0$overwrite=merge&Export-Package=org.apache.olingo.*;version=5.0.0";
+        expected = 
"wrap:mvn:org.apache.olingo/odata-server-core/5.0.0$overwrite=merge&Bundle-Version=5.0.0&Export-Package=org.apache.olingo.*;version=5.0.0";
+        assertEquals(expected, ensureVersionMojo.processLocation(location));
+
+        // original version won't work in the karaf container
+        location = 
"wrap:mvn:com.google.apis/google-api-services-storage/v1-rev20240209-2.0.0";
+        expected = 
"wrap:mvn:com.google.apis/google-api-services-storage/v1-rev20240209-2.0.0$Bundle-Version=0.0.0.v1-rev20240209-2_0_0";
+        assertEquals(expected, ensureVersionMojo.processLocation(location));
+
+        // bundle version header is present but it won't work in the karaf 
container
+        location = "mvn:commons-io/commons-io/2.15.1$Bundle-Version=2.15.0";
+        expected = "mvn:commons-io/commons-io/2.15.1$Bundle-Version=2.15.0";
+        ;
+        assertEquals(expected, ensureVersionMojo.processLocation(location));
+
+        // bundle version header is present but it points to the wrong value
+        location = "mvn:commons-io/commons-io/2.15.1$Bundle-Version=2.15.0";
+        expected = "mvn:commons-io/commons-io/2.15.1$Bundle-Version=2.15.0";
+        ;

Review Comment:
   I think this one we can keep. It ensures that it won't touch the bundle 
header declaration when it is OSGI-compliant



-- 
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-unsubscr...@camel.apache.org

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

Reply via email to