Author: slaws
Date: Tue Jun 14 09:48:46 2011
New Revision: 1135444

URL: http://svn.apache.org/viewvc?rev=1135444&view=rev
Log:
TUSCANY-3873 - start of a test case to check out policy matching and to look at 
where an how policy interceptors are added along the reference, service and 
binding chains

Added:
    tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/   (with props)
    tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/pom.xml
    tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/
    tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/
    tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/
    
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/
    
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorld.java
    
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorldClient.java
    
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorldService.java
    
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/
    
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicy.java
    
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyBuilder.java
    
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyInterceptor.java
    
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyProcessor.java
    
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyProviderFactory.java
    
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyProviderImplementation.java
    
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyProviderReference.java
    
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyProviderService.java
    
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/
    
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/META-INF/
    
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/META-INF/sca-contribution.xml
    
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/META-INF/services/
    
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.PolicyBuilder
    
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
    
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
    
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory
    
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/definitions.xml
    
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/helloworld.composite
    
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/helloworld.wsdl
    tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/test/
    tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/test/java/
    
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/test/java/interceptors/
    
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/test/java/interceptors/HelloworldTestCase.java

Propchange: tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Jun 14 09:48:46 2011
@@ -0,0 +1,4 @@
+.classpath
+.project
+.settings
+target

Added: tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/pom.xml
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/pom.xml?rev=1135444&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/pom.xml (added)
+++ tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/pom.xml Tue 
Jun 14 09:48:46 2011
@@ -0,0 +1,57 @@
+<?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>itest-ws</artifactId>
+        <version>2.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>itest-policy-interceptors</artifactId>
+    <name>Apache Tuscany SCA iTest Policy Interceptors</name>
+
+    <dependencies>
+        
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-base-runtime-pom</artifactId>
+            <type>pom</type>
+            <version>2.0-SNAPSHOT</version>
+        </dependency>
+
+       <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-binding-ws-runtime-axis2</artifactId>
+            <version>2.0-SNAPSHOT</version>
+       </dependency>
+                
+        <dependency>
+            <groupId>org.mortbay.jetty</groupId>
+            <artifactId>jetty</artifactId>
+            <version>6.1.19</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+       <finalName>${project.artifactId}</finalName>
+    </build>
+</project>

Added: 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorld.java
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorld.java?rev=1135444&view=auto
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorld.java
 (added)
+++ 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorld.java
 Tue Jun 14 09:48:46 2011
@@ -0,0 +1,29 @@
+/*
+ * 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 helloworld;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorld {
+    
+    String getGreetings(String s);
+
+}

Added: 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorldClient.java
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorldClient.java?rev=1135444&view=auto
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorldClient.java
 (added)
+++ 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorldClient.java
 Tue Jun 14 09:48:46 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 helloworld;
+
+import org.oasisopen.sca.annotation.Reference;
+
+public class HelloWorldClient implements HelloWorld {
+
+    @Reference
+    public HelloWorld helloWorldWS;
+    
+    public String getGreetings(String s) {
+        String response = helloWorldWS.getGreetings(s);
+        System.out.println("At client: " + response);
+        return response;
+    }
+
+}

Added: 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorldService.java
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorldService.java?rev=1135444&view=auto
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorldService.java
 (added)
+++ 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorldService.java
 Tue Jun 14 09:48:46 2011
@@ -0,0 +1,45 @@
+/*
+ * 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 helloworld;
+
+import javax.security.auth.Subject;
+
+import org.oasisopen.sca.RequestContext;
+import org.oasisopen.sca.annotation.Context;
+
+public class HelloWorldService implements HelloWorld {
+
+    @Context
+    protected RequestContext requestContext;
+    
+    public String getGreetings(String name) {
+        Subject subject = requestContext.getSecuritySubject();
+        String response = "Hello " + name + " ";
+        
+        if (subject == null){
+            response += "null subject";
+        } else {
+            response += subject.getPrincipals().iterator().next().getName();
+        }
+        
+        System.out.println("At service: " + response);
+        return response;
+    }
+}

Added: 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicy.java
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicy.java?rev=1135444&view=auto
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicy.java
 (added)
+++ 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicy.java
 Tue Jun 14 09:48:46 2011
@@ -0,0 +1,63 @@
+/*
+ * 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 testpolicy;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Base;
+
+/**
+ * Implementation for policies that could be injected as parameter
+ * into the axis2config.
+ *
+ * @version $Rev: 824551 $ $Date: 2009-10-13 01:21:22 +0100 (Tue, 13 Oct 2009) 
$
+ */
+public class TestPolicy {
+    static final String SCA11_NS = Base.SCA11_NS;
+    static final String SCA11_TUSCANY_NS = Base.SCA11_TUSCANY_NS;
+    static final QName TEST_POLICY_QNAME = new QName(SCA11_TUSCANY_NS, 
"testPolicy");
+
+    private String testString;
+    
+    public String getTestString() {
+        return testString;
+    }
+    
+    public void setTestString(String testString) {
+        this.testString = testString;
+    }
+
+    public QName getSchemaName() {
+        return TEST_POLICY_QNAME;
+    }
+
+    public boolean isUnresolved() {
+        return false;
+    }
+
+    public void setUnresolved(boolean unresolved) {
+    }
+
+    @Override
+    public String toString() {
+        return "TestPolicy [testString=" + 
+               testString
+               + "]";
+    }
+}

