You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by cs...@apache.org on 2017/08/10 17:15:45 UTC

[1/3] karaf git commit: Cleanup test

Repository: karaf
Updated Branches:
  refs/heads/master b9ae8bfdd -> 3b42fb5a5


Cleanup test


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/38c728df
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/38c728df
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/38c728df

Branch: refs/heads/master
Commit: 38c728dfe31c8056859767692b0d8848469a33e7
Parents: b9ae8bf
Author: Christian Schneider <ch...@die-schneider.net>
Authored: Thu Aug 10 18:39:28 2017 +0200
Committer: Christian Schneider <ch...@die-schneider.net>
Committed: Thu Aug 10 18:39:28 2017 +0200

----------------------------------------------------------------------
 .../internal/service/FeatureValidationUtil.java | 41 -------------
 .../service/FeaturesValidationTest.java         | 61 ++++++--------------
 2 files changed, 18 insertions(+), 84 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/38c728df/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureValidationUtil.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureValidationUtil.java b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureValidationUtil.java
deleted file mode 100644
index f0b24a6..0000000
--- a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureValidationUtil.java
+++ /dev/null
@@ -1,41 +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 org.apache.karaf.features.internal.service;
-
-import java.net.URI;
-
-import org.apache.karaf.features.internal.model.JaxbUtil;
-
-/**
- * Utility class which fires XML Schema validation.
- */
-public final class FeatureValidationUtil {
-
-    private FeatureValidationUtil() {
-    }
-
-    /**
-     * Runs schema validation.
-     *
-     * @param uri Uri to validate.
-     * @throws Exception When validation fails.
-     */
-    public static void validate(URI uri) throws Exception {
-        JaxbUtil.unmarshal(uri.toASCIIString(), true);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/karaf/blob/38c728df/features/core/src/test/java/org/apache/karaf/features/internal/service/FeaturesValidationTest.java
----------------------------------------------------------------------
diff --git a/features/core/src/test/java/org/apache/karaf/features/internal/service/FeaturesValidationTest.java b/features/core/src/test/java/org/apache/karaf/features/internal/service/FeaturesValidationTest.java
index af3c2e1..09badc5 100644
--- a/features/core/src/test/java/org/apache/karaf/features/internal/service/FeaturesValidationTest.java
+++ b/features/core/src/test/java/org/apache/karaf/features/internal/service/FeaturesValidationTest.java
@@ -16,61 +16,43 @@
  */
 package org.apache.karaf.features.internal.service;
 
-import java.net.URL;
-
-import org.apache.karaf.features.Library;
-import org.apache.karaf.features.internal.model.Features;
-import org.apache.karaf.features.internal.model.JaxbUtil;
-import org.junit.Test;
-
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import java.net.URI;
+
+import org.apache.karaf.features.Library;
+import org.apache.karaf.features.internal.model.Features;
+import org.apache.karaf.features.internal.model.JaxbUtil;
+import org.junit.Test;
+
 public class FeaturesValidationTest {
 
     @Test
     public void testNs10() throws Exception {
-        FeatureValidationUtil.validate(getClass().getResource("f02.xml").toURI());
-    }
-
-    @Test
-    public void testNs10Unmarshall() throws Exception {
-        URL url = getClass().getResource("f02.xml");
-        Features features = JaxbUtil.unmarshal(url.toExternalForm(), true);
+        Features features = unmarshalAndValidate("f02.xml");
         assertNotNull(features);
     }
 
     @Test
     public void testNs10NoName() throws Exception {
-        FeatureValidationUtil.validate(getClass().getResource("f03.xml").toURI());
-    }
-
-    @Test
-    public void testNs10NoNameUnmarshall() throws Exception {
-        URL url = getClass().getResource("f03.xml");
-        Features features = JaxbUtil.unmarshal(url.toExternalForm(), true);
+        Features features = unmarshalAndValidate("f03.xml");
         assertNotNull(features);
     }
 
     @Test
     public void testNs11() throws Exception {
-        FeatureValidationUtil.validate(getClass().getResource("f04.xml").toURI());
-    }
-
-    @Test
-    public void testNs11Unmarshall() throws Exception {
-        URL url = getClass().getResource("f04.xml");
-        Features features = JaxbUtil.unmarshal(url.toExternalForm(), true);
+        Features features = unmarshalAndValidate("f04.xml");;
         assertNotNull(features);
     }
 
     @Test
     public void testNs11NoName() throws Exception {
         try {
-            FeatureValidationUtil.validate(getClass().getResource("f05.xml").toURI());
+            unmarshalAndValidate("f05.xml");
             fail("Validation should have failed");
         } catch (Exception e) {
             // ok
@@ -78,26 +60,14 @@ public class FeaturesValidationTest {
     }
 
     @Test
-    public void testNs12() throws Exception {
-        FeatureValidationUtil.validate(getClass().getResource("f06.xml").toURI());
-    }
-
-    @Test
     public void testNs12Unmarshall() throws Exception {
-        URL url = getClass().getResource("f06.xml");
-        Features features = JaxbUtil.unmarshal(url.toExternalForm(), true);
+        Features features = unmarshalAndValidate("f06.xml");
         assertNotNull(features);
     }
 
     @Test
     public void testNs13() throws Exception {
-        FeatureValidationUtil.validate(getClass().getResource("f07.xml").toURI());
-    }
-
-    @Test
-    public void testNs13Unmarshall() throws Exception {
-        URL url = getClass().getResource("f07.xml");
-        Features features = JaxbUtil.unmarshal(url.toExternalForm(), true);
+        Features features = unmarshalAndValidate("f07.xml");
         assertNotNull(features);
         assertEquals("2.5.6.SEC02", features.getFeature().get(0).getVersion());
         assertTrue(features.getFeature().get(1).isHidden());
@@ -109,4 +79,9 @@ public class FeaturesValidationTest {
         assertTrue(features.getFeature().get(0).getLibraries().get(0).isDelegate());
     }
 
+    private Features unmarshalAndValidate(String path) throws Exception {
+        URI uri = getClass().getResource(path).toURI();
+        return JaxbUtil.unmarshal(uri.toASCIIString(), true);
+    }
+
 }


[2/3] karaf git commit: Fix warnings

Posted by cs...@apache.org.
Fix warnings


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/05806fdc
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/05806fdc
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/05806fdc

Branch: refs/heads/master
Commit: 05806fdce8294163aca5cb4b20a651230ce21516
Parents: 38c728d
Author: Christian Schneider <ch...@die-schneider.net>
Authored: Thu Aug 10 19:15:11 2017 +0200
Committer: Christian Schneider <ch...@die-schneider.net>
Committed: Thu Aug 10 19:15:11 2017 +0200

----------------------------------------------------------------------
 .../org/apache/karaf/features/internal/service/DeployerTest.java | 1 -
 .../karaf/features/internal/support/TestDownloadManager.java     | 4 ++--
 2 files changed, 2 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/05806fdc/features/core/src/test/java/org/apache/karaf/features/internal/service/DeployerTest.java
----------------------------------------------------------------------
diff --git a/features/core/src/test/java/org/apache/karaf/features/internal/service/DeployerTest.java b/features/core/src/test/java/org/apache/karaf/features/internal/service/DeployerTest.java
index 651f88e..c9cc4ae 100644
--- a/features/core/src/test/java/org/apache/karaf/features/internal/service/DeployerTest.java
+++ b/features/core/src/test/java/org/apache/karaf/features/internal/service/DeployerTest.java
@@ -471,7 +471,6 @@ public class DeployerTest {
         doTestPrereqOnPrereq(4);
     }
 
-    @SuppressWarnings("unchecked")
     private void doTestPrereqOnPrereq(int scenario) throws Exception {
         IMocksControl c = EasyMock.createControl();
 

http://git-wip-us.apache.org/repos/asf/karaf/blob/05806fdc/features/core/src/test/java/org/apache/karaf/features/internal/support/TestDownloadManager.java
----------------------------------------------------------------------
diff --git a/features/core/src/test/java/org/apache/karaf/features/internal/support/TestDownloadManager.java b/features/core/src/test/java/org/apache/karaf/features/internal/support/TestDownloadManager.java
index c78f854..550519f 100644
--- a/features/core/src/test/java/org/apache/karaf/features/internal/support/TestDownloadManager.java
+++ b/features/core/src/test/java/org/apache/karaf/features/internal/support/TestDownloadManager.java
@@ -38,10 +38,10 @@ public class TestDownloadManager implements DownloadManager, Downloader {
 
     private final MultiException exception = new MultiException("Error");
     private final ConcurrentMap<String, StreamProvider> providers = new ConcurrentHashMap<>();
-    private final Class loader;
+    private final Class<?> loader;
     private final String dir;
 
-    public TestDownloadManager(Class loader, String dir) {
+    public TestDownloadManager(Class<?> loader, String dir) {
         this.loader = loader;
         this.dir = dir;
     }


[3/3] karaf git commit: Cleanup test

Posted by cs...@apache.org.
Cleanup test


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/3b42fb5a
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/3b42fb5a
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/3b42fb5a

Branch: refs/heads/master
Commit: 3b42fb5a5b52ce20a7843521d5f41ff157086672
Parents: 05806fd
Author: Christian Schneider <ch...@die-schneider.net>
Authored: Thu Aug 10 19:15:26 2017 +0200
Committer: Christian Schneider <ch...@die-schneider.net>
Committed: Thu Aug 10 19:15:26 2017 +0200

----------------------------------------------------------------------
 features/core/pom.xml                           |  7 ++++
 .../apache/karaf/features/ConditionalTest.java  | 36 ++++++++------------
 2 files changed, 21 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/3b42fb5a/features/core/pom.xml
----------------------------------------------------------------------
diff --git a/features/core/pom.xml b/features/core/pom.xml
index d4f5944..9e5a272 100644
--- a/features/core/pom.xml
+++ b/features/core/pom.xml
@@ -98,6 +98,13 @@
             <artifactId>tinybundles</artifactId>
             <scope>test</scope>
         </dependency>
+        
+        <dependency>
+            <groupId>org.hamcrest</groupId>
+            <artifactId>hamcrest-all</artifactId>
+            <version>1.3</version>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>

http://git-wip-us.apache.org/repos/asf/karaf/blob/3b42fb5a/features/core/src/test/java/org/apache/karaf/features/ConditionalTest.java
----------------------------------------------------------------------
diff --git a/features/core/src/test/java/org/apache/karaf/features/ConditionalTest.java b/features/core/src/test/java/org/apache/karaf/features/ConditionalTest.java
index b103683..aed4b3d 100644
--- a/features/core/src/test/java/org/apache/karaf/features/ConditionalTest.java
+++ b/features/core/src/test/java/org/apache/karaf/features/ConditionalTest.java
@@ -16,39 +16,31 @@
  */
 package org.apache.karaf.features;
 
-import junit.framework.TestCase;
+import static org.hamcrest.Matchers.contains;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+
 import org.apache.karaf.features.internal.service.RepositoryImpl;
+import org.junit.Test;
 
 
-public class ConditionalTest extends TestCase {
+public class ConditionalTest {
 
+    @Test
     public void testLoad() throws Exception {
         RepositoryImpl r = new RepositoryImpl(getClass().getResource("internal/service/f06.xml").toURI());
-        // Check repo
         Feature[] features = r.getFeatures();
-        assertNotNull(features);
         assertEquals(1, features.length);
         Feature feature = features[0];
 
-        assertNotNull(feature.getConditional());
         assertEquals(2,feature.getConditional().size());
 
-        Conditional conditional = feature.getConditional().get(0);
-        assertNotNull(conditional.getCondition());
-        assertEquals(1,conditional.getCondition().size());
-        String dependency = conditional.getCondition().get(0);
-        assertNotNull(dependency);
-        assertEquals("http", dependency);
-        assertNotNull(conditional.getBundles());
-        assertEquals(1, feature.getConditional().get(0).getBundles().size());
-
-        conditional = feature.getConditional().get(1);
-        assertNotNull(conditional.getCondition());
-        assertEquals(1,conditional.getCondition().size());
-        dependency = conditional.getCondition().get(0);
-        assertNotNull(dependency);
-        assertEquals("req:osgi.ee;filter:=\"(&(osgi.ee=JavaSE)(!(version>=1.7)))\"", dependency);
-
-        String wrapperName = "my6/1.5.3-beta-3".replaceAll("[^A-Za-z0-9 ]", "_");
+        Conditional conditional1 = feature.getConditional().get(0);
+        assertThat(conditional1.getCondition(), contains("http"));
+        assertEquals(1, conditional1.getBundles().size());
+
+        Conditional conditional2 = feature.getConditional().get(1);
+        assertThat(conditional2.getCondition(), contains("req:osgi.ee;filter:=\"(&(osgi.ee=JavaSE)(!(version>=1.7)))\""));
     }
+    
 }