summaryrefslogtreecommitdiffstats
path: root/tags/java/sca/2.0-M4-RC1/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml
diff options
context:
space:
mode:
Diffstat (limited to 'tags/java/sca/2.0-M4-RC1/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml')
-rw-r--r--tags/java/sca/2.0-M4-RC1/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/BeanXMLStreamReaderTestCase.java188
-rw-r--r--tags/java/sca/2.0-M4-RC1/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/DOM2StAXTestCase.java116
-rw-r--r--tags/java/sca/2.0-M4-RC1/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/DataPipeTestCase.java96
-rw-r--r--tags/java/sca/2.0-M4-RC1/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/JavaBean2XMLStreamReaderTestCase.java137
-rw-r--r--tags/java/sca/2.0-M4-RC1/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/Node2StringTestCase.java41
-rw-r--r--tags/java/sca/2.0-M4-RC1/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/PushTransformationTestCase.java81
-rw-r--r--tags/java/sca/2.0-M4-RC1/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/TraxTransformerTestCase.java99
7 files changed, 0 insertions, 758 deletions
diff --git a/tags/java/sca/2.0-M4-RC1/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/BeanXMLStreamReaderTestCase.java b/tags/java/sca/2.0-M4-RC1/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/BeanXMLStreamReaderTestCase.java
deleted file mode 100644
index 95f21ff4c9..0000000000
--- a/tags/java/sca/2.0-M4-RC1/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/BeanXMLStreamReaderTestCase.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.databinding.xml;
-
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.stream.XMLStreamReader;
-
-import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
-import org.custommonkey.xmlunit.Diff;
-import org.junit.Test;
-
-/**
- *
- * @version $Rev$ $Date$
- */
-public class BeanXMLStreamReaderTestCase {
- private static final String XML_RESULT =
- "<?xml version='1.0' encoding='UTF-8'?>" + "<MyBean xmlns=\"http://xml.databinding.sca.tuscany.apache.org/\">"
- + "<arr>1</arr><arr>2</arr><arr>3</arr><bean><name>Name</name></bean><i>1</i>"
- + "<list>Item1</list><list>Item2</list>"
- + "<map><entry><key>key1</key><value>value1</value></entry>"
- + "<entry><key>key2</key><value>value2</value></entry></map>"
- + "<nil xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:nil=\"true\" />"
- + "<str>ABC</str></MyBean>";
-
- // The map entries can come in a different order
- private static final String XML_RESULT1 =
- "<?xml version='1.0' encoding='UTF-8'?>" + "<MyBean xmlns=\"http://xml.databinding.sca.tuscany.apache.org/\">"
- + "<arr>1</arr><arr>2</arr><arr>3</arr><bean><name>Name</name></bean><i>1</i>"
- + "<list>Item1</list><list>Item2</list>"
- + "<map><entry><key>key2</key><value>value2</value></entry>"
- + "<entry><key>key1</key><value>value1</value></entry></map>"
- + "<nil xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:nil=\"true\" />"
- + "<str>ABC</str></MyBean>";
-
-
- @Test
- public void testTransformation() throws Exception {
- MyBean bean = new MyBean();
- bean.str = "ABC";
- bean.i = 1;
- bean.arr = new long[] {1, 2, 3};
- bean.bean = new AnotherBean();
- bean.bean.setName("Name");
- bean.list.add("Item1");
- bean.list.add("Item2");
- bean.map.put("key1", "value1");
- bean.map.put("key2", "value2");
- XMLStreamReader reader = new BeanXMLStreamReaderImpl(null, bean);
- XMLStreamReader2String t3 = new XMLStreamReader2String(new DefaultExtensionPointRegistry());
- String xml = t3.transform(reader, null);
- Diff diff = new Diff(XML_RESULT, xml);
- Diff diff1 = new Diff(XML_RESULT1, xml);
- assertTrue(diff.similar() || diff1.similar());
- }
-
- private static class MyBean {
- private long arr[];
- private String str;
- private int i;
- private String nil;
- private List<String> list = new ArrayList<String>();
- private AnotherBean bean;
- private Map<String, String> map = new HashMap<String, String>();
-
- /**
- * @return the i
- */
- public int getI() {
- return i;
- }
-
- /**
- * @param i the i to set
- */
- public void setI(int i) {
- this.i = i;
- }
-
- /**
- * @return the arr
- */
- public long[] getArr() {
- return arr;
- }
-
- /**
- * @param arr the arr to set
- */
- public void setArr(long[] arr) {
- this.arr = arr;
- }
-
- /**
- * @return the str
- */
- public String getStr() {
- return str;
- }
-
- /**
- * @param str the str to set
- */
- public void setStr(String str) {
- this.str = str;
- }
-
- /**
- * @return the bean
- */
- public AnotherBean getBean() {
- return bean;
- }
-
- /**
- * @param bean the bean to set
- */
- public void setBean(AnotherBean bean) {
- this.bean = bean;
- }
-
- public List<String> getList() {
- return list;
- }
-
- public void setList(List<String> list) {
- this.list = list;
- }
-
- public String getNil() {
- return nil;
- }
-
- public void setNil(String nil) {
- this.nil = nil;
- }
-
- public Map<String, String> getMap() {
- return map;
- }
-
- public void setMap(Map<String, String> map) {
- this.map = map;
- }
-
- }
-
- private static class AnotherBean {
- private String name;
-
- /**
- * @return the name
- */
- public String getName() {
- return name;
- }
-
- /**
- * @param name the name to set
- */
- public void setName(String name) {
- this.name = name;
- }
- }
-
-}
diff --git a/tags/java/sca/2.0-M4-RC1/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/DOM2StAXTestCase.java b/tags/java/sca/2.0-M4-RC1/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/DOM2StAXTestCase.java
deleted file mode 100644
index 27d111374a..0000000000
--- a/tags/java/sca/2.0-M4-RC1/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/DOM2StAXTestCase.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.databinding.xml;
-
-import static org.junit.Assert.assertTrue;
-
-import javax.xml.stream.XMLStreamReader;
-
-import org.apache.tuscany.sca.common.xml.stax.reader.DOMXmlNodeImpl;
-import org.apache.tuscany.sca.common.xml.stax.reader.XmlTreeStreamReaderImpl;
-import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.custommonkey.xmlunit.XMLAssert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.w3c.dom.Node;
-
-/**
- *
- * @version $Rev$ $Date$
- */
-public class DOM2StAXTestCase {
- private static final String IPO_XML =
- "<?xml version=\"1.0\"?>" + "<ipo:purchaseOrder"
- + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
- + " xmlns:ipo=\"http://www.example.com/IPO\""
- + " xsi:schemaLocation=\"http://www.example.com/IPO ipo.xsd\""
- + " orderDate=\"1999-12-01\">"
- + " <shipTo exportCode=\"1\" xsi:type=\"ipo:UKAddress\">"
- + " <name>Helen Zoe</name>"
- + " <street>47 Eden Street</street>"
- + " <city>Cambridge</city>"
- + " <postcode>CB1 1JR</postcode>"
- + " </shipTo>"
- + " <billTo xsi:type=\"ipo:USAddress\">"
- + " <name>Robert Smith</name>"
- + " <street>8 Oak Avenue</street>"
- + " <city>Old Town</city>"
- + " <state>PA</state>"
- + " <zip>95819</zip>"
- + " </billTo>"
- + " <items>"
- + " <item partNum=\"833-AA\">"
- + " <productName>Lapis necklace</productName>"
- + " <quantity>1</quantity>"
- + " <USPrice>99.95</USPrice>"
- + " <ipo:comment>Want this for the holidays</ipo:comment>"
- + " <shipDate>1999-12-05</shipDate>"
- + " </item>"
- + " </items>"
- + "</ipo:purchaseOrder>";
-
- private static final String CRAZY_XML =
- "<p:e1 xmlns=\"http://ns0\" xmlns:p=\"http://p1\">" + "<p:e2 xmlns:p=\"http://p2\"/><e3/><e4 xmlns=\"\">E4</e4></p:e1>";
-
- private static ExtensionPointRegistry registry;
-
- @BeforeClass
- public static void init() {
- registry = new DefaultExtensionPointRegistry();
- }
-
- @Test
- public void testTransformation() throws Exception {
- String2Node t1 = new String2Node(registry);
- Node node = t1.transform(IPO_XML, null);
- Node2XMLStreamReader t2 = new Node2XMLStreamReader();
- XMLStreamReader reader = t2.transform(node, null);
- XMLStreamReader2String t3 = new XMLStreamReader2String(registry);
- String xml = t3.transform(reader, null);
- XMLAssert.assertXMLEqual(IPO_XML, xml);
- // assertTrue(xml != null && xml.indexOf("<shipDate>1999-12-05</shipDate>") != -1);
- }
-
- @Test
- public void testTransformation2() throws Exception {
- String2Node t1 = new String2Node(registry);
- Node node = t1.transform(CRAZY_XML, null);
- Node2XMLStreamReader t2 = new Node2XMLStreamReader();
- XMLStreamReader reader = t2.transform(node, null);
- XMLStreamReader2String t3 = new XMLStreamReader2String(registry);
- String xml = t3.transform(reader, null);
- // System.out.println(xml);
- XMLAssert.assertXMLEqual(CRAZY_XML, xml);
- assertTrue(xml.contains("<p:e2 xmlns:p=\"http://p2\""));
- }
-
- @Test
- public void testTransformation3() throws Exception {
- String2Node t1 = new String2Node(registry);
- Node node = t1.transform(IPO_XML, null);
- DOMXmlNodeImpl element = new DOMXmlNodeImpl(node);
- XmlTreeStreamReaderImpl reader = new XmlTreeStreamReaderImpl(element);
- XMLStreamReader2String t3 = new XMLStreamReader2String(registry);
- String xml = t3.transform(reader, null);
- XMLAssert.assertXMLEqual(IPO_XML, xml);
- // assertTrue(xml != null && xml.indexOf("<shipDate>1999-12-05</shipDate>") != -1);
- }
-
-}
diff --git a/tags/java/sca/2.0-M4-RC1/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/DataPipeTestCase.java b/tags/java/sca/2.0-M4-RC1/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/DataPipeTestCase.java
deleted file mode 100644
index 682fbd4243..0000000000
--- a/tags/java/sca/2.0-M4-RC1/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/DataPipeTestCase.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.databinding.xml;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.io.Writer;
-
-import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
-import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
-import org.apache.tuscany.sca.databinding.DataPipe;
-import org.apache.tuscany.sca.databinding.DataPipeTransformer;
-import org.apache.tuscany.sca.databinding.impl.PipedTransformer;
-import org.junit.Assert;
-import org.junit.Test;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- * Test case for DataPipe
- *
- * @version $Rev$ $Date$
- */
-public class DataPipeTestCase {
-
- @Test
- public final void testStreamPipe() throws IOException {
- byte[] bytes = new byte[] {1, 2, 3};
- DataPipeTransformer<OutputStream, InputStream> pipe = new StreamDataPipe();
- DataPipe<OutputStream, InputStream> dataPipe = pipe.newInstance();
- OutputStream os = dataPipe.getSink();
- os.write(bytes);
- byte[] newBytes = new byte[16];
- int count = dataPipe.getResult().read(newBytes);
- Assert.assertEquals(3, count);
- for (int i = 0; i < bytes.length; i++) {
- Assert.assertEquals(bytes[i], newBytes[i]);
- }
- }
-
- @Test
- public final void testWriter2ReaderPipe() throws IOException {
- String str = "ABC";
- Writer2ReaderDataPipe pipe = new Writer2ReaderDataPipe();
- Assert.assertSame(Writer.class, pipe.getSourceType());
- Assert.assertSame(Reader.class, pipe.getTargetType());
- DataPipe<Writer, Reader> dataPipe = pipe.newInstance();
- dataPipe.getSink().write(str);
- char[] buf = new char[16];
- int count = dataPipe.getResult().read(buf);
- Assert.assertEquals(3, count);
- for (int i = 0; i < str.length(); i++) {
- Assert.assertEquals(str.charAt(i), buf[i]);
- }
- }
-
- @Test
- public final void testPiped() throws Exception {
- Node2Writer node2Writer = new Node2Writer();
- Writer2ReaderDataPipe pipe = new Writer2ReaderDataPipe();
- PipedTransformer<Node, Writer, Reader> transformer =
- new PipedTransformer<Node, Writer, Reader>(node2Writer, pipe);
- Document document = DOMHelper.getInstance(new DefaultExtensionPointRegistry()).newDocument();
- Element element = document.createElementNS("http://ns1", "root");
- document.appendChild(element);
- Reader reader = transformer.transform(document, null);
- Assert.assertEquals(transformer.getWeight(), node2Writer.getWeight() + pipe.getWeight());
- Assert.assertEquals(transformer.getSourceDataBinding(), node2Writer.getSourceDataBinding());
- Assert.assertEquals(transformer.getTargetDataBinding(), pipe.getTargetDataBinding());
- char[] buf = new char[120];
- int count = reader.read(buf);
- String xml = new String(buf, 0, count);
- Assert.assertTrue(xml.contains("<root xmlns=\"http://ns1\"/>"));
- }
-
-}
diff --git a/tags/java/sca/2.0-M4-RC1/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/JavaBean2XMLStreamReaderTestCase.java b/tags/java/sca/2.0-M4-RC1/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/JavaBean2XMLStreamReaderTestCase.java
deleted file mode 100644
index 8919453731..0000000000
--- a/tags/java/sca/2.0-M4-RC1/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/JavaBean2XMLStreamReaderTestCase.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.databinding.xml;
-
-import javax.xml.stream.XMLStreamReader;
-
-import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
-import org.apache.tuscany.sca.databinding.javabeans.JavaBean2XMLStreamReaderTransformer;
-import org.custommonkey.xmlunit.XMLAssert;
-import org.junit.Test;
-
-/**
- *
- * @version $Rev$ $Date$
- */
-public class JavaBean2XMLStreamReaderTestCase {
- private static final String XML_RESULT =
- "<?xml version='1.0' encoding='UTF-8'?>"
- + "<MyBean xmlns=\"http://xml.databinding.sca.tuscany.apache.org/\">"
- + "<arr>1</arr><arr>2</arr><arr>3</arr><bean><name>Name</name></bean><i>1</i><str>ABC</str>"
- + "</MyBean>";
-
- @Test
- public void testTransformation() throws Exception {
- JavaBean2XMLStreamReaderTransformer t2 = new JavaBean2XMLStreamReaderTransformer();
- MyBean bean = new MyBean();
- bean.str = "ABC";
- bean.i = 1;
- bean.arr = new long[] {1, 2, 3};
- bean.bean = new AnotherBean();
- bean.bean.setName("Name");
- XMLStreamReader reader = t2.transform(bean, null);
- XMLStreamReader2String t3 = new XMLStreamReader2String(new DefaultExtensionPointRegistry());
- String xml = t3.transform(reader, null);
- XMLAssert.assertXMLEqual(XML_RESULT, xml);
-
- }
-
- private static class MyBean {
- private String str;
- private int i;
- private long arr[];
- private AnotherBean bean;
-
- /**
- * @return the arr
- */
- public long[] getArr() {
- return arr;
- }
-
- /**
- * @param arr the arr to set
- */
- public void setArr(long[] arr) {
- this.arr = arr;
- }
-
- /**
- * @return the i
- */
- public int getI() {
- return i;
- }
-
- /**
- * @param i the i to set
- */
- public void setI(int i) {
- this.i = i;
- }
-
- /**
- * @return the str
- */
- public String getStr() {
- return str;
- }
-
- /**
- * @param str the str to set
- */
- public void setStr(String str) {
- this.str = str;
- }
-
- /**
- * @return the bean
- */
- public AnotherBean getBean() {
- return bean;
- }
-
- /**
- * @param bean the bean to set
- */
- public void setBean(AnotherBean bean) {
- this.bean = bean;
- }
-
- }
-
- private static class AnotherBean {
- private String name;
-
- /**
- * @return the name
- */
- public String getName() {
- return name;
- }
-
- /**
- * @param name the name to set
- */
- public void setName(String name) {
- this.name = name;
- }
- }
-
-}
diff --git a/tags/java/sca/2.0-M4-RC1/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/Node2StringTestCase.java b/tags/java/sca/2.0-M4-RC1/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/Node2StringTestCase.java
deleted file mode 100644
index 516b57c851..0000000000
--- a/tags/java/sca/2.0-M4-RC1/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/Node2StringTestCase.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.databinding.xml;
-
-import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
-import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
-import org.junit.Test;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- *
- * @version $Rev$ $Date$
- */
-public class Node2StringTestCase {
-
- @Test
- public void testTransformation() throws Exception {
- Document document = DOMHelper.getInstance(new DefaultExtensionPointRegistry()).newDocument();
- Element element = document.createElementNS("http://ns1", "test");
- document.appendChild(element);
-
- new Node2String().transform(document, null);
- }
-}
diff --git a/tags/java/sca/2.0-M4-RC1/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/PushTransformationTestCase.java b/tags/java/sca/2.0-M4-RC1/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/PushTransformationTestCase.java
deleted file mode 100644
index a8657a5be8..0000000000
--- a/tags/java/sca/2.0-M4-RC1/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/PushTransformationTestCase.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.databinding.xml;
-
-import javax.xml.stream.XMLStreamReader;
-
-import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.databinding.impl.PipedTransformer;
-import org.junit.Assert;
-import org.junit.Test;
-import org.w3c.dom.Node;
-import org.xml.sax.ContentHandler;
-
-/**
- *
- * @version $Rev$ $Date$
- */
-public class PushTransformationTestCase {
- private static final String IPO_XML =
- "<?xml version=\"1.0\"?>" + "<ipo:purchaseOrder"
- + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
- + " xmlns:ipo=\"http://www.example.com/IPO\""
- + " xsi:schemaLocation=\"http://www.example.com/IPO ipo.xsd\""
- + " orderDate=\"1999-12-01\">"
- + " <shipTo exportCode=\"1\" xsi:type=\"ipo:UKAddress\">"
- + " <name>Helen Zoe</name>"
- + " <street>47 Eden Street</street>"
- + " <city>Cambridge</city>"
- + " <postcode>CB1 1JR</postcode>"
- + " </shipTo>"
- + " <billTo xsi:type=\"ipo:USAddress\">"
- + " <name>Robert Smith</name>"
- + " <street>8 Oak Avenue</street>"
- + " <city>Old Town</city>"
- + " <state>PA</state>"
- + " <zip>95819</zip>"
- + " </billTo>"
- + " <items>"
- + " <item partNum=\"833-AA\">"
- + " <productName>Lapis necklace</productName>"
- + " <quantity>1</quantity>"
- + " <USPrice>99.95</USPrice>"
- + " <ipo:comment>Want this for the holidays</ipo:comment>"
- + " <shipDate>1999-12-05</shipDate>"
- + " </item>"
- + " </items>"
- + "</ipo:purchaseOrder>";
-
- @Test
- public void testTransformation() {
- ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
- String2XMLStreamReader t1 = new String2XMLStreamReader(registry);
- XMLStreamReader reader = t1.transform(IPO_XML, null);
- XMLStreamReader2SAX t2 = new XMLStreamReader2SAX(registry);
- PipedTransformer<XMLStreamReader, ContentHandler, Node> t3 =
- new PipedTransformer<XMLStreamReader, ContentHandler, Node>(t2, new SAX2DOMPipe(registry));
- Node node = t3.transform(reader, null);
- Assert.assertNotNull(node);
- Node2String t4 = new Node2String();
- String xml = t4.transform(node, null);
- Assert.assertTrue(xml != null && xml.indexOf("<shipDate>1999-12-05</shipDate>") != -1);
- }
-
-}
diff --git a/tags/java/sca/2.0-M4-RC1/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/TraxTransformerTestCase.java b/tags/java/sca/2.0-M4-RC1/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/TraxTransformerTestCase.java
deleted file mode 100644
index fb9895f120..0000000000
--- a/tags/java/sca/2.0-M4-RC1/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/TraxTransformerTestCase.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.databinding.xml;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.net.URL;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.w3c.dom.Node;
-import org.xml.sax.Attributes;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
-
-/**
- *
- * @version $Rev$ $Date$
- */
-public class TraxTransformerTestCase {
- private URL url;
-
- @Before
- public void setUp() throws Exception {
- url = getClass().getResource("foo.xml");
- }
-
- @Test
- public void testTransformDOM() throws IOException {
- InputStream is = url.openStream();
- InputStream2Node t1 = new InputStream2Node();
- Node node = t1.transform(is, null);
- is.close();
- Writer writer = new StringWriter();
- Node2Writer t2 = new Node2Writer();
- t2.transform(node, writer, null);
- String str = writer.toString();
- StringReader reader = new StringReader(str);
- Reader2Node t3 = new Reader2Node();
- node = t3.transform(reader, null);
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- Node2OutputStream t4 = new Node2OutputStream();
- t4.transform(node, os, null);
- InputSource inputSource = new InputSource(new ByteArrayInputStream(os.toByteArray()));
- InputSource2Node t5 = new InputSource2Node();
- node = t5.transform(inputSource, null);
- }
-
- @Test
- public void testTransformSAX() throws IOException {
- MyContentHandler handler = new MyContentHandler();
- InputStream is = url.openStream();
- InputStream2SAX t1 = new InputStream2SAX();
- t1.transform(is, handler, null);
- is.close();
-
- String xml = "<foo xmlns=\"http://foo\">bar</foo>";
-
- InputSource inputSource = new InputSource(new StringReader(xml));
- InputSource2SAX t2 = new InputSource2SAX();
- MyContentHandler handler2 = new MyContentHandler();
- t2.transform(inputSource, handler2, null);
-
- }
-
- private static class MyContentHandler extends DefaultHandler {
-
- @Override
- public void startElement(String namespaceURI, String localName, String qName, Attributes atts)
- throws SAXException {
- super.startElement(namespaceURI, localName, qName, atts);
- }
-
- }
-
-}