Added: 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyBuilder.java
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyBuilder.java?rev=1135444&view=auto
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyBuilder.java
 (added)
+++ 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyBuilder.java
 Tue Jun 14 09:48:46 2011
@@ -0,0 +1,84 @@
+/*
+ * 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 testpolicy;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.builder.BuilderContext;
+import org.apache.tuscany.sca.assembly.builder.PolicyBuilder;
+import org.apache.tuscany.sca.policy.PolicyExpression;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * 
+ */
+public class TestPolicyBuilder implements PolicyBuilder<TestPolicy> {
+
+    public boolean build(Endpoint endpoint, BuilderContext context) {
+        List<TestPolicy> polices = getPolicies(endpoint);
+        System.out.println(endpoint + ": " + polices);
+        return true;
+    }
+
+    public boolean build(EndpointReference endpointReference, BuilderContext 
context) {
+        List<TestPolicy> polices = getPolicies(endpointReference);
+        System.out.println(endpointReference + ": " + polices);
+        return true;
+    }
+
+    public boolean build(Component component, Implementation implementation, 
BuilderContext context) {
+        List<TestPolicy> polices = getPolicies(implementation);
+        System.out.println(implementation + ": " + polices);
+        return true;
+    }
+
+    public QName getPolicyType() {
+        return TestPolicy.TEST_POLICY_QNAME;
+    }
+    
+    public List<QName> getSupportedBindings() {
+        return null;
+    }
+
+    private List<TestPolicy> getPolicies(PolicySubject subject) {
+        List<TestPolicy> polices = new ArrayList<TestPolicy>();
+        for (PolicySet ps : subject.getPolicySets()) {
+            for (PolicyExpression exp : ps.getPolicies()) {
+                if (getPolicyType().equals(exp.getName())) {
+                    polices.add((TestPolicy)exp.getPolicy());
+                }
+            }
+        }
+        return polices;
+    }
+
+    public boolean build(EndpointReference endpointReference, Endpoint 
endpoint, BuilderContext context) {
+        return true;
+    }
+
+}

Added: 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyInterceptor.java
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyInterceptor.java?rev=1135444&view=auto
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyInterceptor.java
 (added)
+++ 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyInterceptor.java
 Tue Jun 14 09:48:46 2011
