Package org.jpos.util

Source Code of org.jpos.util.ISOBitMapDeepCopierTest

package org.jpos.util;

import java.util.BitSet;

import junit.framework.TestCase;

import org.jpos.iso.ISOBitMap;

/**
* $Revision: 23416 $
* $Date: 2007-03-14 00:14:09 +0000 (Wed, 14 Mar 2007) $
* $Author: nsmith $
*/
public final class ISOBitMapDeepCopierTest extends TestCase {

    private ISOBitMapDeepCopier copier;
   
    protected void setUp() throws Exception {
        copier = new ISOBitMapDeepCopier();
    }
   
    public void testDoDeepCopyOfISOBitMapWhenBitSetContentChanges() throws Exception {
        BitSet fieldContentToBeUpdated = new BitSet(48);
        fieldContentToBeUpdated.set(11);
        fieldContentToBeUpdated.set(22);
        fieldContentToBeUpdated.set(33);
        BitSet originalFieldContent = (BitSet) fieldContentToBeUpdated.clone();
       
        ISOBitMap fieldWhichWillBeModified = new ISOBitMap(42, fieldContentToBeUpdated);
        ISOBitMap fieldWhoseValueShouldNotChange = (ISOBitMap) copier.doDeepCopy(fieldWhichWillBeModified);
       
        fieldContentToBeUpdated.set(44);
        fieldWhichWillBeModified.setFieldNumber(41);
       
        assertNotNull(fieldWhichWillBeModified);
        assertNotNull(fieldWhoseValueShouldNotChange);
        assertNotSame(fieldWhichWillBeModified, fieldWhoseValueShouldNotChange);
        assertEquals(originalFieldContent, fieldWhoseValueShouldNotChange.getValue());
        assertEquals(fieldContentToBeUpdated, fieldWhichWillBeModified.getValue());
        ISOComponentEqualityTester.assertNotEquals(fieldWhichWillBeModified, fieldWhoseValueShouldNotChange);
    }
   
    public void testDoDeepCopyOfISOBitMapWhenFieldContentChanges() throws Exception {
        BitSet originalFieldContent = new BitSet(48);
        originalFieldContent.set(11);
        originalFieldContent.set(22);
        originalFieldContent.set(33);
        BitSet newFieldContent = new BitSet(33);
        newFieldContent.set(1);
        newFieldContent.set(23);
       
        ISOBitMap fieldWhichWillBeModified = new ISOBitMap(42, originalFieldContent);
        ISOBitMap fieldWhoseValueShouldNotChange = (ISOBitMap) copier.doDeepCopy(fieldWhichWillBeModified);
       
        fieldWhichWillBeModified.setValue(newFieldContent);
        fieldWhichWillBeModified.setFieldNumber(41);
       
        assertNotNull(fieldWhichWillBeModified);
        assertNotNull(fieldWhoseValueShouldNotChange);
        assertNotSame(fieldWhichWillBeModified, fieldWhoseValueShouldNotChange);
        assertEquals(originalFieldContent, fieldWhoseValueShouldNotChange.getValue());
        assertEquals(newFieldContent, fieldWhichWillBeModified.getValue());
        ISOComponentEqualityTester.assertNotEquals(fieldWhichWillBeModified, fieldWhoseValueShouldNotChange);
    }
   

}
TOP

Related Classes of org.jpos.util.ISOBitMapDeepCopierTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.