You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by an...@apache.org on 2007/10/26 15:57:17 UTC

svn commit: r588646 [2/2] - in /incubator/tuscany/java/sca/itest: ./ contribution-classloader/ contribution-classloader/contribution-classes/ contribution-classloader/contribution-classes/src/ contribution-classloader/contribution-classes/src/main/ con...

Added: incubator/tuscany/java/sca/itest/contribution-classloader/contribution-test/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/contribution-classloader/contribution-test/pom.xml?rev=588646&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/contribution-classloader/contribution-test/pom.xml (added)
+++ incubator/tuscany/java/sca/itest/contribution-classloader/contribution-test/pom.xml Fri Oct 26 06:57:14 2007
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    * 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.    
+-->
+<project>
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.tuscany.sca</groupId>
+        <artifactId>tuscany-itest</artifactId>
+        <version>1.1-incubating-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    <artifactId>itest-contribution-classloader-test</artifactId>
+    <name>Apache Tuscany Contribution Classloader tests</name>
+
+<dependencies>
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-host-embedded</artifactId>
+            <version>1.1-incubating-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-implementation-java-runtime</artifactId>
+            <version>1.1-incubating-SNAPSHOT</version>
+            <scope>runtime</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.2</version>
+            <scope>test</scope>
+        </dependency>
+
+    </dependencies>
+</project>

Propchange: incubator/tuscany/java/sca/itest/contribution-classloader/contribution-test/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/contribution-classloader/contribution-test/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/tuscany/java/sca/itest/contribution-classloader/contribution-test/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: incubator/tuscany/java/sca/itest/contribution-classloader/contribution-test/src/main/resources/META-INF/LICENSE.txt
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/contribution-classloader/contribution-test/src/main/resources/META-INF/LICENSE.txt?rev=588646&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/contribution-classloader/contribution-test/src/main/resources/META-INF/LICENSE.txt (added)
+++ incubator/tuscany/java/sca/itest/contribution-classloader/contribution-test/src/main/resources/META-INF/LICENSE.txt Fri Oct 26 06:57:14 2007
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, serviceDefinition marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed 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.

