From f7e7402c450c81c4ca5a58adb7b3603db94a44f5 Mon Sep 17 00:00:00 2001 From: slaws Date: Mon, 11 Jul 2011 10:41:30 +0000 Subject: TUSCANY-3883 - Add wireFormat support to default binding. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1145115 13f79535-47bb-0310-9956-ffa450edef68 --- .../binding/sca/wireformat/WireFormatDefault.java | 49 +++++++++++++++ .../sca/wireformat/WireFormatDefaultProcessor.java | 71 ++++++++++++++++++++++ .../tuscany/sca/binding/sca/xml/ReadTestCase.java | 10 +-- 3 files changed, 126 insertions(+), 4 deletions(-) create mode 100644 sca-java-2.x/trunk/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/wireformat/WireFormatDefault.java create mode 100644 sca-java-2.x/trunk/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/wireformat/WireFormatDefaultProcessor.java (limited to 'sca-java-2.x/trunk/modules/binding-sca-runtime/src/test/java/org/apace/tuscany') diff --git a/sca-java-2.x/trunk/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/wireformat/WireFormatDefault.java b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/wireformat/WireFormatDefault.java new file mode 100644 index 0000000000..1cb4df39e0 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/wireformat/WireFormatDefault.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apace.tuscany.sca.binding.sca.wireformat; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.assembly.WireFormat; +import org.apache.tuscany.sca.assembly.xml.Constants; + +/** + * + * @version $Rev: 986685 $ $Date: 2010-08-18 15:00:03 +0100 (Wed, 18 Aug 2010) $ + */ +public class WireFormatDefault implements WireFormat { + public static final QName WIRE_FORMAT_DEFAULT_QNAME = new QName(Constants.SCA11_NS, "wireFormat.default"); + + + public QName getSchemaName() { + return WIRE_FORMAT_DEFAULT_QNAME; + } + + public boolean isUnresolved() { + return false; + } + + public void setUnresolved(boolean unresolved) { + } + + @Override + public boolean equals(Object obj) { + return this.getClass() == obj.getClass(); + } +} diff --git a/sca-java-2.x/trunk/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/wireformat/WireFormatDefaultProcessor.java b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/wireformat/WireFormatDefaultProcessor.java new file mode 100644 index 0000000000..6c8bd13197 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/wireformat/WireFormatDefaultProcessor.java @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apace.tuscany.sca.binding.sca.wireformat; + +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.assembly.xml.Constants; +import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor; +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: 825773 $ $Date: 2009-10-16 06:42:26 +0100 (Fri, 16 Oct 2009) $ + */ +public class WireFormatDefaultProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor { + + public QName getArtifactType() { + return WireFormatDefault.WIRE_FORMAT_DEFAULT_QNAME; + } + + public WireFormatDefaultProcessor(FactoryExtensionPoint modelFactories) { + } + + public WireFormatDefault read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException { + WireFormatDefault wireFormat = new WireFormatDefault(); + + return wireFormat; + } + + public void write(WireFormatDefault wireFormat, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException { + String prefix = "tuscany"; + writer.writeStartElement(prefix, getArtifactType().getLocalPart(), getArtifactType().getNamespaceURI()); + writer.writeNamespace("tuscany", Constants.SCA11_TUSCANY_NS); + + writer.writeEndElement(); + } + + public Class getModelType() { + return WireFormatDefault.class; + } + + public void resolve(WireFormatDefault arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException { + + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/xml/ReadTestCase.java b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/xml/ReadTestCase.java index 895a551f79..c60885f5a4 100644 --- a/sca-java-2.x/trunk/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/xml/ReadTestCase.java +++ b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/xml/ReadTestCase.java @@ -61,7 +61,7 @@ public class ReadTestCase { } @Test - public void testReadComponentType() throws Exception { + public void testReadComponentType() throws Exception { InputStream is = getClass().getResourceAsStream("/CalculatorServiceImpl.componentType"); XMLStreamReader reader = inputFactory.createXMLStreamReader(is); ComponentType componentType = (ComponentType)staxProcessor.read(reader, context); @@ -71,8 +71,8 @@ public class ReadTestCase { assertNotNull(referenceSCABinding); SCABinding serviceSCABinding = (SCABinding) componentType.getServices().get(0).getBindings().get(0); - assertNotNull(serviceSCABinding); - + assertNotNull(serviceSCABinding); + //new PrintUtil(System.out).print(componentType); } @@ -87,7 +87,9 @@ public class ReadTestCase { SCABinding serviceSCABinding = (SCABinding) composite.getComponents().get(1).getServices().get(0).getBindings().get(0); Assert.assertNotNull(referenceSCABinding); - Assert.assertNotNull(serviceSCABinding); + Assert.assertNotNull(serviceSCABinding); + + assertNotNull(serviceSCABinding.getRequestWireFormat()); } } -- cgit v1.2.3