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);
+    }
+
 }

Reply via email to