@@ -0,0 +1,95 @@
+/*
+ * 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 testpolicy;
+
+import java.util.List;
+import java.util.logging.ConsoleHandler;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+
+public class TestPolicyInterceptor implements PhasedInterceptor {
+    public static final String loggingPolicy = "JDKLoggingPolicy";
+    public static final QName policySetQName = new 
QName(TestPolicy.SCA11_TUSCANY_NS, loggingPolicy);
+    private Logger logger = null;
+
+    private Invoker next;
+    private Operation operation;
+    private List<TestPolicy> policies;
+    private PolicySubject subject;
+    private String context;
+    private String phase;
+
+    public TestPolicyInterceptor(PolicySubject subject,
+                                       String context,
+                                       Operation operation,
+                                       List<TestPolicy> policies,
+                                       String phase) {
+        super();
+        this.operation = operation;
+        this.policies = policies;
+        this.subject = subject;
+        this.phase = phase;
+        this.context = getContext();
+    }
+
+    private String getContext() {
+        if (subject instanceof Endpoint) {
+            Endpoint endpoint = (Endpoint)subject;
+            return endpoint.getURI();
+        } else if (subject instanceof EndpointReference) {
+            EndpointReference endpointReference = (EndpointReference)subject;
+            return endpointReference.getURI();
+        } else if (subject instanceof Component) {
+            Component component = (Component)subject;
+            return component.getURI();
+        }
+        return null;
+    }
+
+    public Message invoke(Message msg) {
+        System.out.println("In interceptor");
+        return msg;
+    }
+
+    public Invoker getNext() {
+        return next;
+    }
+
+    public void setNext(Invoker next) {
+        this.next = next;
+    }
+
+    public String getPhase() {
+        return phase;
+    }
+
+}

Added: 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyProcessor.java
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyProcessor.java?rev=1135444&view=auto
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyProcessor.java
 (added)
+++ 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyProcessor.java
 Tue Jun 14 09:48:46 2011
@@ -0,0 +1,99 @@
+/*
+ * 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 testpolicy;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import java.util.logging.Level;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import 
org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import 
org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+
+/**
+ *
+ * @version $Rev: 883438 $ $Date: 2009-11-23 18:07:34 +0000 (Mon, 23 Nov 2009) 
$
+ */
+public class TestPolicyProcessor implements StAXArtifactProcessor<TestPolicy> {
+    
+    public QName getArtifactType() {
+        return TestPolicy.TEST_POLICY_QNAME;
+    }
+    
+    public TestPolicyProcessor(FactoryExtensionPoint modelFactories) {
+    }
+
+    
+    public TestPolicy read(XMLStreamReader reader, ProcessorContext context) 
throws ContributionReadException, XMLStreamException {
+        TestPolicy policy = new TestPolicy();
+        int event = reader.getEventType();
+        QName name = null;
+        
+        
+        while (reader.hasNext()) {
+            event = reader.getEventType();
+            switch (event) {
+                case START_ELEMENT : {
+                    name = reader.getName();
+                    if ( name.equals("testString") ) {
+                        String testString = reader.getAttributeValue(null, 
"testString");
+                        policy.setTestString(testString);
+                    }
+                    break;
+                }
+            }
+            
+            if ( event == END_ELEMENT ) {
+                if ( TestPolicy.TEST_POLICY_QNAME.equals(reader.getName()) ) {
+                    break;
+                } 
+            }
+            
+            //Read the next element
+            if (reader.hasNext()) {
+                reader.next();
+            }
+        }
+         
+        return policy;
+    }
+
+    public void write(TestPolicy policy, XMLStreamWriter writer, 
ProcessorContext context) throws ContributionWriteException, XMLStreamException 
{
+        // TODO
+    }
+
+    public Class<TestPolicy> getModelType() {
+        return TestPolicy.class;
+    }
+
+    public void resolve(TestPolicy arg0, ModelResolver arg1, ProcessorContext 
context) throws ContributionResolveException {
+
+    }
+    
+}

Added: 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyProviderFactory.java
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyProviderFactory.java?rev=1135444&view=auto
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyProviderFactory.java
 (added)
+++ 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyProviderFactory.java
 Tue Jun 14 09:48:46 2011
@@ -0,0 +1,68 @@
+/*
+ * 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 testpolicy;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.provider.PolicyProvider;
+import org.apache.tuscany.sca.provider.PolicyProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * @version $Rev: 792622 $ $Date: 2009-07-09 19:14:18 +0100 (Thu, 09 Jul 2009) 
$
+ */
+public class TestPolicyProviderFactory implements 
PolicyProviderFactory<TestPolicy> {
+    private ExtensionPointRegistry registry;
+    
+    public TestPolicyProviderFactory(ExtensionPointRegistry registry) {
+        super();
+        this.registry = registry;
+    }
+
+    /**
+     * @see 
org.apache.tuscany.sca.provider.PolicyProviderFactory#createImplementationPolicyProvider(org.apache.tuscany.sca.runtime.RuntimeComponent,
 org.apache.tuscany.sca.assembly.Implementation)
+     */
+    public PolicyProvider createImplementationPolicyProvider(RuntimeComponent 
component) {
+        return new TestPolicyProviderImplementation(component);
+    }
+
+    /**
+     * @see 
org.apache.tuscany.sca.provider.PolicyProviderFactory#createReferencePolicyProvider(org.apache.tuscany.sca.runtime.RuntimeComponent,
 org.apache.tuscany.sca.runtime.RuntimeComponentReference, 
org.apache.tuscany.sca.assembly.Binding)
+     */
+    public PolicyProvider createReferencePolicyProvider(EndpointReference 
endpointReference) {
+        return new TestPolicyProviderReference(endpointReference);
+    }
+
+    /**
+     * @see 
org.apache.tuscany.sca.provider.PolicyProviderFactory#createServicePolicyProvider(org.apache.tuscany.sca.runtime.RuntimeComponent,
 org.apache.tuscany.sca.runtime.RuntimeComponentService, 
org.apache.tuscany.sca.assembly.Binding)
+     */
+    public PolicyProvider createServicePolicyProvider(Endpoint endpoint) {
+        return new TestPolicyProviderService(endpoint);
+    }
+
+    /**
+     * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType()
+     */
+    public Class<TestPolicy> getModelType() {
+        return TestPolicy.class;
+    }
+
+}