Propchange: incubator/tuscany/java/sca/itest/contribution-classloader/contribution-test/src/main/resources/META-INF/LICENSE.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/contribution-classloader/contribution-test/src/main/resources/META-INF/LICENSE.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/tuscany/java/sca/itest/contribution-classloader/contribution-test/src/main/resources/META-INF/NOTICE
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/contribution-classloader/contribution-test/src/main/resources/META-INF/NOTICE?rev=588646&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/contribution-classloader/contribution-test/src/main/resources/META-INF/NOTICE (added)
+++ incubator/tuscany/java/sca/itest/contribution-classloader/contribution-test/src/main/resources/META-INF/NOTICE Fri Oct 26 06:57:14 2007
@@ -0,0 +1,14 @@
+${pom.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+

Propchange: incubator/tuscany/java/sca/itest/contribution-classloader/contribution-test/src/main/resources/META-INF/NOTICE
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/contribution-classloader/contribution-test/src/main/resources/META-INF/NOTICE
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/tuscany/java/sca/itest/contribution-classloader/contribution-test/src/main/resources/META-INF/README.txt
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/contribution-classloader/contribution-test/src/main/resources/META-INF/README.txt?rev=588646&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/contribution-classloader/contribution-test/src/main/resources/META-INF/README.txt (added)
+++ incubator/tuscany/java/sca/itest/contribution-classloader/contribution-test/src/main/resources/META-INF/README.txt Fri Oct 26 06:57:14 2007
@@ -0,0 +1,35 @@
+Apache Tuscany M1 build (May, 2006)
+===================================
+
+http://incubator.apache.org/tuscany/
+
+Tuscany is an effort undergoing incubation at the Apache Software Foundation
+(ASF), sponsored by the Web Services PMC.
+
+Incubation is required of all newly accepted projects until a further review
+indicates that the infrastructure, communications, and decision making process
+have stabilized in a manner consistent with other successful ASF projects. 
+
+While incubation status is not necessarily a reflection of the completeness or 
+stability of the code, it does indicate that the project has yet to be fully
+endorsed by the ASF.
+
+
+Support
+-------
+
+Any problem with this release can be reported to the Tuscany mailing list 
+or in the JIRA issue tracker.
+
+Mailing list subscription:
+    tuscany-dev-subscribe@ws.apache.org
+
+Jira:
+    http://issues.apache.org/jira/browse/Tuscany
+
+
+Thank you for using Tuscany!
+
+
+The Tuscany Team. 
+

Propchange: incubator/tuscany/java/sca/itest/contribution-classloader/contribution-test/src/main/resources/META-INF/README.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/contribution-classloader/contribution-test/src/main/resources/META-INF/README.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/tuscany/java/sca/itest/contribution-classloader/contribution-test/src/test/java/org/apache/tuscany/sca/test/contribution/ContributionTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/contribution-classloader/contribution-test/src/test/java/org/apache/tuscany/sca/test/contribution/ContributionTestCase.java?rev=588646&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/contribution-classloader/contribution-test/src/test/java/org/apache/tuscany/sca/test/contribution/ContributionTestCase.java (added)
+++ incubator/tuscany/java/sca/itest/contribution-classloader/contribution-test/src/test/java/org/apache/tuscany/sca/test/contribution/ContributionTestCase.java Fri Oct 26 06:57:14 2007
@@ -0,0 +1,369 @@
+/*
+ * 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.sca.test.contribution;
+
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URLClassLoader;
+
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.resolver.ClassReference;
+import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/*
+ * 
+ * Contribution classloading integration tests
+ */
+
+public class ContributionTestCase {
+
+    private SupplyChain supplyChain;
+    
+    
+    @Before
+    public void setUp() throws Exception {
+        supplyChain = new SupplyChain();
+    }
+	
+
+	@After
+    public void tearDown() throws Exception {
+
+        supplyChain.tearDown();
+        
+	}
+
+   
+    /**
+     * Test static classloading for classes that are visible from contribution
+     * 
+     * @throws Exception
+     */
+    public void staticClassLoadingTestForVisibleClasses() throws Exception {
+        
+        Contribution customerContribution = supplyChain.getContribution("Customer");
+        ClassReference customerClassRef = new ClassReference("supplychain.customer.Customer");
+        customerClassRef = customerContribution.getModelResolver().resolveModel(ClassReference.class, customerClassRef);
+        Class customerClass = customerClassRef.getJavaClass();
+        
+        Class customerClassFromContribution = customerContribution.getClassLoader().loadClass("supplychain.customer.Customer");
+        Assert.assertEquals(customerClass, customerClassFromContribution);
+        
+        Object customer = supplyChain.getCustomer(customerClass);
+                
+        Method m = customerClass.getMethod("purchaseGoods");
+        m.invoke(customer);
+        
+
+        m = customerClass.getMethod("outstandingOrderCount");
+        
+        int retries = 10;
+        int outstandingCount = 1;
+        while (retries-- > 0) {
+        
+            outstandingCount = (int)(Integer)m.invoke(customer);
+            if (outstandingCount == 0)
+                break;
+            else
+                Thread.sleep(100);
+        }
+        Assert.assertEquals(0, outstandingCount);
+        
+        
+    }
+    
+
+    /**
+     * Test dynamic classloading for classes that are visible from contribution
+     * 
+     * @throws Exception
+     */
+    public void dynamicClassLoadingTestForVisibleClasses() throws Exception {
+        
+        Contribution customerContribution = supplyChain.getContribution("Customer");
+        Contribution retailerContribution = supplyChain.getContribution("Retailer");
+        Contribution warehouseContribution = supplyChain.getContribution("Warehouse");
+        Contribution shipperContribution = supplyChain.getContribution("Shipper");
+        Contribution supplyChainContribution = supplyChain.getContribution("SupplyChain");
+        
+        ClassReference customerClassRef = new ClassReference("supplychain.customer.Customer");
+        customerClassRef = customerContribution.getModelResolver().resolveModel(ClassReference.class, customerClassRef);
+        Class customerClass = customerClassRef.getJavaClass();
+        
+        Class customerClassFromContribution = customerContribution.getClassLoader().loadClass("supplychain.customer.Customer");
+        Assert.assertEquals(customerClass, customerClassFromContribution);
+        
+        Object customer = supplyChain.getCustomer(customerClass);
+        Assert.assertTrue(customerClass.isInstance(customer));
+        
+        ClassReference retailerClassRef = new ClassReference("supplychain.retailer.Retailer");
+        retailerClassRef = retailerContribution.getModelResolver().resolveModel(ClassReference.class, retailerClassRef);
+        Class retailerClass = retailerClassRef.getJavaClass();
+        
+        Class retailerClassFromContribution = retailerContribution.getClassLoader().loadClass("supplychain.retailer.Retailer");
+        Assert.assertEquals(retailerClass, retailerClassFromContribution);
+        
+        Class retailerClassFromCustomer = customerContribution.getClassLoader().loadClass("supplychain.retailer.Retailer");
+        Assert.assertEquals(retailerClass, retailerClassFromCustomer);
+        
+        ClassReference warehouseClassRef = new ClassReference("supplychain.warehouse.Warehouse");
+        warehouseClassRef = warehouseContribution.getModelResolver().resolveModel(ClassReference.class, warehouseClassRef);
+        Class warehouseClass = warehouseClassRef.getJavaClass();
+        
+        Class warehouseClassFromContribution = warehouseContribution.getClassLoader().loadClass("supplychain.warehouse.Warehouse");
+        Assert.assertEquals(warehouseClass, warehouseClassFromContribution);
+        
+        Class warehouseClassFromRetailer = retailerContribution.getClassLoader().loadClass("supplychain.warehouse.Warehouse");
+        Assert.assertEquals(warehouseClass, warehouseClassFromRetailer);
+        
+        ClassReference shipperClassRef = new ClassReference("supplychain.shipper.Shipper");
+        shipperClassRef = shipperContribution.getModelResolver().resolveModel(ClassReference.class, shipperClassRef);
+        Class shipperClass = shipperClassRef.getJavaClass();
+        
+        Class shipperClassFromContribution = shipperContribution.getClassLoader().loadClass("supplychain.shipper.Shipper");
+        Assert.assertEquals(shipperClass, shipperClassFromContribution);
+        
+        Class shipperClassFromWarehouse = shipperContribution.getClassLoader().loadClass("supplychain.shipper.Shipper");
+        Assert.assertEquals(shipperClass, shipperClassFromWarehouse);
+        
+        Class customerClassFromShipper = shipperContribution.getClassLoader().loadClass("supplychain.customer.Customer");
+        Assert.assertEquals(customerClass, customerClassFromShipper);
+        
+        Class customerClassFromSupplyChain = supplyChainContribution.getClassLoader().loadClass("supplychain.customer.Customer");
+        Assert.assertEquals(customerClass, customerClassFromSupplyChain);
+        Class retailerClassFromSupplyChain = supplyChainContribution.getClassLoader().loadClass("supplychain.retailer.Retailer");
+        Assert.assertEquals(retailerClass, retailerClassFromSupplyChain);
+        Class warehouseClassFromSupplyChain = supplyChainContribution.getClassLoader().loadClass("supplychain.warehouse.Warehouse");
+        Assert.assertEquals(warehouseClass, warehouseClassFromSupplyChain);
+        Class shipperClassFromSupplyChain = supplyChainContribution.getClassLoader().loadClass("supplychain.shipper.Shipper");
+        Assert.assertEquals(shipperClass, shipperClassFromSupplyChain);
+        
+    }
+    
+    /**
+     * Test dynamic classloading for classes that are visible from contribution
+     * 
+     * @throws Exception
+     */
+    public void dynamicClassLoadingTestForNonImportedClasses() throws Exception {
+        
+        Contribution customerContribution = supplyChain.getContribution("Customer");
+        Contribution shipperContribution = supplyChain.getContribution("Shipper");
+        
+        Class customerClass = customerContribution.getClassLoader().loadClass("supplychain.customer.Customer"); 
+        Class shipperClass = shipperContribution.getClassLoader().loadClass("supplychain.shipper.Shipper");
+        
+        try {
+            customerClass.getClassLoader().loadClass("supplychain.warehouse.Warehouse");
+            Assert.fail("Non-imported class loaded incorrectly");
+        } catch (ClassNotFoundException e) {
+        }
+        try {
+            customerClass.getClassLoader().loadClass("supplychain.shipper.JavaShipperComponentImpl");
+            Assert.fail("Non-imported class loaded incorrectly");
+        } catch (ClassNotFoundException e) {
+        }
+        
+        try {
+            Class.forName("supplychain.warehouse.Warehouse", true, customerClass.getClassLoader());
+            Assert.fail("Non-imported class loaded incorrectly");
+        } catch (ClassNotFoundException e) {
+        }
+        try {
+            Class.forName("supplychain.shipper.JavaShipperComponentImpl", true, customerClass.getClassLoader());
+            Assert.fail("Non-imported class loaded incorrectly");
+        } catch (ClassNotFoundException e) {
+        }
+        
+        try {
+            shipperClass.getClassLoader().loadClass("supplychain.warehouse.JavaWarehouseComponentImpl");
+            Assert.fail("Non-imported class loaded incorrectly");
+        } catch (ClassNotFoundException e) {
+        }
+        try {
+            shipperClass.getClassLoader().loadClass("supplychain.retailer.Retailer");
+            Assert.fail("Non-imported class loaded incorrectly");
+        } catch (ClassNotFoundException e) {
+        }
+        
+        try {
+            Class.forName("supplychain.warehouse.JavaWarehouseComponentImpl", true, shipperClass.getClassLoader());
+            Assert.fail("Non-imported class loaded incorrectly");
+        } catch (ClassNotFoundException e) {
+        }
+        try {
+            Class.forName("supplychain.retailer.Retailer", true, shipperClass.getClassLoader());
+            Assert.fail("Non-imported class loaded incorrectly");
+        } catch (ClassNotFoundException e) {
+        }
+        
+        
+    }
+    
+
+    /**
+     * This test ensures that classes from imported packages can be statically loaded 
+     * from other contributions even though the classes are not on CLASSPATH or on the 
+     * parent classloader, or the thread context classloader.
+     * 
+     * @throws Exception
+     */
+    @Test
+    public void testValidStaticClassLoading() throws Exception {
+               
+        supplyChain.setUp(this.getClass().getClassLoader());
+        
+        staticClassLoadingTestForVisibleClasses();
+    }
+    
+    /**
+     * This test ensures that all imported classes are loaded from the exporting contributions 
+     * rather than the parent classLoader. If any of the interface classes were incorrectly loaded 
+     * through the parent classloader, LinkageError should result.
+     * 
+     * @throws Exception
+     */
+    @Test
+    public void testValidStaticClassLoadingWithContributionsInParentClassLoader() throws Exception {
+        
+        
+        URLClassLoader parentClassLoader = new URLClassLoader(
+                supplyChain.getContributionURLs(),
+                this.getClass().getClassLoader());
+
+        supplyChain.setUp(parentClassLoader);
+        
+        staticClassLoadingTestForVisibleClasses();
+    }
+    
+    
+    /**
+     * This test ensures that classes from imported packages can be dynamically loaded from
+     * other contributions even though the classes are not on CLASSPATH or on the 
+     * parent classloader, or the thread context classloader.
+     * 
+     * @throws Exception
+     */
+    @Test
+    public void testValidDynamicClassLoading() throws Exception {
+               
+        supplyChain.setUp(this.getClass().getClassLoader());
+        
+        dynamicClassLoadingTestForVisibleClasses();
+    }
+    
+    /**
+     * This test ensures that all imported classes are dynamically loaded from the exporting 
+     * contributions rather  than the parent classLoader. If any of the interface classes were 
+     * incorrectly loaded through the parent, NoClassDefFoundError or LinkageError should result.
+     * 
+     * @throws Exception
+     */
+    @Test
+    public void testValidDynamicClassLoadingWithContributionsInParentClassLoader() throws Exception {
+        
+        
+        URLClassLoader parentClassLoader = new URLClassLoader(
+                supplyChain.getContributionURLs(),
+                this.getClass().getClassLoader());
+
+        supplyChain.setUp(parentClassLoader);
+        
+        dynamicClassLoadingTestForVisibleClasses();
+    }
+    
+    @Test
+    public void testIllegalStaticClassLoading1() throws Exception {
+            
+        try {
+            supplyChain.setUp(this.getClass().getClassLoader(), SupplyChain.SUPPLYCHAIN_ILLEGAL_1);
+        
+            Assert.fail("Composite containing unresolved references resolved incorrectly");
+        } catch (ContributionResolveException e) {
+        }
+    }
+    
+    @Test
+    public void testIllegalStaticClassLoading2() throws Exception {
+          
+        supplyChain.setUp(this.getClass().getClassLoader(), SupplyChain.SUPPLYCHAIN_ILLEGAL_2);
+        
+        Contribution customerContribution = supplyChain.getContribution("Customer");
+        ClassReference customerClassRef = new ClassReference("supplychain.customer.Customer");
+        customerClassRef = customerContribution.getModelResolver().resolveModel(ClassReference.class, customerClassRef);
+        Class customerClass = customerClassRef.getJavaClass();
+        
+        Object customer = supplyChain.getCustomer(customerClass);
+                
+        try {
+            Method m = customerClass.getMethod("purchaseGoods");
+            m.invoke(customer);
+            
+            Assert.fail("Classloading exception not thrown as expected");
+        } catch (InvocationTargetException e) {
+            
+            Throwable cause = e.getCause();
+            Assert.assertTrue(cause instanceof NoClassDefFoundError);
+            Assert.assertTrue(cause.getMessage().indexOf("JavaWarehouseComponentImpl") > -1);        }
+        
+    }
+    
+    /**
+     * This test ensures that classes from imported packages can be dynamically loaded from
+     * other contributions even though the classes are not on CLASSPATH or on the 
+     * parent classloader, or the thread context classloader.
+     * 
+     * @throws Exception
+     */
+    @Test
+    public void testIllegalDynamicClassLoading() throws Exception {
+               
+        supplyChain.setUp(this.getClass().getClassLoader());
+        
+        dynamicClassLoadingTestForNonImportedClasses();
+    }
+    
+    
+    /**
+     * Self-contained contribution containing composites, componentType files and implementations
+     * should not require import/export statements for these files to find each other or for Tuscany
+     * to load these files.
+     * @throws Exception
+     */
+    @Test
+    public void testSelfContainedContribution() throws Exception {
+               
+        supplyChain.setUp(this.getClass().getClassLoader(), SupplyChain.SUPPLYCHAIN_SELFCONTAINED);
+        
+        staticClassLoadingTestForVisibleClasses();
+    }
+    
+    @Test
+    public void testContributionsWithSplitPackage() throws Exception {
+               
+        supplyChain.setUp(this.getClass().getClassLoader(), SupplyChain.SUPPLYCHAIN_SPLITPACKAGE);
+        
+        staticClassLoadingTestForVisibleClasses();
+    }
+}

Propchange: incubator/tuscany/java/sca/itest/contribution-classloader/contribution-test/src/test/java/org/apache/tuscany/sca/test/contribution/ContributionTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/contribution-classloader/contribution-test/src/test/java/org/apache/tuscany/sca/test/contribution/ContributionTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/itest/contribution-classloader/contribution-test/src/test/java/org/apache/tuscany/sca/test/contribution/SupplyChain.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/contribution-classloader/contribution-test/src/test/java/org/apache/tuscany/sca/test/contribution/SupplyChain.java?rev=588646&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/contribution-classloader/contribution-test/src/test/java/org/apache/tuscany/sca/test/contribution/SupplyChain.java (added)
+++ incubator/tuscany/java/sca/itest/contribution-classloader/contribution-test/src/test/java/org/apache/tuscany/sca/test/contribution/SupplyChain.java Fri Oct 26 06:57:14 2007
@@ -0,0 +1,231 @@
+/*
+ * 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.sca.test.contribution;
+
+
+import java.io.File;
+import java.net.URL;
+import java.util.Hashtable;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.service.ContributionService;
+import org.apache.tuscany.sca.host.embedded.impl.EmbeddedSCADomain;
+import org.junit.Assert;
+
+/*
+ * 
+ * Contribution classloading integration tests
+ */
+
+public class SupplyChain {
+    
+    public static final int SUPPLYCHAIN = 0;
+    public static final int SUPPLYCHAIN_ILLEGAL_1 = 1;
+    public static final int SUPPLYCHAIN_ILLEGAL_2 = 2;
+    public static final int SUPPLYCHAIN_SELFCONTAINED = 3;
+    public static final int SUPPLYCHAIN_SPLITPACKAGE = 4;
+    
+    private String folderName = "../contribution-classes/target/classes";
+
+    private String customerJarName = "Customer";
+    private String retailerJarName = "Retailer";
+    private String warehouseJarName = "Warehouse";
+    private String shipperJarName = "Shipper";
+    private String supplychainJarName = "SupplyChain";
+    private String illegalSupplyChain1JarName = "IllegalSupplyChain1";
+    private String illegalSupplyChain2JarName = "IllegalSupplyChain2";
+    private String illegalCustomerJarName = "IllegalCustomer";
+    private String completeSupplychainJarName = "CompleteSupplyChain";
+    private String customerInterfaceJarName = "CustomerInterface";
+    private String customerImplJarName = "CustomerImpl";
+    
+    
+    private  EmbeddedSCADomain domain;
+    private ContributionService contributionService;
+    private int supplyChainVersion;
+        
+    private Hashtable<String, Contribution> contributions = new Hashtable<String, Contribution>();
+    
+    private URL customerContribURL;
+    private URL retailerContribURL;
+    private URL warehouseContribURL;
+    private URL shipperContribURL;
+    private URL supplyChainContribURL;
+    private URL illegalSupplyChain1ContribURL;
+    private URL illegalSupplyChain2ContribURL;
+    private URL illegalCustomerContribURL;
+    private URL completeSupplyChainContribURL;
+    private URL customerInterfaceContribURL;
+    private URL customerImplContribURL;
+    
+    public SupplyChain() throws Exception {
+        
+        customerContribURL = new File(folderName + "/" + customerJarName + ".jar").toURL();
+        retailerContribURL = new File(folderName + "/" + retailerJarName + ".jar").toURL();
+        warehouseContribURL = new File(folderName + "/" + warehouseJarName + ".jar").toURL();
+        shipperContribURL = new File(folderName + "/" + shipperJarName + ".jar").toURL();
+        supplyChainContribURL = new File(folderName + "/" + supplychainJarName + ".jar").toURL();
+        illegalSupplyChain1ContribURL = new File(folderName + "/" + illegalSupplyChain1JarName + ".jar").toURL();
+        illegalSupplyChain2ContribURL = new File(folderName + "/" + illegalSupplyChain2JarName + ".jar").toURL();
+        illegalCustomerContribURL = new File(folderName + "/" + illegalCustomerJarName + ".jar").toURL();
+        completeSupplyChainContribURL = new File(folderName + "/" + completeSupplychainJarName + ".jar").toURL();
+        customerInterfaceContribURL = new File(folderName + "/" + customerInterfaceJarName + ".jar").toURL();
+        customerImplContribURL = new File(folderName + "/" + customerImplJarName + ".jar").toURL();
+    }
+    
+    public void setUp(ClassLoader parentClassLoader) throws Exception  {
+        this.setUp(parentClassLoader, SUPPLYCHAIN);
+    }
+    
+    public void setUp(ClassLoader parentClassLoader, int supplyChainVersion) throws Exception {
+        
+        this.supplyChainVersion = supplyChainVersion;
+        
+        Thread.currentThread().setContextClassLoader(parentClassLoader);
+        
+        //Create an embedded SCA domain
+        domain = new EmbeddedSCADomain(parentClassLoader, "http://localhost");
+
+        //Start the domain
+        domain.start();
+
+        this.contributionService = domain.getContributionService();
+        
+        addContributions(supplyChainVersion);
+    }
+        
+    protected void addContributions(int supplyChainVersion) throws Exception {
+            
+        Contribution contribution;
+        
+        if (supplyChainVersion != SUPPLYCHAIN_SELFCONTAINED) {
+            contribution = contributionService.contribute("Shipper", shipperContribURL, true);
+            contributions.put("Shipper", contribution);
+            contribution = contributionService.contribute("Warehouse", warehouseContribURL, true);
+            contributions.put("Warehouse", contribution);
+            contribution = contributionService.contribute("Retailer", retailerContribURL, true);
+            contributions.put("Retailer", contribution);
+        }
+        
+        switch (supplyChainVersion) {
+        case SUPPLYCHAIN:
+            contribution = contributionService.contribute("Customer", customerContribURL, true);
+            contributions.put("Customer", contribution);
+            
+            contribution = contributionService.contribute("SupplyChain", supplyChainContribURL, true);
+            contributions.put("SupplyChain", contribution);
+            break;
+        case SUPPLYCHAIN_ILLEGAL_1:
+            contribution = contributionService.contribute("Customer", customerContribURL, true);
+            contributions.put("Customer", contribution);
+            
+            contribution = contributionService.contribute("SupplyChain", illegalSupplyChain1ContribURL, true);
+            contributions.put("SupplyChain", contribution);
+            break;
+        case SUPPLYCHAIN_ILLEGAL_2:
+            contribution = contributionService.contribute("Customer", illegalCustomerContribURL, true);
+            contributions.put("Customer", contribution);
+            
+            contribution = contributionService.contribute("SupplyChain", illegalSupplyChain2ContribURL, true);
+            contributions.put("SupplyChain", contribution);
+            break;
+        case SUPPLYCHAIN_SELFCONTAINED:
+            contribution = contributionService.contribute("SupplyChain", completeSupplyChainContribURL, true);
+            contributions.put("SupplyChain", contribution);
+            break;
+        case SUPPLYCHAIN_SPLITPACKAGE:
+            contribution = contributionService.contribute("Customer", customerInterfaceContribURL, true);
+            contributions.put("Customer", contribution);
+            
+            contribution = contributionService.contribute("CustomerImpl", customerImplContribURL, true);
+            contributions.put("CustomerImpl", contribution);
+            
+            contribution = contributionService.contribute("SupplyChain", supplyChainContribURL, true);
+            contributions.put("SupplyChain", contribution);
+            break;
+        }
+        
+        // SUPPLYCHAIN_ILLEGAL_1 should throw an exception when the composite is resolved, and hence
+        // should not get this far.
+        Assert.assertTrue(supplyChainVersion != SUPPLYCHAIN_ILLEGAL_1);
+            
+        
+        for (Contribution c : contributions.values()) {
+
+            for (Composite deployable : c.getDeployables()) {
+                domain.getDomainComposite().getIncludes().add(deployable);
+                domain.getCompositeBuilder().build(deployable);
+            }
+            
+        }
+            
+        // Start Components from my composite
+        for (Composite deployable : contributions.get("SupplyChain").getDeployables() ) {
+            domain.getCompositeActivator().activate(deployable);
+            domain.getCompositeActivator().start(deployable);
+        }
+    }
+   
+    public void tearDown() throws Exception {
+        
+        if (domain == null)
+            return;
+        
+        for (String contributionURI : contributions.keySet()) {
+            contributionService.remove(contributionURI);
+        }
+
+
+        if (contributions.get("SupplyChain") != null) {
+            // Stop Components from my composite
+            for (Composite deployable : contributions.get("SupplyChain").getDeployables() ) {
+                domain.getCompositeActivator().stop(deployable);
+                domain.getCompositeActivator().deactivate(deployable);
+            }
+        }
+
+        domain.stop();
+
+        domain.close();
+    }
+
+    public Contribution getContribution(String uri) {
+        if (supplyChainVersion == SUPPLYCHAIN_SELFCONTAINED)
+            return contributions.get("SupplyChain");
+        else
+            return contributions.get(uri);
+    }
+    
+    public Object getCustomer(Class<?> customerClass) {
+        return domain.getService(customerClass, "CustomerComponent");
+    }
+      
+    public URL[] getContributionURLs() {
+        return new URL[] {
+                customerContribURL,
+                retailerContribURL,
+                warehouseContribURL,
+                shipperContribURL,
+                supplyChainContribURL
+        };
+    }
+    
+    
+}

Propchange: incubator/tuscany/java/sca/itest/contribution-classloader/contribution-test/src/test/java/org/apache/tuscany/sca/test/contribution/SupplyChain.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/contribution-classloader/contribution-test/src/test/java/org/apache/tuscany/sca/test/contribution/SupplyChain.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/itest/contribution-classloader/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/contribution-classloader/pom.xml?rev=588646&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/contribution-classloader/pom.xml (added)
+++ incubator/tuscany/java/sca/itest/contribution-classloader/pom.xml Fri Oct 26 06:57:14 2007
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    * 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.    
+-->
+<project>
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.tuscany.sca</groupId>
+        <artifactId>tuscany-itest</artifactId>
+        <version>1.1-incubating-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    <artifactId>itest-contribution-classloader</artifactId>
+    <packaging>pom</packaging>
+    <name>Apache Tuscany Contribution ClassLoader Integration Tests</name>
+
+    <modules>
+        <module>contribution-classes</module>
+        <module>contribution-test</module>
+    </modules>
+    
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-host-embedded</artifactId>
+            <version>1.1-incubating-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-contribution-impl</artifactId>
+            <version>1.1-incubating-SNAPSHOT</version>
+        </dependency>
+
+    </dependencies>
+</project>
\ No newline at end of file

Propchange: incubator/tuscany/java/sca/itest/contribution-classloader/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/contribution-classloader/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/tuscany/java/sca/itest/contribution-classloader/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: incubator/tuscany/java/sca/itest/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/pom.xml?rev=588646&r1=588645&r2=588646&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/pom.xml (original)
+++ incubator/tuscany/java/sca/itest/pom.xml Fri Oct 26 06:57:14 2007
@@ -47,6 +47,7 @@
                 <module>contribution</module>
                 <module>contribution-multiple</module>
                 <module>contribution-import-export</module>
+                <module>contribution-classloader</module>
                 <module>conversations</module>
                 <module>databindings</module>
                 <module>exceptions</module>



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