aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tjwat...@apache.org
Subject svn commit: r1609462 - in /aries/trunk/subsystem/subsystem-core/src: main/java/org/apache/aries/subsystem/core/internal/Location.java test/java/org/apache/aries/subsystem/core/internal/LocationTest.java
Date Thu, 10 Jul 2014 14:04:08 GMT
Author: tjwatson
Date: Thu Jul 10 14:04:07 2014
New Revision: 1609462

URL: http://svn.apache.org/r1609462
Log:
ARIES-1147 - Fix necessary to pass the OSGi Subsystem CT

Need to capture the IllegalStateException from parsing the subsystem URI so that 
we can fail later when we need to compute the symbolic name or version from the URI

Modified:
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Location.java
    aries/trunk/subsystem/subsystem-core/src/test/java/org/apache/aries/subsystem/core/internal/LocationTest.java

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Location.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Location.java?rev=1609462&r1=1609461&r2=1609462&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Location.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Location.java
Thu Jul 10 14:04:07 2014
@@ -43,6 +43,7 @@ public class Location {
   private final URI uri;
   private final URL url;
   private final SubsystemUri subsystemUri;
+  private final IllegalArgumentException subsystemUriException;
 
   /*
    * type, value, uri are always set to some non-null value, url and
@@ -56,13 +57,16 @@ public class Location {
       if (LocationType.SUBSYSTEM.scheme.equals(scheme)) {
         type = LocationType.SUBSYSTEM;
         SubsystemUri ssUri;
+        IllegalArgumentException ssUriException = null;
         try {
           ssUri = new SubsystemUri(location);
-        } catch (Exception ex) {
+        } catch (IllegalArgumentException ex) {
           // In some cases the SubsystemUri can't be parsed by the SubsystemUri parser.
           ssUri = null;
+          ssUriException = ex;
         }
         subsystemUri = ssUri;
+        subsystemUriException = ssUriException;
         if (subsystemUri != null) {
           url = subsystemUri.getURL(); // subsystem uris may contain a nested url.
           uri = (url==null) ? null : url.toURI();
@@ -73,11 +77,13 @@ public class Location {
       } else if (LocationType.IDIRFINDER.scheme.equals(scheme)) {
         type = LocationType.IDIRFINDER;
         subsystemUri = null;
+        subsystemUriException = null;
         url = null;
         uri = locationUri;
       } else {                       // otherwise will only accept a url, (a url
         type = LocationType.URL;     // always has a scheme, so fine to have 
         subsystemUri = null;         // this inside the 'if isAbsolute' block).
+        subsystemUriException = null;
         url = locationUri.toURL();
         uri = locationUri;
       }
@@ -86,6 +92,7 @@ public class Location {
     	url = null;
     	uri = null;
     	subsystemUri = null;
+    	subsystemUriException = null;
     }
   }
     
@@ -94,10 +101,16 @@ public class Location {
   }
     
   public String getSymbolicName() {
+    if (subsystemUriException != null) {
+      throw subsystemUriException;
+    }
     return (subsystemUri!=null) ? subsystemUri.getSymbolicName() : null;
   }
     
   public Version getVersion() {
+    if (subsystemUriException != null) {
+      throw subsystemUriException;
+    }
     return (subsystemUri!=null) ? subsystemUri.getVersion() : null;
   }
 

Modified: aries/trunk/subsystem/subsystem-core/src/test/java/org/apache/aries/subsystem/core/internal/LocationTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/test/java/org/apache/aries/subsystem/core/internal/LocationTest.java?rev=1609462&r1=1609461&r2=1609462&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/test/java/org/apache/aries/subsystem/core/internal/LocationTest.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/test/java/org/apache/aries/subsystem/core/internal/LocationTest.java
Thu Jul 10 14:04:07 2014
@@ -67,7 +67,17 @@ public class LocationTest {
 
         Location location = new Location(locationString);
         assertEquals(locationString, location.getValue());
-        assertNull(location.getSymbolicName());
-        assertNull(location.getVersion());
+        try {
+        	String sn = location.getSymbolicName();
+        	fail("Expecting an error: " + sn);
+        } catch (IllegalArgumentException e) {
+        	// expected
+        }
+        try {
+        	Version v = location.getVersion();
+        	fail("Expecting an error: " + v);
+        } catch (IllegalArgumentException e) {
+        	// expected 
+        }
     }
 }



Mime
View raw message