gt:         Sequence currentSeq = address1Object.getSequence();
context: /*******************************************************************************
   * Copyright (c) 1998, 2012 Oracle and/or its affiliates. All rights reserved.
   * This program and the accompanying materials are made available under the 
   * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 
   * which accompanies this distribution. 
   * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
   * and the Eclipse Distribution License is available at 
   * http://www.eclipse.org/org/documents/edl-v10.php.
   *
   * Contributors:
   *     Oracle - initial API and implementation from Oracle TopLink
   ******************************************************************************/  
  package org.eclipse.persistence.testing.sdo.model.changesummary.sequence;
  
  import commonj.sdo.ChangeSummary;
  import commonj.sdo.DataObject;
  import commonj.sdo.Property;
  import commonj.sdo.Sequence;
  import java.io.FileInputStream;
  import java.io.InputStream;
  import java.util.ArrayList;
  import java.util.List;
  import junit.textui.TestRunner;
  import org.eclipse.persistence.sdo.SDOSequence;
  import org.eclipse.persistence.testing.sdo.SDOTestCase;
  import org.eclipse.persistence.exceptions.SDOException;
  
  public class ChangeSummaryGetOldSequenceTestCases extends SDOTestCase {
      DataObject companyObject;
      DataObject purchaseOrderObject;
      DataObject address1Object;
      DataObject itemsObject;
      ChangeSummary cs;
  
      public ChangeSummaryGetOldSequenceTestCases(String name) {
          super(name);
      }
  
      public static void main(String[] args) {
          String[] arguments = { "-c", "org.eclipse.persistence.testing.sdo.model.changesummary.sequence.ChangeSummaryGetOldSequenceTestCases" };
          TestRunner.main(arguments);
      }
  
      public void setUp() {
          super.setUp();
  
          try {
              InputStream is = new FileInputStream(getSchemaToDefine());
              List types = xsdHelper.define(is, null);
  
              //     XMLDocument doc = xmlHelper.load(new FileInputStream(getControlFileName()));
              //companyObject= doc.getRootObject();
          } catch (Exception e) {
              e.printStackTrace();
              fail("An error occurred during setup.");
          }
          companyObject = buildDataObjects();
          purchaseOrderObject = companyObject.getDataObject("order");
          assertNotNull(purchaseOrderObject);
          address1Object = (DataObject)(purchaseOrderObject.getList("address")).get(0);
          assertNotNull(address1Object);
          assertTrue(address1Object.getType().isSequenced());
          assertNotNull(address1Object.getSequence());
          assertNotNull(purchaseOrderObject.getChangeSummary());
          itemsObject = purchaseOrderObject.getDataObject("items");
          assertNotNull(itemsObject);
          assertNotNull(itemsObject.getSequence());
          cs = purchaseOrderObject.getChangeSummary();
  
      }
  
      public String getSchemaToDefine() {
          return "org/eclipse/persistence/testing/sdo/schemas/PurchaseOrderComplexSequenced.xsd";
      }
  
      protected String getControlFileName() {
          return "./org/eclipse/persistence/testing/sdo/helper/xmlhelper/sequence/purchaseOrderComplexSequenced.xml";
      }
  
      public void testGetOldSequenceNotLogging() {
          cs.endLogging();
          address1Object.set("city", "aaa");
          List oldValues = cs.getOldValues(address1Object);
          assertEquals(0, oldValues.size());
          address1Object.unset(address1Object.getInstanceProperty("city"));
          Sequence oldAddressSeq = cs.getOldSequence(address1Object);
  
          assertNotNull(oldAddressSeq);
      }
  
      public void testGetOldSequenceNotLoggingNull() {
          purchaseOrderObject.unset("address");
          cs.endLogging();
          address1Object.unset(address1Object.getInstanceProperty("city"));
          Sequence oldAddressSeq = cs.getOldSequence(address1Object);
  
          assertNotNull(oldAddressSeq);
      }
  
      public void testGetOldSequenceNotSequenced() {
          cs.beginLogging();
          DataObject lineItem1 = (DataObject)itemsObject.getList("item").get(0);
          assertNotNull(lineItem1);
          lineItem1.unset(0);
          Sequence oldLineItemSeq = cs.getOldSequence(lineItem1);
  
          //old seq should be null because line item is not sequenced
          assertNull(oldLineItemSeq);
      }
  
      public void testGetOldSequenceNull() {
          cs.beginLogging();
  
          Sequence oldSeq = cs.getOldSequence(null);
          assertNull(oldSeq);
      }
  
      public void testGetOldSequenceTwice() {
          Sequence originalSeq = address1Object.getSequence();
          String originalValue = (String)originalSeq.getValue(0);
          assertEquals("Alice Smith", originalValue);
          cs.beginLogging();
          address1Object.set("name", "newName");
  
          Sequence oldSeq1 = cs.getOldSequence(address1Object);
          assertNotNull(oldSeq1);
          assertNotSame(oldSeq1, originalSeq);
  
          Sequence oldSeq2 = cs.getOldSequence(address1Object);
          assertNotNull(oldSeq2);
          assertEquals(oldSeq1, oldSeq2);
  
          address1Object.set("name", "newName2");
  
          Sequence oldSeq3 = cs.getOldSequence(address1Object);
          assertNotNull(oldSeq3);
          assertEquals(oldSeq2, oldSeq3);		   
          
          String oldSeqValue = (String)oldSeq3.getValue(0);
          assertEquals("Alice Smith", oldSeqValue);
  
          String currentValue = (String)address1Object.getSequence().getValue(0);
          assertEquals("newName2", currentValue);
      }
  
      public void testGetOldSequenceAndOldValueAreEqual() {
          cs.beginLogging();
  
          DataObject lineItem1 = (DataObject)itemsObject.getList("item").get(0);
          assertNotNull(lineItem1);
          lineItem1.delete();
  
          Sequence oldSeq1 = cs.getOldSequence(itemsObject);
          assertNotNull(oldSeq1);
          Object seqFirstOldValue = oldSeq1.getValue(0);
  
          ChangeSummary.Setting itemOldSetting = cs.getOldValue(itemsObject, itemsObject.getInstanceProperty("item"));
          assertNotNull(itemOldSetting);
          Object firstValue = ((List)itemOldSetting.getValue()).get(0);
          assertEquals(seqFirstOldValue, firstValue);
      }
  
      public void testGetOldSequenceCreated() {
          cs.beginLogging();
  
          DataObject newAddress = dataFactory.create("http://www.example.org", "AddressType");
          assertNotNull(newAddress);
          newAddress.set("city", "newCity");
  
          purchaseOrderObject.getList("address").add(newAddress);
  
          assertCreated(newAddress, cs);
          assertNull(cs.getOldSequence(newAddress));
      }
  
      public void testGetOldSequenceUnchanged() {
          cs.beginLogging();
          //if the sequence has not changed return the current sequence
          Sequence oldSeq = cs.getOldSequence(address1Object);
          assertNotNull(oldSeq);
          assertEquals(4, ((SDOSequence)oldSeq).getSettings().size());
  
          assertEquals("name", oldSeq.getProperty(0).getName());
          assertEquals("street", oldSeq.getProperty(1).getName());
          assertEquals("city", oldSeq.getProperty(2).getName());
          assertEquals("state", oldSeq.getProperty(3).getName());
  
          assertEquals("Alice Smith", oldSeq.getValue(0));
          assertEquals("123 Maple Street", oldSeq.getValue(1));
          assertEquals("Mill Valley", oldSeq.getValue(2));
          assertEquals("CA", oldSeq.getValue(3));
      }
  
      public void testGetOldSequenceDetachedAddress() {
          cs.beginLogging();
  
          address1Object.detach();
          Sequence oldSeq = cs.getOldSequence(address1Object);
          assertNotNull(oldSeq);
          assertEquals(4, ((SDOSequence)oldSeq).getSettings().size());
  
          assertEquals("name", oldSeq.getProperty(0).getName());
          assertEquals("street", oldSeq.getProperty(1).getName());
          assertEquals("city", oldSeq.getProperty(2).getName());
          assertEquals("state", oldSeq.getProperty(3).getName());
  
          assertEquals("Alice Smith", oldSeq.getValue(0));
          assertEquals("123 Maple Street", oldSeq.getValue(1));
          assertEquals("Mill Valley", oldSeq.getValue(2));
          assertEquals("CA", oldSeq.getValue(3));
  
      }
  
      public void testGetOldSequenceDetachedItem() {
          DataObject lineItem1 = (DataObject)itemsObject.getList("item").get(0);
          DataObject lineItem2 = (DataObject)itemsObject.getList("item").get(1);
          Sequence currentSeq = itemsObject.getSequence();
          assertEquals(2, currentSeq.size());
  
          cs.beginLogging();
          lineItem1.detach();
          assertEquals(1, currentSeq.size());
          Sequence oldSeq = cs.getOldSequence(itemsObject);
          assertNotNull(oldSeq);
          assertEquals(2, ((SDOSequence)oldSeq).getSettings().size());
  
          DataObject oldLineItem1 = (DataObject)oldSeq.getValue(0);
          assertEquals("Lawnmower", oldLineItem1.get("productName"));
  
          DataObject oldLineItem2 = (DataObject)oldSeq.getValue(1);
          assertEquals("Baby Monitor", oldLineItem2.get("productName"));
          //should be a deep copy not the same object
          assertNotSame(lineItem1, oldLineItem1);
          assertNotSame(lineItem2, oldLineItem2);
          assertFalse(lineItem1.equals(oldLineItem1));
          assertFalse(lineItem2.equals(oldLineItem2));
  
      }
  
      public void testGetOldSequenceDeletedAddress() {
          cs.beginLogging();
  