Added: 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyProviderImplementation.java
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyProviderImplementation.java?rev=1135444&view=auto
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyProviderImplementation.java
 (added)
+++ 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyProviderImplementation.java
 Tue Jun 14 09:48:46 2011
@@ -0,0 +1,48 @@
+/*
+ * 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 testpolicy;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+import org.apache.tuscany.sca.provider.BasePolicyProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * @version $Rev: 792641 $ $Date: 2009-07-09 20:13:08 +0100 (Thu, 09 Jul 2009) 
$
+ */
+public class TestPolicyProviderImplementation extends 
BasePolicyProvider<TestPolicy> {
+
+    public TestPolicyProviderImplementation(RuntimeComponent component) {
+        super(TestPolicy.class, component);
+    }
+
+    /**
+     * @see 
org.apache.tuscany.sca.provider.PolicyProvider#createInterceptor(org.apache.tuscany.sca.interfacedef.Operation)
+     */
+    public PhasedInterceptor createInterceptor(Operation operation) {
+        List<TestPolicy> policies = findPolicies();
+        return policies.isEmpty() ? null : new TestPolicyInterceptor(subject, 
getContext(), operation,
+                                                                     policies, 
Phase.IMPLEMENTATION_POLICY);
+    }
+
+}

Added: 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyProviderReference.java
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyProviderReference.java?rev=1135444&view=auto
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyProviderReference.java
 (added)
+++ 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyProviderReference.java
 Tue Jun 14 09:48:46 2011
@@ -0,0 +1,45 @@
+/*
+ * 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 testpolicy;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+import org.apache.tuscany.sca.provider.BasePolicyProvider;
+
+/**
+ * @version $Rev: 792641 $ $Date: 2009-07-09 20:13:08 +0100 (Thu, 09 Jul 2009) 
$
+ */
+public class TestPolicyProviderReference extends 
BasePolicyProvider<TestPolicy> {
+
+    public TestPolicyProviderReference(EndpointReference endpointReference) {
+        super(TestPolicy.class, endpointReference);
+    }
+
+    public PhasedInterceptor createInterceptor(Operation operation) {
+        List<TestPolicy> policies = findPolicies();
+        return policies.isEmpty() ? null : new TestPolicyInterceptor(subject, 
getContext(), operation,
+                                                                     policies, 
Phase.REFERENCE_POLICY);
+    }
+
+}

Added: 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyProviderService.java
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyProviderService.java?rev=1135444&view=auto
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyProviderService.java
 (added)
+++ 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyProviderService.java
 Tue Jun 14 09:48:46 2011
@@ -0,0 +1,44 @@
+/*
+ * 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 testpolicy;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+import org.apache.tuscany.sca.provider.BasePolicyProvider;
+
+/**
+ * @version $Rev: 792641 $ $Date: 2009-07-09 20:13:08 +0100 (Thu, 09 Jul 2009) 
$
+ */
+public class TestPolicyProviderService extends BasePolicyProvider<TestPolicy> {
+
+    public TestPolicyProviderService(Endpoint endpoint) {
+        super(TestPolicy.class, endpoint);
+    }
+
+    public PhasedInterceptor createInterceptor(Operation operation) {
+        List<TestPolicy> policies = findPolicies();
+        return policies.isEmpty() ? null : new TestPolicyInterceptor(subject, 
getContext(), operation, policies, Phase.SERVICE_POLICY);
+    }
+
+}

