
org.apache.ws.jaxme.junit.RecursionTest Maven / Gradle / Ivy
The newest version!
package org.apache.ws.jaxme.junit;
import org.apache.ws.jaxme.test.recursion.Attribute;
import org.apache.ws.jaxme.test.recursion.DirectEmployee;
import org.apache.ws.jaxme.test.recursion.IndirectEmployee;
import org.apache.ws.jaxme.test.recursion.PotEmployee;
/**
* Tests for unmarshalling from a string, them marshalling to another
* string and unmarshalling back to another object for comparison.
* Three different recursive schemas are used:
*
* - Direct recursion: A node is recurring directly under itself.
* - Indirect recursion: A node is recurring as a child of another
* node within itself.
* - Potential direct/indirect recursion: A node is directly
* recurring/indirectly recurring under as one of the choices under
* itself.
*
*/
public class RecursionTest extends BaseTestCase {
/** Creates a new instance with the given name.
*/
public RecursionTest(String pName) { super(pName); }
/** Tests indirect recursion: The recursing element is a child
* elements child.
*/
public void testIndirectRecursion() throws Exception {
final String xml =
"\n" +
" \n" +
" \n" +
" \n" +
" \n" +
" \n" +
" \n" +
" \n" +
" \n" +
" \n" +
" ";
unmarshalMarshalUnmarshal(IndirectEmployee.class, xml);
}
/** Tests direct recursion: The recursing element is an
* immediate child.
*/
public void testDirectRecursion() throws Exception {
final String xml =
"\n" +
" \n" +
" \n" +
" \n" +
" \n" +
" \n" +
" ";
unmarshalMarshalUnmarshal(DirectEmployee.class, xml);
}
/** Tests potential recursion: The recursing element may
* be a direct or an indirect child.
*/
public void testPotentialRecursion() throws Exception {
final String xml1 =
"\n" +
" \n" +
" ";
unmarshalMarshalUnmarshal(PotEmployee.class, xml1);
final String xml2 =
"\n" +
" \n" +
" \n" +
" \n" +
" ";
unmarshalMarshalUnmarshal(PotEmployee.class, xml2);
}
/** Tests recursion using element references.
*/
public void testElementRecursion() throws Exception {
final String xml =
"\n" +
" \n" +
" \n" +
" \n" +
" \n" +
" \n" +
" \n" +
" \n" +
" \n" +
" ";
unmarshalMarshalUnmarshal(Attribute.class, xml);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy