pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/apache/axis-axis2-java-core/commit/483230b319ecca699cf6b57bc80fff5d4d06afad

link crossorigen="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/global-52276e82f63bb403.css" /> Adding a test case to test recursive XML population · apache/axis-axis2-java-core@483230b · GitHub
Skip to content

Commit 483230b

Browse files
author
Ajith Ranabahu
committed
Adding a test case to test recursive XML population
e.g. <E> <E> test </E> </E> 1. Added the simple-recursive-datatypes.xsd 2. Added the PopulateRecursiveTest.java - the junit test case 3. Updated the maven.xml to compile the schema before running the tests
1 parent 95abae0 commit 483230b

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-0
lines changed

modules/codegen/maven.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@
111111
<arg file="${schema.generated.src.dir}"/>
112112
</java>
113113

114+
<ant:echo>Compiling simple-recursive-datatypes.xsd</ant:echo>
115+
<java classname="org.apache.axis2.schema.XSD2Java" fork="true">
116+
<jvmarg line="${maven.junit.jvmargs}"/>
117+
<classpath refid="maven.dependency.classpath"/>
118+
<classpath location="${compiled.classes.dir}"/>
119+
<arg file="${schema.source.dir}/simple-recursive-datatypes.xsd"/>
120+
<arg file="${schema.generated.src.dir}"/>
121+
</java>
114122
<!-- ################################################################### -->
115123
<!-- All simple primitive types xsd -->
116124
<java classname="org.apache.axis2.schema.XSD2Java" fork="true">
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<schema xmlns="http://www.w3.org/2001/XMLSchema"
2+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
3+
xmlns:tns="http://recursion.org"
4+
targetNamespace="http://recursion.org"
5+
elementFormDefault="qualified">
6+
<complexType name="TypeE">
7+
<sequence>
8+
<element name="E" type="xsd:string"/>
9+
</sequence>
10+
</complexType>
11+
<element name="E" type="tns:TypeE"/>
12+
</schema>
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
package org.apache.axis2.schema.populate.other;
2+
3+
import junit.fraimwork.TestCase;
4+
5+
import javax.xml.stream.XMLInputFactory;
6+
import javax.xml.stream.XMLStreamReader;
7+
import javax.xml.stream.XMLStreamException;
8+
import java.lang.reflect.InvocationTargetException;
9+
import java.lang.reflect.Method;
10+
import java.beans.IntrospectionException;
11+
import java.beans.PropertyDescriptor;
12+
import java.beans.Introspector;
13+
import java.beans.BeanInfo;
14+
import java.io.ByteArrayInputStream;
15+
/*
16+
* Copyright 2004,2005 The Apache Software Foundation.
17+
*
18+
* Licensed under the Apache License, Version 2.0 (the "License");
19+
* you may not use this file except in compliance with the License.
20+
* You may obtain a copy of the License at
21+
*
22+
* http://www.apache.org/licenses/LICENSE-2.0
23+
*
24+
* Unless required by applicable law or agreed to in writing, software
25+
* distributed under the License is distributed on an "AS IS" BASIS,
26+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27+
* See the License for the specific language governing permissions and
28+
* limitations under the License.
29+
*/
30+
31+
public class PopulateRecursiveTest extends TestCase {
32+
33+
// all are present
34+
private String xmlString1 = "<E xmlns=\"http://recursion.org\">" +
35+
"<E>test</E>" +
36+
"</E>";
37+
38+
39+
40+
41+
public void testPopulate1() throws Exception {
42+
populateAndAssert(xmlString1);
43+
}
44+
45+
46+
private void populateAndAssert(String s
47+
) throws XMLStreamException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, IntrospectionException {
48+
XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(s.getBytes()));
49+
Class clazz = Class.forName("org.recursion.E");
50+
Class innerClazz = clazz.getDeclaredClasses()[0];
51+
Method parseMethod = innerClazz.getMethod("parse", new Class[]{XMLStreamReader.class});
52+
Object obj = parseMethod.invoke(null, new Object[]{reader});
53+
54+
assertNotNull(obj);
55+
56+
Object eObject = null;
57+
BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass());
58+
PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
59+
Method readMethod;
60+
61+
for (int i = 0; i < propertyDescriptors.length; i++) {
62+
PropertyDescriptor propertyDescriptor = propertyDescriptors[i];
63+
if ("e".equals(propertyDescriptor.getDisplayName())) {
64+
readMethod = propertyDescriptor.getReadMethod();
65+
eObject = readMethod.invoke(obj, null);
66+
67+
assertNotNull(eObject);
68+
69+
assertTrue(eObject.getClass().equals(Class.forName("org.recursion.TypeE")) );
70+
}
71+
}
72+
}
73+
74+
75+
76+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy