You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2007/04/16 09:54:19 UTC

svn commit: r529155 - in /incubator/tuscany/java/sca/modules: core-databinding/src/main/java/org/apache/tuscany/core/databinding/wire/ core-databinding/src/test/java/org/apache/tuscany/core/databinding/wire/ core-spi/src/main/java/org/apache/tuscany/sp...

Author: jsdelfino
Date: Mon Apr 16 00:54:14 2007
New Revision: 529155

URL: http://svn.apache.org/viewvc?view=rev&rev=529155
Log:
Cleaning up core-spi. Moved URIHelper util class to core-databinding, as it's only used in that module.

Added:
    incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/core/databinding/wire/URIHelper.java   (with props)
    incubator/tuscany/java/sca/modules/core-databinding/src/test/java/org/apache/tuscany/core/databinding/wire/URIHelperTestCase.java   (with props)
Removed:
    incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/spi/util/
    incubator/tuscany/java/sca/modules/core-spi/src/test/java/org/apache/tuscany/spi/util/
Modified:
    incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/core/databinding/wire/DataBindingInteceptor.java
    incubator/tuscany/java/sca/modules/core-databinding/src/test/java/org/apache/tuscany/core/databinding/wire/DataBindingWirePostProcessorOptimizationTestCase.java
    incubator/tuscany/java/sca/modules/core-databinding/src/test/java/org/apache/tuscany/core/databinding/wire/DataBindingWirePostProcessorTestCase.java

Modified: incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/core/databinding/wire/DataBindingInteceptor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/core/databinding/wire/DataBindingInteceptor.java?view=diff&rev=529155&r1=529154&r2=529155
==============================================================================
--- incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/core/databinding/wire/DataBindingInteceptor.java (original)
+++ incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/core/databinding/wire/DataBindingInteceptor.java Mon Apr 16 00:54:14 2007
@@ -34,7 +34,6 @@
 import org.apache.tuscany.spi.databinding.ExceptionHandler;
 import org.apache.tuscany.spi.databinding.Mediator;
 import org.apache.tuscany.spi.databinding.TransformationException;
-import org.apache.tuscany.spi.util.UriHelper;
 import org.apache.tuscany.spi.wire.Interceptor;
 import org.apache.tuscany.spi.wire.Message;
 import org.apache.tuscany.spi.wire.Wire;
@@ -63,7 +62,7 @@
         this.sourceOperation = sourceOperation;
         this.targetOperation = targetOperation;
         URI uri = wire.getSourceUri();
-        URI sourceUri = UriHelper.getDefragmentedName(uri);
+        URI sourceUri = URIHelper.getDefragmentedName(uri);
         this.composite = componentManager.getComponent(sourceUri);
 
     }

Added: incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/core/databinding/wire/URIHelper.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/core/databinding/wire/URIHelper.java?view=auto&rev=529155
==============================================================================
--- incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/core/databinding/wire/URIHelper.java (added)
+++ incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/core/databinding/wire/URIHelper.java Mon Apr 16 00:54:14 2007
@@ -0,0 +1,57 @@
+/*
+ * 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.tuscany.core.databinding.wire;
+
+import java.net.URI;
+
+/**
+ * Utility methods for handling URIs
+ *
+ * @version $Rev$ $Date$
+ */
+final class URIHelper {
+
+    private URIHelper() {
+    }
+
+    /**
+     * Returns the base name for a component URI, e.g. 'Bar' for 'sca://foo/Bar'
+     *
+     * @param uri the URI to parse
+     * @return the base name
+     */
+    static String getBaseName(URI uri) {
+        String s = uri.toString();
+        int pos = s.lastIndexOf('/');
+        if (pos > -1) {
+            return s.substring(pos + 1);
+        } else {
+            return s;
+        }
+    }
+
+    static URI getDefragmentedName(URI uri) {
+        if (uri.getFragment() == null) {
+            return uri;
+        }
+        String s = uri.toString();
+        int pos = s.lastIndexOf('#');
+        return URI.create(s.substring(0, pos));
+    }
+}

