TestMultiRefIdentitypublic class TestMultiRefIdentity extends TestCase
Constructors Summary |
---|
public TestMultiRefIdentity(String name)
super(name);
|
Methods Summary |
---|
public static void | main(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.Test | suite()
return new TestSuite(test.encoding.TestMultiRefIdentity.class);
| public void | testEquality1()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 void | testEquality2()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 void | testEquality3()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 void | testIdentity1()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 void | testIdentity2()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);
|
|