aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r1090724 - in /aries/trunk/spi-fly: spi-fly-core/src/main/java/org/apache/aries/spifly/ spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/ spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/impl2_123/ sp...
Date Sun, 10 Apr 2011 00:53:54 GMT
Author: davidb
Date: Sun Apr 10 00:53:53 2011
New Revision: 1090724

URL: http://svn.apache.org/viewvc?rev=1090724&view=rev
Log:
More work on the SPI-Fly tests

Added:
    aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/AltTestClient.java
    aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/JaxpClient.java
    aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/impl2_123/
    aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/impl2_123/MySPIImpl2B.java
    aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/impl3/
    aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/impl3/MyAltDocumentBuilderFactory.java
    aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/resources/org/apache/aries/spifly/dynamic/impl2_123/
    aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/resources/org/apache/aries/spifly/dynamic/impl2_123/META-INF/
    aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/resources/org/apache/aries/spifly/dynamic/impl2_123/META-INF/services/
    aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/resources/org/apache/aries/spifly/dynamic/impl2_123/META-INF/services/org.apache.aries.mytest.MySPI
    aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/resources/org/apache/aries/spifly/dynamic/impl3/
    aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/resources/org/apache/aries/spifly/dynamic/impl3/META-INF/
    aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/resources/org/apache/aries/spifly/dynamic/impl3/META-INF/services/
    aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/resources/org/apache/aries/spifly/dynamic/impl3/META-INF/services/javax.xml.parsers.DocumentBuilderFactory
Modified:
    aries/trunk/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/ConsumerHeaderProcessor.java
    aries/trunk/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/WeavingData.java
    aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/ClientWeavingHookTest.java

Modified: aries/trunk/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/ConsumerHeaderProcessor.java
URL: http://svn.apache.org/viewvc/aries/trunk/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/ConsumerHeaderProcessor.java?rev=1090724&r1=1090723&r2=1090724&view=diff
==============================================================================
--- aries/trunk/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/ConsumerHeaderProcessor.java
(original)
+++ aries/trunk/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/ConsumerHeaderProcessor.java
Sun Apr 10 00:53:53 2011
@@ -118,6 +118,7 @@ public class ConsumerHeaderProcessor {
             }
             ConsumerRestriction restriction = new ConsumerRestriction(className, methodRestriction);
 
+            // TODO is this correct? Why is it added to a set?
             Set<ConsumerRestriction> restrictions = new HashSet<ConsumerRestriction>();
             restrictions.add(restriction);
 
@@ -156,8 +157,9 @@ public class ConsumerHeaderProcessor {
             // TODO this can be done in the WeavingData itself?
             String[] argClasses = restriction.getMethodRestriction(methodName).getArgClasses();
 
-            weavingData.add(new WeavingData(className, methodName, argClasses, restrictions,
-                    allowedBundles.size() == 0 ? null : allowedBundles));
+            WeavingData wd = new WeavingData(className, methodName, argClasses, restrictions,
+                    allowedBundles.size() == 0 ? null : allowedBundles);
+            weavingData.add(wd);
         }
         return weavingData;
     }