Propchange: incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/core/databinding/wire/URIHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/core/databinding/wire/URIHelper.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/sca/modules/core-databinding/src/test/java/org/apache/tuscany/core/databinding/wire/DataBindingWirePostProcessorOptimizationTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-databinding/src/test/java/org/apache/tuscany/core/databinding/wire/DataBindingWirePostProcessorOptimizationTestCase.java?view=diff&rev=529155&r1=529154&r2=529155
==============================================================================
--- incubator/tuscany/java/sca/modules/core-databinding/src/test/java/org/apache/tuscany/core/databinding/wire/DataBindingWirePostProcessorOptimizationTestCase.java (original)
+++ incubator/tuscany/java/sca/modules/core-databinding/src/test/java/org/apache/tuscany/core/databinding/wire/DataBindingWirePostProcessorOptimizationTestCase.java Mon Apr 16 00:54:14 2007
@@ -37,7 +37,6 @@
 import org.apache.tuscany.spi.component.Component;
 import org.apache.tuscany.spi.component.ComponentManager;
 import org.apache.tuscany.spi.databinding.Mediator;
-import org.apache.tuscany.spi.util.UriHelper;
 import org.apache.tuscany.spi.wire.InvocationChain;
 import org.apache.tuscany.spi.wire.Wire;
 import org.easymock.EasyMock;
@@ -69,8 +68,8 @@
         Mediator mediator = new MediatorImpl();
         ComponentManager componentManager = createMock(ComponentManager.class);
         Component component = createMock(Component.class);
-        expect(componentManager.getComponent(UriHelper.getDefragmentedName(sourceUri))).andReturn(component);
-        expect(componentManager.getComponent(UriHelper.getDefragmentedName(targetUri))).andReturn(component);
+        expect(componentManager.getComponent(URIHelper.getDefragmentedName(sourceUri))).andReturn(component);
+        expect(componentManager.getComponent(URIHelper.getDefragmentedName(targetUri))).andReturn(component);
 
         replay(component, componentManager);
         processor = new DataBindingWirePostProcessor(componentManager, mediator);

Modified: incubator/tuscany/java/sca/modules/core-databinding/src/test/java/org/apache/tuscany/core/databinding/wire/DataBindingWirePostProcessorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-databinding/src/test/java/org/apache/tuscany/core/databinding/wire/DataBindingWirePostProcessorTestCase.java?view=diff&rev=529155&r1=529154&r2=529155
==============================================================================
--- incubator/tuscany/java/sca/modules/core-databinding/src/test/java/org/apache/tuscany/core/databinding/wire/DataBindingWirePostProcessorTestCase.java (original)
+++ incubator/tuscany/java/sca/modules/core-databinding/src/test/java/org/apache/tuscany/core/databinding/wire/DataBindingWirePostProcessorTestCase.java Mon Apr 16 00:54:14 2007
@@ -47,7 +47,6 @@
 import org.apache.tuscany.spi.component.ComponentManager;
 import org.apache.tuscany.spi.component.ReferenceBinding;
 import org.apache.tuscany.spi.databinding.Mediator;
-import org.apache.tuscany.spi.util.UriHelper;
 import org.apache.tuscany.spi.wire.Interceptor;
 import org.apache.tuscany.spi.wire.InvocationChain;
 import org.apache.tuscany.spi.wire.Wire;
@@ -83,8 +82,8 @@
         // expect(component1.getReference("reference1")).andReturn(null);
         Component component2 = createMock(Component.class);
         // expect(component2.getService("service1")).andReturn(null);
-        expect(componentManager.getComponent(UriHelper.getDefragmentedName(sourceUri))).andReturn(component1).anyTimes();
-        expect(componentManager.getComponent(UriHelper.getDefragmentedName(targetUri))).andReturn(component2).anyTimes();
+        expect(componentManager.getComponent(URIHelper.getDefragmentedName(sourceUri))).andReturn(component1).anyTimes();
+        expect(componentManager.getComponent(URIHelper.getDefragmentedName(targetUri))).andReturn(component2).anyTimes();
         replay(mediator, componentManager, component1, component2);
         DataBindingWirePostProcessor processor = new DataBindingWirePostProcessor(componentManager, mediator);
 
@@ -110,8 +109,8 @@
         expect(component1.getReference("reference1")).andReturn(null);
         Component component2 = createMock(Component.class);
         expect(component2.getReference("reference1")).andReturn(null);
