FileDocCategorySizeDatePackage
TestMultiRefIdentity.javaAPI DocApache Axis 1.46558Sat Apr 22 18:57:26 BST 2006test.encoding

TestMultiRefIdentity

public class TestMultiRefIdentity extends TestCase
author
John Gregg (john.gregg@techarch.com)
author
$Author: gdaniels $
version
$Revision: 258817 $

Fields Summary
Constructors Summary
public TestMultiRefIdentity(String name)

        super(name);
    
Methods Summary
public static voidmain(java.lang.String[] argv)

        
        boolean swing = false;
        if (argv.length > 0) {
            if ("-swing".equals(argv[0])) {
                swing = true;
            }
        }
        
        if (swing) {
            junit.swingui.TestRunner.main(new String[] {"test.encoding.TestMultiRefIdentity"});
        } else {
            System.out.println("use '-swing' for the Swing version.");
            junit.textui.TestRunner.main(new String[] {"test.encoding.TestMultiRefIdentity"});
        }
    
public static junit.framework.Testsuite()

        return new TestSuite(test.encoding.TestMultiRefIdentity.class);
    
public voidtestEquality1()
Tests when beans have different contents and rely on default hashCode().

        TestBeanA tb1 = new TestBeanA();
        tb1.s1 = "john";
        TestBeanA tb2 = new TestBeanA();
        tb2.s1 = "gregg";
        
        CharArrayWriter caw = new CharArrayWriter();
        SerializationContext sci = new SerializationContext(caw);
        sci.setDoMultiRefs(true);
        sci.serialize(new QName("someLocalPart"), null, tb1);
        sci.serialize(new QName("someOtherLocalPart"), null, tb2);
        
        String s = caw.toString();
        
        // Cheap but fragile.
        int first = s.indexOf("#id0");
        int last = s.lastIndexOf("#id1");
        assertTrue(s,first >= 0);
        assertTrue(s,last >= 0);
    
public voidtestEquality2()
Tests when beans have same contents but rely on default hashCode().

        TestBeanA tb1 = new TestBeanA();
        tb1.s1 = "john";
        TestBeanA tb2 = new TestBeanA();
        tb2.s1 = "john";
        
        CharArrayWriter caw = new CharArrayWriter();
        SerializationContext sci = new SerializationContext(caw);
        sci.setDoMultiRefs(true);
        sci.serialize(new QName("someLocalPart"), null, tb1);
        sci.serialize(new QName("someOtherLocalPart"), null, tb2);
        
        String s = caw.toString();
        
        // Cheap but fragile.
        int first = s.indexOf("#id0");
        int last = s.lastIndexOf("#id1");
        assertTrue(s,first >= 0);
        assertTrue(s,last >= 0);
    
public voidtestEquality3()
Tests when beans have same contents and use their own hashCode().

        TestBeanB tb1 = new TestBeanB();
        tb1.s1 = "john";
        TestBeanB tb2 = new TestBeanB();
        tb2.s1 = "john";
        
        CharArrayWriter caw = new CharArrayWriter();
        SerializationContext sci = new SerializationContext(caw);
        sci.setDoMultiRefs(true);
        sci.serialize(new QName("someLocalPart"), null, tb1);
        sci.serialize(new QName("someOtherLocalPart"), null, tb2);
        
        String s = caw.toString();
        
        // Cheap but fragile.
        int first = s.indexOf("#id0");
        int last = s.lastIndexOf("#id1");
        assertTrue(s,first >= 0);
        assertTrue(s,last >= 0 && last != first);
    
public voidtestIdentity1()
Tests when beans are identical and use default hashCode().

        TestBeanA tb1 = new TestBeanA();
        tb1.s1 = "john";
        TestBeanA tb2 = tb1;
        
        CharArrayWriter caw = new CharArrayWriter();
        SerializationContext sci = new SerializationContext(caw);
        sci.setDoMultiRefs(true);
        sci.serialize(new QName("someLocalPart"), null, tb1);
        sci.serialize(new QName("someOtherLocalPart"), null, tb2);
        
        String s = caw.toString();
        
        // Cheap but fragile.
        int first = s.indexOf("#id0");
        int last = s.lastIndexOf("#id0");
        assertTrue(s, first >= 0);
        assertTrue(s, last >= 0 && last != first);
    
public voidtestIdentity2()
Tests when beans are identical and use their own hashCode().

        TestBeanB tb1 = new TestBeanB();
        tb1.s1 = "john";
        TestBeanB tb2 = tb1;
        
        CharArrayWriter caw = new CharArrayWriter();
        SerializationContext sci = new SerializationContext(caw);
        sci.setDoMultiRefs(true);
        sci.serialize(new QName("someLocalPart"), null, tb1);
        sci.serialize(new QName("someOtherLocalPart"), null, tb2);
        
        String s = caw.toString();
        
        // Cheap but fragile.
        int first = s.indexOf("#id0");
        int last = s.lastIndexOf("#id0");
        assertTrue(s,first >= 0);
        assertTrue(s,last >= 0 && last != first);