diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2012-02-20 10:40:35 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2012-02-20 10:40:35 +0000 |
commit | dcdefa32b02ea6df9e1226a0d7028d89531f983a (patch) | |
tree | 1ec381da93c1781ff31daee3e87a0ce5185b2396 /sca-java-2.x/trunk/testing/itest | |
parent | 1a01ce4fe5882fcc5b312172d7fdf409e0cb9765 (diff) |
TUSCANY-4017 - add a test case to ensure that the exactlyOnce profile intent resolves to atLeastOnce and atMostOnce.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1291186 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
32 files changed, 1781 insertions, 2 deletions
diff --git a/sca-java-2.x/trunk/testing/itest/policy/pom.xml b/sca-java-2.x/trunk/testing/itest/policy/pom.xml index 4e62039bbd..07998c97d7 100644 --- a/sca-java-2.x/trunk/testing/itest/policy/pom.xml +++ b/sca-java-2.x/trunk/testing/itest/policy/pom.xml @@ -33,9 +33,8 @@ <module>matching</module> <module>wspolicy</module> <module>operations</module> -<!-- <module>interceptors</module> ---> + <module>reliability</module> </modules> </project> diff --git a/sca-java-2.x/trunk/testing/itest/policy/reliability/pom.xml b/sca-java-2.x/trunk/testing/itest/policy/reliability/pom.xml new file mode 100644 index 0000000000..617f51f58d --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/policy/reliability/pom.xml @@ -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>tuscany-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-policy-reliability</artifactId>
+ <name>Apache Tuscany SCA iTest Policy Reliability</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>
diff --git a/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/helloworld/HelloWorld.java b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/helloworld/HelloWorld.java new file mode 100644 index 0000000000..1f5b8b365d --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/helloworld/HelloWorld.java @@ -0,0 +1,31 @@ +/*
+ * 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);
+
+ String getGreetingsException(String s) throws HelloWorldException;
+
+}
diff --git a/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/helloworld/HelloWorldClient.java b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/helloworld/HelloWorldClient.java new file mode 100644 index 0000000000..baeea9bb4b --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/helloworld/HelloWorldClient.java @@ -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 helloworld;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Requires;
+
+public class HelloWorldClient implements HelloWorld {
+
+ @Reference
+ public HelloWorld helloWorldWS;
+
+ public String getGreetings(String s) {
+ StatusImpl.appendStatus("At client.getGreetings() pre-invoke", s);
+ String response = helloWorldWS.getGreetings(s);
+ StatusImpl.appendStatus("At client.getGreetings() post-invoke", response);
+ return response;
+ }
+
+ public String getGreetingsException(String s) throws HelloWorldException {
+ StatusImpl.appendStatus("At client.getGreetingsException() pre-invoke", s);
+ try {
+ String response = helloWorldWS.getGreetingsException(s);
+ StatusImpl.appendStatus("At client.getGreetingsException() post-invoke", response);
+ return response;
+ } catch (HelloWorldException ex){
+ StatusImpl.appendStatus("At client.getGreetingsException() post-exception", ex.getMessage());
+ throw ex;
+ }
+ }
+}
diff --git a/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/helloworld/HelloWorldException.java b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/helloworld/HelloWorldException.java new file mode 100644 index 0000000000..b4a9fec640 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/helloworld/HelloWorldException.java @@ -0,0 +1,34 @@ +/*
+ * 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;
+
+
+public class HelloWorldException extends Exception {
+
+ private static final long serialVersionUID = 4608283774062947117L;
+
+ public HelloWorldException(){
+ }
+
+ public HelloWorldException(String message){
+ super(message);
+ }
+
+}
diff --git a/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/helloworld/HelloWorldService.java b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..e4fb70af09 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/helloworld/HelloWorldService.java @@ -0,0 +1,42 @@ +/*
+ * 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.RequestContext;
+import org.oasisopen.sca.annotation.Context;
+
+public class HelloWorldService implements HelloWorld {
+
+ @Context
+ protected RequestContext requestContext;
+
+ public String getGreetings(String s) {
+ //Subject subject = requestContext.getSecuritySubject();
+ String response = "Hello " + s;
+ StatusImpl.appendStatus("At service.getGreetings()", response);
+ return response;
+ }
+
+ public String getGreetingsException(String s) throws HelloWorldException {
+ String response = "Hello " + s;
+ StatusImpl.appendStatus("At service.getGreetingsException()", response);
+ throw new HelloWorldException(response);
+ }
+}
diff --git a/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/helloworld/StatusImpl.java b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/helloworld/StatusImpl.java new file mode 100644 index 0000000000..644853d6c2 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/helloworld/StatusImpl.java @@ -0,0 +1,32 @@ +/*
+ * 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;
+
+public class StatusImpl {
+
+ public static String statusString = "";
+
+ public static void appendStatus(String event, String location){
+ // remove any addresses from the strings
+ location = location.replaceAll("\\(@.*Endpoint", "Endpoint");
+ statusString += event + " - " + location + "\n";
+ }
+
+}
diff --git a/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testbindingwspolicy/TestBindingWSAxisHandler.java b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testbindingwspolicy/TestBindingWSAxisHandler.java new file mode 100644 index 0000000000..686866e12d --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testbindingwspolicy/TestBindingWSAxisHandler.java @@ -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 testbindingwspolicy;
+
+import helloworld.StatusImpl;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.handlers.AbstractHandler;
+
+/**
+ * An Axis handler to show that policy can add one of needs be
+ *
+ * @version $Rev: 881959 $ $Date: 2009-11-18 22:07:09 +0000 (Wed, 18 Nov 2009) $
+ */
+public class TestBindingWSAxisHandler extends AbstractHandler
+{
+ private String name;
+
+ public TestBindingWSAxisHandler(String name)
+ {
+ this.name = name;
+ }
+
+ public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
+ StatusImpl.appendStatus("TestAxisHandler.invoke()", name);
+ return InvocationResponse.CONTINUE;
+ }
+}
diff --git a/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testbindingwspolicy/TestBindingWSPolicy.java b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testbindingwspolicy/TestBindingWSPolicy.java new file mode 100644 index 0000000000..c7803f03bc --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testbindingwspolicy/TestBindingWSPolicy.java @@ -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 testbindingwspolicy;
+
+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 TestBindingWSPolicy {
+ static final String SCA11_NS = Base.SCA11_NS;
+ static final String SCA11_TUSCANY_NS = Base.SCA11_TUSCANY_NS;
+ static final QName TEST_BINDINGWS_POLICY_QNAME = new QName(SCA11_TUSCANY_NS, "testBindingWSPolicy");
+
+ private String testString;
+
+ public String getTestString() {
+ return testString;
+ }
+
+ public void setTestString(String testString) {
+ this.testString = testString;
+ }
+
+ public QName getSchemaName() {
+ return TEST_BINDINGWS_POLICY_QNAME;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+
+ @Override
+ public String toString() {
+ return "TestBindingWSPolicy [testString=" +
+ testString
+ + "]";
+ }
+}
diff --git a/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testbindingwspolicy/TestBindingWSPolicyBuilder.java b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testbindingwspolicy/TestBindingWSPolicyBuilder.java new file mode 100644 index 0000000000..4fdcde678d --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testbindingwspolicy/TestBindingWSPolicyBuilder.java @@ -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 testbindingwspolicy;
+
+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 TestBindingWSPolicyBuilder implements PolicyBuilder<TestBindingWSPolicy> {
+
+ public boolean build(Endpoint endpoint, BuilderContext context) {
+ List<TestBindingWSPolicy> polices = getPolicies(endpoint);
+ System.out.println(endpoint + ": " + polices);
+ return true;
+ }
+
+ public boolean build(EndpointReference endpointReference, BuilderContext context) {
+ List<TestBindingWSPolicy> polices = getPolicies(endpointReference);
+ System.out.println(endpointReference + ": " + polices);
+ return true;
+ }
+
+ public boolean build(Component component, Implementation implementation, BuilderContext context) {
+ List<TestBindingWSPolicy> polices = getPolicies(implementation);
+ System.out.println(implementation + ": " + polices);
+ return true;
+ }
+
+ public QName getPolicyType() {
+ return TestBindingWSPolicy.TEST_BINDINGWS_POLICY_QNAME;
+ }
+
+ public List<QName> getSupportedBindings() {
+ return null;
+ }
+
+ private List<TestBindingWSPolicy> getPolicies(PolicySubject subject) {
+ List<TestBindingWSPolicy> polices = new ArrayList<TestBindingWSPolicy>();
+ for (PolicySet ps : subject.getPolicySets()) {
+ for (PolicyExpression exp : ps.getPolicies()) {
+ if (getPolicyType().equals(exp.getName())) {
+ polices.add((TestBindingWSPolicy)exp.getPolicy());
+ }
+ }
+ }
+ return polices;
+ }
+
+ public boolean build(EndpointReference endpointReference, Endpoint endpoint, BuilderContext context) {
+ return true;
+ }
+
+}
diff --git a/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testbindingwspolicy/TestBindingWSPolicyInterceptor.java b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testbindingwspolicy/TestBindingWSPolicyInterceptor.java new file mode 100644 index 0000000000..aa33c74aea --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testbindingwspolicy/TestBindingWSPolicyInterceptor.java @@ -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 testbindingwspolicy;
+
+import helloworld.StatusImpl;
+
+import java.util.List;
+
+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.core.invocation.InterceptorAsyncImpl;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+
+public class TestBindingWSPolicyInterceptor extends InterceptorAsyncImpl implements PhasedInterceptor {
+
+ private Operation operation;
+ private List<TestBindingWSPolicy> policies;
+ private PolicySubject subject;
+ private String context;
+ private String phase;
+
+ public TestBindingWSPolicyInterceptor(PolicySubject subject,
+ String context,
+ Operation operation,
+ List<TestBindingWSPolicy> 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 processRequest(Message msg) {
+ StatusImpl.appendStatus("TestBindingWSPolicyInterceptor.processRequest()", context + " @ " + phase);
+ return msg;
+ }
+
+ public Message processResponse(Message msg) {
+ StatusImpl.appendStatus("TestBindingWSPolicyInterceptor.processResponse()", context + " @ " + phase);
+ return msg;
+ }
+
+ public String getPhase() {
+ return phase;
+ }
+
+}
diff --git a/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testbindingwspolicy/TestBindingWSPolicyProcessor.java b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testbindingwspolicy/TestBindingWSPolicyProcessor.java new file mode 100644 index 0000000000..2b013f7ba2 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testbindingwspolicy/TestBindingWSPolicyProcessor.java @@ -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 testbindingwspolicy;
+
+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 TestBindingWSPolicyProcessor implements StAXArtifactProcessor<TestBindingWSPolicy> {
+
+ public QName getArtifactType() {
+ return TestBindingWSPolicy.TEST_BINDINGWS_POLICY_QNAME;
+ }
+
+ public TestBindingWSPolicyProcessor(FactoryExtensionPoint modelFactories) {
+ }
+
+
+ public TestBindingWSPolicy read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ TestBindingWSPolicy policy = new TestBindingWSPolicy();
+ 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 ( TestBindingWSPolicy.TEST_BINDINGWS_POLICY_QNAME.equals(reader.getName()) ) {
+ break;
+ }
+ }
+
+ //Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+
+ return policy;
+ }
+
+ public void write(TestBindingWSPolicy policy, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+ // TODO
+ }
+
+ public Class<TestBindingWSPolicy> getModelType() {
+ return TestBindingWSPolicy.class;
+ }
+
+ public void resolve(TestBindingWSPolicy arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException {
+
+ }
+
+}
diff --git a/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testbindingwspolicy/TestBindingWSPolicyProviderFactory.java b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testbindingwspolicy/TestBindingWSPolicyProviderFactory.java new file mode 100644 index 0000000000..df626a10ff --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testbindingwspolicy/TestBindingWSPolicyProviderFactory.java @@ -0,0 +1,69 @@ +/*
+ * 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 testbindingwspolicy;
+
+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 TestBindingWSPolicyProviderFactory implements PolicyProviderFactory<TestBindingWSPolicy> {
+ private ExtensionPointRegistry registry;
+
+ public TestBindingWSPolicyProviderFactory(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) {
+ // no implementation provider for this binding specific policy
+ return null;
+ }
+
+ /**
+ * @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 TestBindingWSPolicyProviderReference(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 TestBindingWSPolicyProviderService(endpoint);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType()
+ */
+ public Class<TestBindingWSPolicy> getModelType() {
+ return TestBindingWSPolicy.class;
+ }
+
+}
diff --git a/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testbindingwspolicy/TestBindingWSPolicyProviderReference.java b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testbindingwspolicy/TestBindingWSPolicyProviderReference.java new file mode 100644 index 0000000000..489c069ea8 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testbindingwspolicy/TestBindingWSPolicyProviderReference.java @@ -0,0 +1,72 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package testbindingwspolicy;
+
+import helloworld.StatusImpl;
+
+import java.util.List;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.binding.ws.axis2.provider.Axis2BaseBindingProvider;
+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 TestBindingWSPolicyProviderReference extends BasePolicyProvider<TestBindingWSPolicy> {
+
+ public TestBindingWSPolicyProviderReference(EndpointReference endpointReference) {
+ super(TestBindingWSPolicy.class, endpointReference);
+ }
+
+ public void configureBinding(Object configuration) {
+ super.configureBinding(configuration);
+
+ StatusImpl.appendStatus("TestBindingWSPolicyProviderReference.configureBinding()", configuration.getClass().getName());
+
+ Axis2BaseBindingProvider bindingProvider = (Axis2BaseBindingProvider)configuration;
+ ConfigurationContext axisConfigurationContext = bindingProvider.getAxisConfigurationContext();
+ AxisConfiguration axisConfiguration = axisConfigurationContext.getAxisConfiguration();
+ List<org.apache.axis2.engine.Phase> outPhases = axisConfiguration.getOutFlowPhases();
+ outPhases.get(0).addHandler(new TestBindingWSAxisHandler("Reference OutFlow Handler"));
+ List<org.apache.axis2.engine.Phase> inPhases = axisConfiguration.getInFlowPhases();
+ inPhases.get(0).addHandler(new TestBindingWSAxisHandler("Reference InFlow Handler"));
+ List<org.apache.axis2.engine.Phase> inFaultPhases = axisConfiguration.getInFaultFlowPhases();
+ inFaultPhases.get(0).addHandler(new TestBindingWSAxisHandler("Reference InFaultFlow Handler"));
+ }
+
+ public PhasedInterceptor createBindingInterceptor() {
+ List<TestBindingWSPolicy> policies = findPolicies();
+
+ if (policies.isEmpty()){
+ return null;
+ } else {
+ return new TestBindingWSPolicyInterceptor(subject,
+ getContext(),
+ null,
+ policies,
+ Phase.REFERENCE_BINDING_POLICY);
+ }
+ }
+}
diff --git a/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testbindingwspolicy/TestBindingWSPolicyProviderService.java b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testbindingwspolicy/TestBindingWSPolicyProviderService.java new file mode 100644 index 0000000000..9880bf04b0 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testbindingwspolicy/TestBindingWSPolicyProviderService.java @@ -0,0 +1,72 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package testbindingwspolicy;
+
+import helloworld.StatusImpl;
+
+import java.util.List;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.binding.ws.axis2.provider.Axis2BaseBindingProvider;
+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 TestBindingWSPolicyProviderService extends BasePolicyProvider<TestBindingWSPolicy> {
+
+ public TestBindingWSPolicyProviderService(Endpoint endpoint) {
+ super(TestBindingWSPolicy.class, endpoint);
+ }
+
+ public void configureBinding(Object configuration) {
+ super.configureBinding(configuration);
+
+ StatusImpl.appendStatus("TestBindingWSPolicyProviderService.configureBinding()", configuration.getClass().getName());
+
+ Axis2BaseBindingProvider bindingProvider = (Axis2BaseBindingProvider)configuration;
+ ConfigurationContext axisConfigurationContext = bindingProvider.getAxisConfigurationContext();
+ AxisConfiguration axisConfiguration = axisConfigurationContext.getAxisConfiguration();
+ List<org.apache.axis2.engine.Phase> inPhases = axisConfiguration.getInFlowPhases();
+ inPhases.get(0).addHandler(new TestBindingWSAxisHandler("Service InFlow Handler"));
+ List<org.apache.axis2.engine.Phase> outPhases = axisConfiguration.getOutFlowPhases();
+ outPhases.get(0).addHandler(new TestBindingWSAxisHandler("Service OutFlow Handler"));
+ List<org.apache.axis2.engine.Phase> outFaultPhases = axisConfiguration.getOutFaultFlowPhases();
+ outFaultPhases.get(0).addHandler(new TestBindingWSAxisHandler("Service OutFaultFlow Handler"));
+ }
+
+ public PhasedInterceptor createBindingInterceptor() {
+ List<TestBindingWSPolicy> policies = findPolicies();
+
+ if (policies.isEmpty()){
+ return null;
+ } else {
+ return new TestBindingWSPolicyInterceptor(subject,
+ getContext(),
+ null,
+ policies,
+ Phase.SERVICE_BINDING_POLICY);
+ }
+ }
+}
diff --git a/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testpolicy/TestPolicy.java b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testpolicy/TestPolicy.java new file mode 100644 index 0000000000..651208fa76 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testpolicy/TestPolicy.java @@ -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
+ + "]";
+ }
+}
diff --git a/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testpolicy/TestPolicyBuilder.java b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testpolicy/TestPolicyBuilder.java new file mode 100644 index 0000000000..a7cceec4de --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testpolicy/TestPolicyBuilder.java @@ -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;
+ }
+
+}
diff --git a/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testpolicy/TestPolicyInterceptor.java b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testpolicy/TestPolicyInterceptor.java new file mode 100644 index 0000000000..f03247c4d5 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testpolicy/TestPolicyInterceptor.java @@ -0,0 +1,110 @@ +/*
+ * 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 helloworld.StatusImpl;
+
+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.core.invocation.InterceptorAsyncImpl;
+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 extends InterceptorAsyncImpl implements PhasedInterceptor {
+
+ 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 processRequest(Message msg) {
+ String policyStrings = "";
+ for (TestPolicy testPolicy : policies){
+ policyStrings += testPolicy.getTestString() + " ";
+ }
+ StatusImpl.appendStatus("TestPolicyInterceptor.processRequest()", context + " @ " + phase + " testPolicyStringes " + policyStrings);
+ return msg;
+ }
+
+ public Message postProcessRequest(Message msg, Throwable e) throws Throwable {
+ StatusImpl.appendStatus("TestPolicyInterceptor.postProcessRequest()", context + " @ " + phase);
+ return msg;
+ }
+
+ public Message processResponse(Message msg) {
+ String policyStrings = "";
+ for (TestPolicy testPolicy : policies){
+ policyStrings += testPolicy.getTestString() + " ";
+ }
+ StatusImpl.appendStatus("TestPolicyInterceptor.processResponse()", context + " @ " + phase + " testPolicyStringes " + policyStrings);
+ return msg;
+ }
+/* not in interface - should we add it?
+ public Message postProcessResponse(Message msg) {
+ System.out.println("TestPolicyInterceptor.postProcessResponse() " + context + " @ " + phase);
+ return msg;
+ }
+*/
+
+ public String getPhase() {
+ return phase;
+ }
+
+}
diff --git a/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testpolicy/TestPolicyProcessor.java b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testpolicy/TestPolicyProcessor.java new file mode 100644 index 0000000000..df31399959 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testpolicy/TestPolicyProcessor.java @@ -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.getLocalPart().equals("testPolicy") ) {
+ 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 {
+
+ }
+
+}
diff --git a/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testpolicy/TestPolicyProviderFactory.java b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testpolicy/TestPolicyProviderFactory.java new file mode 100644 index 0000000000..75cb298f2d --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testpolicy/TestPolicyProviderFactory.java @@ -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;
+ }
+
+}
diff --git a/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testpolicy/TestPolicyProviderImplementation.java b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testpolicy/TestPolicyProviderImplementation.java new file mode 100644 index 0000000000..b027763d22 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testpolicy/TestPolicyProviderImplementation.java @@ -0,0 +1,56 @@ +/*
+ * 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.getImplementation());
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.PolicyProvider#createInterceptor(org.apache.tuscany.sca.interfacedef.Operation)
+ */
+ public PhasedInterceptor createInterceptor(Operation operation) {
+ List<TestPolicy> policies = findPolicies();
+
+ if (policies.isEmpty()){
+ return null;
+ } else {
+ return new TestPolicyInterceptor(subject,
+ getContext(),
+ operation,
+ policies,
+ Phase.IMPLEMENTATION_POLICY);
+ }
+ }
+
+}
diff --git a/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testpolicy/TestPolicyProviderReference.java b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testpolicy/TestPolicyProviderReference.java new file mode 100644 index 0000000000..3e784aa62e --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testpolicy/TestPolicyProviderReference.java @@ -0,0 +1,53 @@ +/*
+ * 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();
+
+ if (policies.isEmpty()){
+ return null;
+ } else {
+ return new TestPolicyInterceptor(subject,
+ getContext(),
+ operation,
+ policies,
+ Phase.REFERENCE_POLICY);
+ }
+ }
+
+}
diff --git a/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testpolicy/TestPolicyProviderService.java b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testpolicy/TestPolicyProviderService.java new file mode 100644 index 0000000000..5066193aa6 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/java/testpolicy/TestPolicyProviderService.java @@ -0,0 +1,53 @@ +/*
+ * 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();
+
+ if (policies.isEmpty()){
+ return null;
+ } else {
+ return new TestPolicyInterceptor(subject,
+ getContext(),
+ operation,
+ policies,
+ Phase.SERVICE_POLICY);
+ }
+ }
+
+}
diff --git a/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/resources/META-INF/sca-contribution.xml b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..350ad6be96 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/resources/META-INF/sca-contribution.xml @@ -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 diff --git a/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.PolicyBuilder b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.PolicyBuilder new file mode 100644 index 0000000000..d2138222a6 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.PolicyBuilder @@ -0,0 +1,18 @@ +# 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
+testbindingwspolicy.TestBindingWSPolicyBuilder;qname=http://tuscany.apache.org/xmlns/sca/1.1#testBindingWSPolicy
diff --git a/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor new file mode 100644 index 0000000000..afe19cdffc --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor @@ -0,0 +1,21 @@ +# 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 +testbindingwspolicy.TestBindingWSPolicyProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#testBindingWSPolicy,model=testbindingwspolicy.TestBindingWSPolicy +
diff --git a/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions new file mode 100644 index 0000000000..f362b64a1f --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions @@ -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
diff --git a/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory new file mode 100644 index 0000000000..f5c82538be --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory @@ -0,0 +1,21 @@ +# 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
+testbindingwspolicy.TestBindingWSPolicyProviderFactory;model=testbindingwspolicy.TestBindingWSPolicy
+
diff --git a/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/resources/definitions.xml b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/resources/definitions.xml new file mode 100644 index 0000000000..39d3d25a78 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/resources/definitions.xml @@ -0,0 +1,48 @@ +<?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">
+
+ <!-- We're not testing real repliability policy here. Just looking
+ at how the exactly once profile intent is handled. -->
+ <sca:policySet name="TestPolicySet1"
+ attachTo="//sca:binding.ws"
+ provides="sca:exactlyOnce"
+ appliesTo="//sca:binding.ws">
+ <tuscany:testPolicy testString="exactlyonce"/>
+ </sca:policySet>
+
+ <sca:policySet name="TestPolicySet2"
+ attachTo="//sca:binding.ws"
+ provides="sca:atLeastOnce"
+ appliesTo="//sca:binding.ws">
+ <tuscany:testPolicy testString="atleastonce"/>
+ </sca:policySet>
+
+ <sca:policySet name="TestPolicySet3"
+ attachTo="//sca:binding.ws"
+ provides="sca:atMostOnce"
+ appliesTo="//sca:binding.ws">
+ <tuscany:testPolicy testString="atmostonce"/>
+ </sca:policySet>
+
+</definitions>
\ No newline at end of file diff --git a/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/resources/helloworld.composite b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/resources/helloworld.composite new file mode 100644 index 0000000000..28fef03db5 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/resources/helloworld.composite @@ -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="exactlyOnce"/>
+ </component>
+
+ <component name="HelloWorldService">
+ <implementation.java class="helloworld.HelloWorldService"/>
+ <service name="HelloWorld" requires="exactlyOnce">
+ <binding.ws name="BindingWS"/>
+ </service>
+ </component>
+
+</composite>
diff --git a/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/resources/helloworld.wsdl b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/resources/helloworld.wsdl new file mode 100644 index 0000000000..15b89dbcea --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/main/resources/helloworld.wsdl @@ -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>
diff --git a/sca-java-2.x/trunk/testing/itest/policy/reliability/src/test/java/interceptors/HelloworldTestCase.java b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/test/java/interceptors/HelloworldTestCase.java new file mode 100644 index 0000000000..dd79f7d622 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/policy/reliability/src/test/java/interceptors/HelloworldTestCase.java @@ -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 interceptors;
+
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import helloworld.HelloWorld;
+import helloworld.HelloWorldException;
+import helloworld.StatusImpl;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.node.impl.NodeImpl;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.junit.Ignore;
+
+public class HelloworldTestCase extends TestCase {
+
+ private Node node;
+ private HelloWorld helloWorld;
+
+ @Override
+ protected void setUp() throws Exception {
+ StatusImpl.statusString = "";
+
+ node = NodeFactory.newInstance().createNode("helloworld.composite", new Contribution("test", "target/classes"));
+ node.start();
+ helloWorld = node.getService(HelloWorld.class, "HelloWorldClient/HelloWorld");
+ }
+
+ /*
+ * We're not testing real reliability policy here. Just checking that the
+ * exactlyOnce profile intent is handled correctly and presented as its
+ * constituent atMostOnce and atLeastOnce intents.
+ */
+ public void testReliabilityIntent() throws Exception {
+ // check response from application
+ assertEquals("Hello fred", helloWorld.getGreetings("fred"));
+
+ // check sequences of interceptors
+ System.out.println(StatusImpl.statusString);
+ assertTrue(StatusImpl.statusString.contains("atmostonce exactlyonce atleastonce"));
+
+ // check final intents on endpoint reference to see if the matching process
+ // results on the right set
+ Composite domainComposite = ((NodeImpl)node).getDomainComposite();
+ List<Intent> intents = domainComposite.getComponents().get(0).getReferences().get(0).getEndpointReferences().get(0).getRequiredIntents();
+
+ assertEquals(2, intents.size());
+ assertEquals("atMostOnce", intents.get(0).getName().getLocalPart());
+ assertEquals("atLeastOnce", intents.get(1).getName().getLocalPart());
+
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ }
+
+}
|