Modified: aries/trunk/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/WeavingData.java
URL: http://svn.apache.org/viewvc/aries/trunk/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/WeavingData.java?rev=1090724&r1=1090723&r2=1090724&view=diff
==============================================================================
--- aries/trunk/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/WeavingData.java
(original)
+++ aries/trunk/spi-fly/spi-fly-core/src/main/java/org/apache/aries/spifly/WeavingData.java
Sun Apr 10 00:53:53 2011
@@ -38,8 +38,8 @@ public class WeavingData {
      * @param argClasses The overload (class names of the signature) of the call
      * that needs to be woven. If <code>null</code> then all overloads of the
method
      * need to be woven.
-     * @param argRestrictions 
-     * @param allowedBundles 
+     * @param argRestrictions
+     * @param allowedBundles
      */
     public WeavingData(String className, String methodName, String[] argClasses, Set<ConsumerRestriction>
argRestrictions, List<BundleDescriptor> allowedBundles) {
         // TODO can we infer argClasses from restrictions?
@@ -64,12 +64,12 @@ public class WeavingData {
 
     public String[] getArgClasses() {
         return argClasses;
-    }        
+    }
 
     public Set<ConsumerRestriction> getArgRestrictions() {
         return argRestrictions;
-    }        
-    
+    }
+
     @Override
     public int hashCode() {
         final int prime = 31;
@@ -77,6 +77,8 @@ public class WeavingData {
         result = prime * result + Arrays.hashCode(argClasses);
         result = prime * result + ((className == null) ? 0 : className.hashCode());
         result = prime * result + ((methodName == null) ? 0 : methodName.hashCode());
+        result = prime * result + ((argRestrictions == null) ? 0 : argRestrictions.hashCode());
+        result = prime * result + ((allowedBundles == null) ? 0 : allowedBundles.hashCode());
         return result;
     }
 
@@ -84,26 +86,41 @@ public class WeavingData {
     public boolean equals(Object obj) {
         if (this == obj)
             return true;
-        
+
         if (obj == null)
             return false;
-        
+
         if (getClass() != obj.getClass())
             return false;
-        
+
         WeavingData other = (WeavingData) obj;
         if (!Arrays.equals(argClasses, other.argClasses))
             return false;
+
         if (className == null) {
             if (other.className != null)
                 return false;
         } else if (!className.equals(other.className))
             return false;
+
         if (methodName == null) {
             if (other.methodName != null)
                 return false;
         } else if (!methodName.equals(other.methodName))
             return false;
+
+        if (argRestrictions == null) {
+            if (other.argRestrictions != null)
+                return false;
+        } else if (!argRestrictions.equals(other.argRestrictions))
+            return false;
+
+        if (allowedBundles == null) {
+            if (other.allowedBundles != null)
+                return false;
+        } else if (!allowedBundles.equals(other.allowedBundles))
+            return false;
+
         return true;
     }
 }

Added: aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/AltTestClient.java
URL: http://svn.apache.org/viewvc/aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/AltTestClient.java?rev=1090724&view=auto
==============================================================================
--- aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/AltTestClient.java
(added)
+++ aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/AltTestClient.java
Sun Apr 10 00:53:53 2011
@@ -0,0 +1,35 @@
+/**
+ * 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.aries.spifly.dynamic;
+
+import java.util.ServiceLoader;
+
+import org.apache.aries.mytest.AltSPI;
+
+public class AltTestClient {
+    public long test(long input) {
+        long result = 0;
+
+        ServiceLoader<AltSPI> loader = ServiceLoader.load(AltSPI.class);
+        for (AltSPI mySPI : loader) {
+            result += mySPI.square(input);
+        }
+        return result;
+    }
+}

Modified: aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/ClientWeavingHookTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/ClientWeavingHookTest.java?rev=1090724&r1=1090723&r2=1090724&view=diff
==============================================================================
--- aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/ClientWeavingHookTest.java
(original)
+++ aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/ClientWeavingHookTest.java
Sun Apr 10 00:53:53 2011
@@ -331,7 +331,7 @@ public class ClientWeavingHookTest {
 
         // Weave the AltTestClient class.
         URL cls2Url = getClass().getResource("AltTestClient.class");
-        WovenClass wc2 = new MyWovenClass(cls2Url, "org.apache.aries.spifly.AltTestClient",
consumerBundle);
+        WovenClass wc2 = new MyWovenClass(cls2Url, "org.apache.aries.spifly.dynamic.AltTestClient",
consumerBundle);
         wh.weave(wc2);
 
         // Invoke the AltTestClient
@@ -378,7 +378,7 @@ public class ClientWeavingHookTest {
                 providerBundle1, providerBundle2, providerBundle3, providerBundle4);
         WeavingHook wh = new ClientWeavingHook(spiFlyBundle.getBundleContext(), activator);
 
-        testConsumerBundleWeaving(consumerBundle1, wh, "impl4", "org.apache.aries.spifly.impl3.MyAltDocumentBuilderFactory");
+        testConsumerBundleWeaving(consumerBundle1, wh, "impl4", "org.apache.aries.spifly.dynamic.impl3.MyAltDocumentBuilderFactory");
         testConsumerBundleWeaving(consumerBundle2, wh, "olleh", "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
         testConsumerBundleWeaving(consumerBundle3, wh, "", "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
     }
@@ -386,7 +386,7 @@ public class ClientWeavingHookTest {
     private void testConsumerBundleWeaving(Bundle consumerBundle, WeavingHook wh, String
testClientResult, String jaxpClientResult) throws Exception {
         // Weave the TestClient class.
         URL clsUrl = getClass().getResource("TestClient.class");
-        WovenClass wc = new MyWovenClass(clsUrl, "org.apache.aries.spifly.TestClient", consumerBundle);
+        WovenClass wc = new MyWovenClass(clsUrl, "org.apache.aries.spifly.dynamic.TestClient",
consumerBundle);
         wh.weave(wc);
 
         // Invoke the woven class and check that it propertly sets the TCCL so that the
@@ -397,7 +397,7 @@ public class ClientWeavingHookTest {
         Assert.assertEquals(testClientResult, result);
 
         URL clsUrl2 = getClass().getResource("JaxpClient.class");
-        WovenClass wc2 = new MyWovenClass(clsUrl2, "org.apache.aries.spifly.JaxpClient",
consumerBundle);
+        WovenClass wc2 = new MyWovenClass(clsUrl2, "org.apache.aries.spifly.dynamic.JaxpClient",
consumerBundle);
         wh.weave(wc2);
 
         Class<?> cls2 = wc2.getDefinedClass();
@@ -772,6 +772,7 @@ public class ClientWeavingHookTest {
         private final String className;
         private final Bundle bundle;
         private final byte [] bytes;
+        private Class<?> wovenClass;
 
         public MyWovenClassClassLoader(String className, byte[] bytes, ClassLoader parent,
Bundle bundle) {
             super(parent);
@@ -785,7 +786,10 @@ public class ClientWeavingHookTest {
         protected synchronized Class<?> loadClass(String name, boolean resolve)
                 throws ClassNotFoundException {
             if (name.equals(className)) {
-                return defineClass(className, bytes, 0, bytes.length);
+                if (wovenClass == null)
+                    wovenClass = defineClass(className, bytes, 0, bytes.length);
+
+                return wovenClass;
             } else {
                 return super.loadClass(name, resolve);
             }

Added: aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/JaxpClient.java
URL: http://svn.apache.org/viewvc/aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/JaxpClient.java?rev=1090724&view=auto
==============================================================================
--- aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/JaxpClient.java
(added)
+++ aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/JaxpClient.java
Sun Apr 10 00:53:53 2011
@@ -0,0 +1,27 @@
+/**
+ * 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.aries.spifly.dynamic;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+public class JaxpClient {
+    public Class<?> test() {
+        return DocumentBuilderFactory.newInstance().getClass();
+    }
+}

Added: aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/impl2_123/MySPIImpl2B.java
URL: http://svn.apache.org/viewvc/aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/impl2_123/MySPIImpl2B.java?rev=1090724&view=auto
==============================================================================
--- aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/impl2_123/MySPIImpl2B.java
(added)
+++ aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/impl2_123/MySPIImpl2B.java
Sun Apr 10 00:53:53 2011
@@ -0,0 +1,28 @@
+/**
+ * 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.aries.spifly.dynamic.impl2_123;
+
+import org.apache.aries.mytest.MySPI;
+
+public class MySPIImpl2B implements MySPI {
+    @Override
+    public String someMethod(String s) {
+        return "Updated!" + s + "!Updated";
+    }
+}

Added: aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/impl3/MyAltDocumentBuilderFactory.java
URL: http://svn.apache.org/viewvc/aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/impl3/MyAltDocumentBuilderFactory.java?rev=1090724&view=auto
==============================================================================
--- aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/impl3/MyAltDocumentBuilderFactory.java
(added)
+++ aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/impl3/MyAltDocumentBuilderFactory.java
Sun Apr 10 00:53:53 2011
@@ -0,0 +1,52 @@
+/**
+ * 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.aries.spifly.dynamic.impl3;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+public class MyAltDocumentBuilderFactory extends DocumentBuilderFactory {
+
+    @Override
+    public DocumentBuilder newDocumentBuilder()
+            throws ParserConfigurationException {
+        return null;
+    }
+
+    @Override
+    public void setAttribute(String name, Object value)
+            throws IllegalArgumentException {
+    }
+
+    @Override
+    public Object getAttribute(String name) throws IllegalArgumentException {
+        return null;
+    }
+
+    @Override
+    public void setFeature(String name, boolean value)
+            throws ParserConfigurationException {
+    }
+
+    @Override
+    public boolean getFeature(String name) throws ParserConfigurationException {
+        return false;
+    }
+}

Added: aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/resources/org/apache/aries/spifly/dynamic/impl2_123/META-INF/services/org.apache.aries.mytest.MySPI
URL: http://svn.apache.org/viewvc/aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/resources/org/apache/aries/spifly/dynamic/impl2_123/META-INF/services/org.apache.aries.mytest.MySPI?rev=1090724&view=auto
==============================================================================
--- aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/resources/org/apache/aries/spifly/dynamic/impl2_123/META-INF/services/org.apache.aries.mytest.MySPI
(added)
+++ aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/resources/org/apache/aries/spifly/dynamic/impl2_123/META-INF/services/org.apache.aries.mytest.MySPI
Sun Apr 10 00:53:53 2011
@@ -0,0 +1 @@
+org.apache.aries.spifly.dynamic.impl2_123.MySPIImpl2B
\ No newline at end of file

Added: aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/resources/org/apache/aries/spifly/dynamic/impl3/META-INF/services/javax.xml.parsers.DocumentBuilderFactory
URL: http://svn.apache.org/viewvc/aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/resources/org/apache/aries/spifly/dynamic/impl3/META-INF/services/javax.xml.parsers.DocumentBuilderFactory?rev=1090724&view=auto
==============================================================================
--- aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/resources/org/apache/aries/spifly/dynamic/impl3/META-INF/services/javax.xml.parsers.DocumentBuilderFactory
(added)
+++ aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/resources/org/apache/aries/spifly/dynamic/impl3/META-INF/services/javax.xml.parsers.DocumentBuilderFactory
Sun Apr 10 00:53:53 2011
@@ -0,0 +1 @@
+org.apache.aries.spifly.impl3.dynamic.MyAltDocumentBuilderFactory



Mime
View raw message