Added: 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/META-INF/sca-contribution.xml
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/META-INF/sca-contribution.xml?rev=1135444&view=auto
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/META-INF/sca-contribution.xml
 (added)
+++ 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/META-INF/sca-contribution.xml
 Tue Jun 14 09:48:46 2011
@@ -0,0 +1,23 @@
+<?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.    
+-->
+<contribution xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912";
+              
xmlns:itest="http://www.tuscany.apache.org/itests/binding/ws/axis2";>
+   <deployable composite="itest:HelloWorld"/>
+</contribution>
\ No newline at end of file

Added: 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.PolicyBuilder
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.PolicyBuilder?rev=1135444&view=auto
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.PolicyBuilder
 (added)
+++ 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.PolicyBuilder
 Tue Jun 14 09:48:46 2011
@@ -0,0 +1,17 @@
+# 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. 
+testpolicy.TestPolicyBuilder;qname=http://tuscany.apache.org/xmlns/sca/1.1#testPolicy

Added: 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor?rev=1135444&view=auto
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
 (added)
+++ 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
 Tue Jun 14 09:48:46 2011
@@ -0,0 +1,20 @@
+# 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. 
+
+# Implementation class for the artifact processor extension
+testpolicy.TestPolicyProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#testPolicy,model=testpolicy.TestPolicy
+

Added: 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions?rev=1135444&view=auto
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
 (added)
+++ 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
 Tue Jun 14 09:48:46 2011
@@ -0,0 +1,17 @@
+# 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.
+definitions.xml

Added: 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory?rev=1135444&view=auto
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory
 (added)
+++ 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory
 Tue Jun 14 09:48:46 2011
@@ -0,0 +1,20 @@
+# 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. 
+
+# Implementation class for the policy extension
+testpolicy.TestPolicyProviderFactory;model=testpolicy.TestPolicy
+

Added: 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/definitions.xml
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/definitions.xml?rev=1135444&view=auto
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/definitions.xml
 (added)
+++ 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/definitions.xml
 Tue Jun 14 09:48:46 2011
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+    * 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.    
+-->
+<definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"; 
+             targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1";
+                xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"; 
+                xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1";>
+
+    <intent name="testIntent" constrains="sca:implementation sca:binding">
+        <description>a test intent</description>
+    </intent>
+
+    <sca:policySet name="TestInteractonPolicySet"
+                   attachTo="//sca:binding.ws"
+                   provides="tuscany:testIntent"
+                   appliesTo="//sca:binding.ws">
+        <tuscany:testPolicy testString="interaction"/>
+    </sca:policySet>
+    
+    <sca:policySet name="TestImplementationPolicySet"
+                   attachTo="//sca:implementation.java"
+                   provides="tuscany:testIntent"
+                   appliesTo="//sca:implementation.java">
+        <tuscany:testPolicy testString="implementation"/> 
+    </sca:policySet>      
+      
+</definitions>
\ No newline at end of file

Added: 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/helloworld.composite
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/helloworld.composite?rev=1135444&view=auto
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/helloworld.composite
 (added)
+++ 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/helloworld.composite
 Tue Jun 14 09:48:46 2011
@@ -0,0 +1,40 @@
+<?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.    
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912";
+           
targetNamespace="http://www.tuscany.apache.org/itests/policy/interceptors";
+                  xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912";
+                  xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1";
+           name="HelloWorld">
+
+    <component name="HelloWorldClient">
+        <implementation.java class="helloworld.HelloWorldClient"/>
+        <reference name="helloWorldWS"
+                   target="HelloWorldService/HelloWorld/BindingWS"
+                   requires="tuscany:testIntent"/>
+    </component>
+    
+    <component name="HelloWorldService">
+               <implementation.java class="helloworld.HelloWorldService"/>
+           <service name="HelloWorld" requires="tuscany:testIntent">  
+               <binding.ws name="BindingWS"/>
+           </service>          
+    </component>
+    
+</composite>

Added: 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/helloworld.wsdl
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/helloworld.wsdl?rev=1135444&view=auto
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/helloworld.wsdl
 (added)
+++ 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/helloworld.wsdl
 Tue Jun 14 09:48:46 2011