-        expect(componentManager.getComponent(UriHelper.getDefragmentedName(sourceUri))).andReturn(component1).anyTimes();
-        expect(componentManager.getComponent(UriHelper.getDefragmentedName(targetUri))).andReturn(component2).anyTimes();
+        expect(componentManager.getComponent(URIHelper.getDefragmentedName(sourceUri))).andReturn(component1).anyTimes();
+        expect(componentManager.getComponent(URIHelper.getDefragmentedName(targetUri))).andReturn(component2).anyTimes();
         replay(mediator, componentManager, component1, component2);
         DataBindingWirePostProcessor processor = new DataBindingWirePostProcessor(componentManager, mediator);
         
@@ -132,8 +131,8 @@
         expect(component1.getService("service1")).andReturn(null);
         Component component2 = createMock(Component.class);
         expect(component2.getService("service1")).andReturn(null);
-        expect(componentManager.getComponent(UriHelper.getDefragmentedName(sourceUri))).andReturn(component1).anyTimes();
-        expect(componentManager.getComponent(UriHelper.getDefragmentedName(targetUri))).andReturn(component2).anyTimes();
+        expect(componentManager.getComponent(URIHelper.getDefragmentedName(sourceUri))).andReturn(component1).anyTimes();
+        expect(componentManager.getComponent(URIHelper.getDefragmentedName(targetUri))).andReturn(component2).anyTimes();
         replay(mediator, componentManager, component1, component2);
         DataBindingWirePostProcessor processor = new DataBindingWirePostProcessor(componentManager, mediator);
         

Added: incubator/tuscany/java/sca/modules/core-databinding/src/test/java/org/apache/tuscany/core/databinding/wire/URIHelperTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-databinding/src/test/java/org/apache/tuscany/core/databinding/wire/URIHelperTestCase.java?view=auto&rev=529155
==============================================================================
--- incubator/tuscany/java/sca/modules/core-databinding/src/test/java/org/apache/tuscany/core/databinding/wire/URIHelperTestCase.java (added)
+++ incubator/tuscany/java/sca/modules/core-databinding/src/test/java/org/apache/tuscany/core/databinding/wire/URIHelperTestCase.java Mon Apr 16 00:54:14 2007
@@ -0,0 +1,72 @@
+/*
+ * 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.tuscany.core.databinding.wire;
+
+import java.net.URI;
+
+import org.apache.tuscany.core.databinding.wire.URIHelper;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class URIHelperTestCase extends TestCase {
+
+    public void testBaseName() throws Exception {
+        URI uri = new URI("foo");
+        assertEquals("foo", URIHelper.getBaseName(uri));
+    }
+
+    public void testBaseNameScheme() throws Exception {
+        URI uri = new URI("sca://foo");
+        assertEquals("foo", URIHelper.getBaseName(uri));
+    }
+
+    public void testBaseNameSchemePath() throws Exception {
+        URI uri = new URI("sca://bar/foo");
+        assertEquals("foo", URIHelper.getBaseName(uri));
+    }
+
+    public void testBaseNamePath() throws Exception {
+        URI uri = new URI("bar/foo");
+        assertEquals("foo", URIHelper.getBaseName(uri));
+    }
+
+    public void testBaseNameFragment() throws Exception {
+        URI uri = new URI("#foo");
+        assertEquals("#foo", URIHelper.getBaseName(uri));
+    }
+
+    public void testDefragmentedNameScheme() throws Exception {
+        URI uri = new URI("sca://foo/bar#bar");
+        assertEquals("sca://foo/bar", URIHelper.getDefragmentedName(uri).toString());
+    }
+
+    public void testDefragmentedName() throws Exception {
+        URI uri = new URI("foo/bar#bar");
+        assertEquals("foo/bar", URIHelper.getDefragmentedName(uri).toString());
+    }
+
+    public void testDefragmentedNoName() throws Exception {
+        URI uri = new URI("#bar");
+        assertEquals("", URIHelper.getDefragmentedName(uri).toString());
+    }
+
+}

Propchange: incubator/tuscany/java/sca/modules/core-databinding/src/test/java/org/apache/tuscany/core/databinding/wire/URIHelperTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/core-databinding/src/test/java/org/apache/tuscany/core/databinding/wire/URIHelperTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org