Author: slaws
Date: Tue Jun 21 16:08:48 2011
New Revision: 1138071
URL: http://svn.apache.org/viewvc?rev=1138071&view=rev
Log:
Add a binding.ws specific policy set and capture the order in which the
interceptors should be called so that this can be explicitly checked by the
test. The test also looks at the result of the matchin process which is not
correct at present because "appliesTo" processing is not performed for runtime
resolved references.
Added:
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/StatusImpl.java
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSAxisHandler.java
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicy.java
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyBuilder.java
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyInterceptor.java
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyProcessor.java
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyProviderFactory.java
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyProviderReference.java
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyProviderService.java
Modified:
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/pom.xml
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/TestPolicyInterceptor.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/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.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/test/java/interceptors/HelloworldTestCase.java
Modified: 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=1138071&r1=1138070&r2=1138071&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/pom.xml
(original)
+++ tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/pom.xml Tue
Jun 21 16:08:48 2011
@@ -21,7 +21,7 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.tuscany.sca</groupId>
- <artifactId>itest-policy</artifactId>
+ <artifactId>tuscany-itest</artifactId>
<version>2.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
Modified:
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=1138071&r1=1138070&r2=1138071&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorldClient.java
(original)
+++
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorldClient.java
Tue Jun 21 16:08:48 2011
@@ -30,7 +30,7 @@ public class HelloWorldClient implements
public String getGreetings(String s) {
String response = helloWorldWS.getGreetings(s);
- System.out.println("At client: " + response);
+ StatusImpl.appendStatus("At client", response);
return response;
}
Modified:
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=1138071&r1=1138070&r2=1138071&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorldService.java
(original)
+++
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/HelloWorldService.java
Tue Jun 21 16:08:48 2011
@@ -32,8 +32,7 @@ public class HelloWorldService implement
public String getGreetings(String name) {
Subject subject = requestContext.getSecuritySubject();
String response = "Hello " + name;
-
- System.out.println("At service: " + response);
+ StatusImpl.appendStatus("At service", response);
return response;
}
}
Added:
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/StatusImpl.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/StatusImpl.java?rev=1138071&view=auto
==============================================================================
---
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/StatusImpl.java
(added)
+++
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/helloworld/StatusImpl.java
Tue Jun 21 16:08:48 2011
@@ -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";
+ }
+
+}
Added:
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSAxisHandler.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSAxisHandler.java?rev=1138071&view=auto
==============================================================================
---
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSAxisHandler.java
(added)
+++
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSAxisHandler.java
Tue Jun 21 16:08:48 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 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;
+ }
+}
Added:
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicy.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicy.java?rev=1138071&view=auto
==============================================================================
---
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicy.java
(added)
+++
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicy.java
Tue Jun 21 16:08:48 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 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
+ + "]";
+ }
+}
Added:
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyBuilder.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyBuilder.java?rev=1138071&view=auto
==============================================================================
---
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyBuilder.java
(added)
+++
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyBuilder.java
Tue Jun 21 16:08:48 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 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;
+ }
+
+}
Added:
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyInterceptor.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyInterceptor.java?rev=1138071&view=auto
==============================================================================
---
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyInterceptor.java
(added)
+++
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyInterceptor.java
Tue Jun 21 16:08:48 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 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;
+ }
+
+}
Added:
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyProcessor.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyProcessor.java?rev=1138071&view=auto
==============================================================================
---
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyProcessor.java
(added)
+++
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyProcessor.java
Tue Jun 21 16:08:48 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 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 {
+
+ }
+
+}
Added:
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyProviderFactory.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyProviderFactory.java?rev=1138071&view=auto
==============================================================================
---
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyProviderFactory.java
(added)
+++
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyProviderFactory.java
Tue Jun 21 16:08:48 2011
@@ -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;
+ }
+
+}
Added:
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyProviderReference.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyProviderReference.java?rev=1138071&view=auto
==============================================================================
---
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyProviderReference.java
(added)
+++
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyProviderReference.java
Tue Jun 21 16:08:48 2011
@@ -0,0 +1,70 @@
+/*
+ * 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"));
+ }
+
+ public PhasedInterceptor createBindingInterceptor() {
+ List<TestBindingWSPolicy> policies = findPolicies();
+
+ if (policies.isEmpty()){
+ return null;
+ } else {
+ return new TestBindingWSPolicyInterceptor(subject,
+ getContext(),
+ null,
+ policies,
+ Phase.REFERENCE_BINDING_POLICY);
+ }
+ }
+}
Added:
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyProviderService.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyProviderService.java?rev=1138071&view=auto
==============================================================================
---
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyProviderService.java
(added)
+++
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testbindingwspolicy/TestBindingWSPolicyProviderService.java
Tue Jun 21 16:08:48 2011
@@ -0,0 +1,70 @@
+/*
+ * 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"));
+ }
+
+ public PhasedInterceptor createBindingInterceptor() {
+ List<TestBindingWSPolicy> policies = findPolicies();
+
+ if (policies.isEmpty()){
+ return null;
+ } else {
+ return new TestBindingWSPolicyInterceptor(subject,
+ getContext(),
+ null,
+ policies,
+ Phase.SERVICE_BINDING_POLICY);
+ }
+ }
+}
Modified:
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=1138071&r1=1138070&r2=1138071&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyInterceptor.java
(original)
+++
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyInterceptor.java
Tue Jun 21 16:08:48 2011
@@ -18,6 +18,8 @@
*/
package testpolicy;
+import helloworld.StatusImpl;
+
import java.util.List;
import java.util.logging.ConsoleHandler;
import java.util.logging.Handler;
@@ -29,6 +31,7 @@ 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;
@@ -36,12 +39,8 @@ import org.apache.tuscany.sca.invocation
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;
+public class TestPolicyInterceptor extends InterceptorAsyncImpl implements
PhasedInterceptor {
+
private Operation operation;
private List<TestPolicy> policies;
private PolicySubject subject;
@@ -75,18 +74,26 @@ public class TestPolicyInterceptor imple
return null;
}
- public Message invoke(Message msg) {
- System.out.println("In interceptor at " + subject.toString());
- return getNext().invoke(msg);
- }
-
- public Invoker getNext() {
- return next;
- }
-
- public void setNext(Invoker next) {
- this.next = next;
+ public Message processRequest(Message msg) {
+ StatusImpl.appendStatus("TestPolicyInterceptor.processRequest()",
context + " @ " + phase);
+ return msg;
+ }
+
+ public Message postProcessRequest(Message msg, Throwable e) throws
Throwable {
+ StatusImpl.appendStatus("TestPolicyInterceptor.postProcessRequest()",
context + " @ " + phase);
+ return msg;
+ }
+
+ public Message processResponse(Message msg) {
+ StatusImpl.appendStatus("TestPolicyInterceptor.processResponse()",
context + " @ " + phase);
+ 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;
Modified:
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=1138071&r1=1138070&r2=1138071&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyProviderImplementation.java
(original)
+++
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyProviderImplementation.java
Tue Jun 21 16:08:48 2011
@@ -41,11 +41,16 @@ public class TestPolicyProviderImplement
*/
public PhasedInterceptor createInterceptor(Operation operation) {
List<TestPolicy> policies = findPolicies();
- return policies.isEmpty() ? null : new TestPolicyInterceptor(subject,
-
getContext(),
- operation,
- policies,
-
Phase.IMPLEMENTATION_POLICY);
+
+ if (policies.isEmpty()){
+ return null;
+ } else {
+ return new TestPolicyInterceptor(subject,
+ getContext(),
+ operation,
+ policies,
+ Phase.IMPLEMENTATION_POLICY);
+ }
}
}
Modified:
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=1138071&r1=1138070&r2=1138071&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyProviderReference.java
(original)
+++
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyProviderReference.java
Tue Jun 21 16:08:48 2011
@@ -38,8 +38,16 @@ public class TestPolicyProviderReference
public PhasedInterceptor createInterceptor(Operation operation) {
List<TestPolicy> policies = findPolicies();
- return policies.isEmpty() ? null : new TestPolicyInterceptor(subject,
getContext(), operation,
- policies,
Phase.REFERENCE_POLICY);
+
+ if (policies.isEmpty()){
+ return null;
+ } else {
+ return new TestPolicyInterceptor(subject,
+ getContext(),
+ operation,
+ policies,
+ Phase.REFERENCE_POLICY);
+ }
}
}
Modified:
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=1138071&r1=1138070&r2=1138071&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyProviderService.java
(original)
+++
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/java/testpolicy/TestPolicyProviderService.java
Tue Jun 21 16:08:48 2011
@@ -38,7 +38,16 @@ public class TestPolicyProviderService e
public PhasedInterceptor createInterceptor(Operation operation) {
List<TestPolicy> policies = findPolicies();
- return policies.isEmpty() ? null : new TestPolicyInterceptor(subject,
getContext(), operation, policies, Phase.SERVICE_POLICY);
+
+ if (policies.isEmpty()){
+ return null;
+ } else {
+ return new TestPolicyInterceptor(subject,
+ getContext(),
+ operation,
+ policies,
+ Phase.SERVICE_POLICY);
+ }
}
}
Modified:
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=1138071&r1=1138070&r2=1138071&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.PolicyBuilder
(original)
+++
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 21 16:08:48 2011
@@ -15,3 +15,4 @@
# 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
Modified:
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=1138071&r1=1138070&r2=1138071&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
(original)
+++
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 21 16:08:48 2011
@@ -17,4 +17,5 @@
# 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
Modified:
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=1138071&r1=1138070&r2=1138071&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory
(original)
+++
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory
Tue Jun 21 16:08:48 2011
@@ -17,4 +17,5 @@
# Implementation class for the policy extension
testpolicy.TestPolicyProviderFactory;model=testpolicy.TestPolicy
+testbindingwspolicy.TestBindingWSPolicyProviderFactory;model=testbindingwspolicy.TestBindingWSPolicy
Modified:
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=1138071&r1=1138070&r2=1138071&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/definitions.xml
(original)
+++
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/definitions.xml
Tue Jun 21 16:08:48 2011
@@ -26,18 +26,36 @@
<description>a test intent</description>
</intent>
- <sca:policySet name="TestInteractonPolicySet"
+ <sca:policySet name="TestInteractonPolicySet1"
attachTo="//sca:binding.ws"
provides="tuscany:testIntent"
appliesTo="//sca:binding.ws">
<tuscany:testPolicy testString="interaction"/>
</sca:policySet>
+
+ <sca:policySet name="TestInteractonPolicySet2"
+ attachTo="//sca:binding.ws"
+ provides="tuscany:testIntent"
+ appliesTo="//sca:binding.ws">
+ <tuscany:testBindingWSPolicy testString="interaction"/>
+ </sca:policySet>
- <sca:policySet name="TestImplementationPolicySet"
+ <!--
+ don't seem to be able to attach the following to binding.sca probably
because
+ attachment is performed before the default binding models are created
+ -->
+ <sca:policySet name="TestInteractonPolicySet3"
+ attachTo="//sca:component"
+ provides="tuscany:testIntent"
+ appliesTo="//sca:binding.sca">
+ <tuscany:testPolicy testString="interaction"/>
+ </sca:policySet>
+
+ <sca:policySet name="TestImplementationPolicySet2"
attachTo="//sca:implementation.java"
provides="tuscany:testIntent"
appliesTo="//sca:implementation.java">
<tuscany:testPolicy testString="implementation"/>
- </sca:policySet>
-
+ </sca:policySet>
+
</definitions>
\ No newline at end of file
Modified:
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=1138071&r1=1138070&r2=1138071&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/helloworld.composite
(original)
+++
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/main/resources/helloworld.composite
Tue Jun 21 16:08:48 2011
@@ -26,11 +26,11 @@
<component name="HelloWorldClient">
<implementation.java class="helloworld.HelloWorldClient"/>
<reference name="helloWorldWS"
- target="HelloWorldService/HelloWorld/BindingWS"
+ target="HelloWorldService2/HelloWorld/BindingWS"
requires="tuscany:testIntent"/>
</component>
- <component name="HelloWorldService">
+ <component name="HelloWorldService1">
<implementation.java class="helloworld.HelloWorldService"
requires="tuscany:testIntent"/>
<service name="HelloWorld" requires="tuscany:testIntent">
@@ -38,4 +38,11 @@
</service>
</component>
+ <component name="HelloWorldService2" requires="tuscany:testIntent">
+ <implementation.java class="helloworld.HelloWorldService"/>
+ <service name="HelloWorld">
+ <binding.ws name="BindingWS"/>
+ </service>
+ </component>
+
</composite>
Modified:
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=1138071&r1=1138070&r2=1138071&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/test/java/interceptors/HelloworldTestCase.java
(original)
+++
tuscany/sca-java-2.x/trunk/testing/itest/policy/interceptors/src/test/java/interceptors/HelloworldTestCase.java
Tue Jun 21 16:08:48 2011
@@ -19,12 +19,21 @@
package interceptors;
+import java.util.List;
+
+import junit.framework.Assert;
import junit.framework.TestCase;
import helloworld.HelloWorld;
+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.PolicySet;
import org.junit.Ignore;
public class HelloworldTestCase extends TestCase {
@@ -34,13 +43,55 @@ public class HelloworldTestCase extends
@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");
}
public void testCalculator() throws Exception {
+ // check response from application
assertEquals("Hello fred", helloWorld.getGreetings("fred"));
+
+ // check sequences of interceptors
+ System.out.println(StatusImpl.statusString);
+ assertEquals("TestBindingWSPolicyProviderService.configureBinding() -
org.apache.tuscany.sca.binding.ws.axis2.provider.Axis2ServiceBindingProvider\n"
+
+ "TestBindingWSPolicyProviderService.configureBinding() -
org.apache.tuscany.sca.binding.ws.axis2.provider.Axis2ServiceBindingProvider\n"
+
+ "TestPolicyInterceptor.processRequest() -
HelloWorldClient#reference-binding($self$.HelloWorld/HelloWorld) @
reference.policy\n" +
+ "TestPolicyInterceptor.processRequest() -
HelloWorldClient#service-binding(HelloWorld/HelloWorld) @ service.policy\n" +
+ "TestPolicyInterceptor.processRequest() - null @
implementation.policy\n" +
+ "TestBindingWSPolicyProviderReference.configureBinding()
-
org.apache.tuscany.sca.binding.ws.axis2.provider.Axis2ReferenceBindingProvider\n"
+
+ "TestPolicyInterceptor.processRequest() -
HelloWorldClient#reference-binding(helloWorldWS/BindingWS) @
reference.policy\n" +
+ "TestBindingWSPolicyInterceptor.processRequest() -
HelloWorldClient#reference-binding(helloWorldWS/BindingWS) @
reference.binding.policy\n" +
+ "TestAxisHandler.invoke() - Reference OutFlow Handler\n" +
+ "TestAxisHandler.invoke() - Service InFlow Handler\n" +
+ "TestBindingWSPolicyInterceptor.processRequest() -
HelloWorldService2#service-binding(HelloWorld/BindingWS) @
service.binding.policy\n" +
+ "TestPolicyInterceptor.processRequest() -
HelloWorldService2#service-binding(HelloWorld/BindingWS) @ service.policy\n" +
+ "TestPolicyInterceptor.processRequest() - null @
implementation.policy\n" +
+ "At service - Hello fred\n" +
+ "TestPolicyInterceptor.processResponse() - null @
implementation.policy\n" +
+ "TestPolicyInterceptor.processResponse() -
HelloWorldService2#service-binding(HelloWorld/BindingWS) @ service.policy\n" +
+ "TestBindingWSPolicyInterceptor.processResponse() -
HelloWorldService2#service-binding(HelloWorld/BindingWS) @
service.binding.policy\n" +
+ "TestAxisHandler.invoke() - Service OutFlow Handler\n" +
+ "TestAxisHandler.invoke() - Reference InFlow Handler\n" +
+ "TestBindingWSPolicyInterceptor.processResponse() -
HelloWorldClient#reference-binding(helloWorldWS/BindingWS) @
reference.binding.policy\n" +
+ "TestPolicyInterceptor.processResponse() -
HelloWorldClient#reference-binding(helloWorldWS/BindingWS) @
reference.policy\n" +
+ "At client - Hello fred\n" +
+ "TestPolicyInterceptor.processResponse() - null @
implementation.policy\n" +
+ "TestPolicyInterceptor.processResponse() -
HelloWorldClient#service-binding(HelloWorld/HelloWorld) @ service.policy\n" +
+ "TestPolicyInterceptor.processResponse() -
HelloWorldClient#reference-binding($self$.HelloWorld/HelloWorld) @
reference.policy\n",
+ StatusImpl.statusString);
+
+ // check final intents on endpoint reference to see if the matching
process
+ // results on the right set
+ Composite domainComposite = ((NodeImpl)node).getDomainComposite();
+ List<PolicySet> policySets =
domainComposite.getComponents().get(0).getReferences().get(0).getEndpointReferences().get(0).getPolicySets();
+
+ assertEquals(2, policySets.size());
+ assertEquals("TestInteractonPolicySet2",
policySets.get(0).getName().getLocalPart());
+ assertEquals("TestInteractonPolicySet1",
policySets.get(1).getName().getLocalPart());
+
}
@Override