@@ -0,0 +1,90 @@
+<?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.    
+-->
+<wsdl:definitions targetNamespace="http://helloworld"; 
+                  xmlns:tns="http://helloworld"; 
+                  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"; 
+                  xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"; 
+                  xmlns:xsd="http://www.w3.org/2001/XMLSchema";
+                     name="helloworld">
+
+    <wsdl:types>
+        <schema elementFormDefault="qualified" 
targetNamespace="http://helloworld"; xmlns="http://www.w3.org/2001/XMLSchema";>
+
+            <element name="getGreetings">
+                <complexType>
+                    <sequence>
+                        <element name="name" type="xsd:string"/>
+                    </sequence>
+                </complexType>
+            </element>
+
+            <element name="getGreetingsResponse">
+                <complexType>
+                    <sequence>
+                        <element name="getGreetingsReturn" type="xsd:string"/>
+                    </sequence>
+                </complexType>
+            </element>
+            
+        </schema>
+    </wsdl:types>
+
+    <wsdl:message name="getGreetingsRequest">
+        <wsdl:part element="tns:getGreetings" name="parameters"/>
+    </wsdl:message>
+
+    <wsdl:message name="getGreetingsResponse">
+        <wsdl:part element="tns:getGreetingsResponse" name="parameters"/>
+    </wsdl:message>
+
+    <wsdl:portType name="HelloWorld">
+        <wsdl:operation name="getGreetings">
+            <wsdl:input message="tns:getGreetingsRequest" 
name="getGreetingsRequest"/>
+            <wsdl:output message="tns:getGreetingsResponse" 
name="getGreetingsResponse"/>
+        </wsdl:operation>
+    </wsdl:portType>
+
+    <wsdl:binding name="HelloWorldSoapBinding" type="tns:HelloWorld">
+        <wsdlsoap:binding style="document" 
transport="http://schemas.xmlsoap.org/soap/http"/>
+        <wsdl:operation name="getGreetings">
+            <wsdlsoap:operation soapAction=""/>
+            <wsdl:input name="getGreetingsRequest">
+                <wsdlsoap:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output name="getGreetingsResponse">
+                <wsdlsoap:body use="literal"/>
+            </wsdl:output>
+        </wsdl:operation>
+
+    </wsdl:binding>
+
+    <wsdl:service name="HelloWorldService">
+        <wsdl:port binding="tns:HelloWorldSoapBinding" 
name="HelloWorldSoapPort1">
+            <wsdlsoap:address 
location="http://localhost:8085/services/HelloWorldWebService1"/>
+        </wsdl:port>
+        <wsdl:port binding="tns:HelloWorldSoapBinding" 
name="HelloWorldSoapPort2">
+            <wsdlsoap:address 
location="http://localhost:8085/services/HelloWorldWebService2"/>
+        </wsdl:port>
+        <wsdl:port binding="tns:HelloWorldSoapBinding" 
name="HelloWorldSoapPort3">
+            <wsdlsoap:address 
location="http://localhost:8085/services/HelloWorldWebService3"/>
+        </wsdl:port>
+    </wsdl:service>
+
+</wsdl:definitions>

Added: 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/test/java/interceptors/HelloworldTestCase.java
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/test/java/interceptors/HelloworldTestCase.java?rev=1135444&view=auto
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/test/java/interceptors/HelloworldTestCase.java
 (added)
+++ 
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/test/java/interceptors/HelloworldTestCase.java
 Tue Jun 14 09:48:46 2011
@@ -0,0 +1,51 @@
+/*
+ * 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 interceptors;
+
+import junit.framework.TestCase;
+
+import helloworld.HelloWorld;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.Ignore;
+
+public class HelloworldTestCase extends TestCase {
+
+    private Node node;
+    private HelloWorld helloWorld;
+
+    @Override
+    protected void setUp() throws Exception {
+        node = NodeFactory.newInstance().createNode("helloworld.composite", 
new Contribution("test", "target/classes"));
+        node.start();
+        helloWorld = node.getService(HelloWorld.class, 
"HelloWorldClient/HelloWorld");
+    }
+    
+    public void testCalculator() throws Exception {
+        assertEquals("Hello fred myname", helloWorld.getGreetings("fred"));
+    }    
+    
+    @Override
+    protected void tearDown() throws Exception {
+        node.stop();
+    }
+
+}


Reply via email to