EntityFieldTest.java :  » Database-ORM » jaxor-3.5 » net » sourceforge » jaxor » tests » Java Open Source

Java Open Source » Database ORM » jaxor 3.5 
jaxor 3.5 » net » sourceforge » jaxor » tests » EntityFieldTest.java
/*
 * User: mrettig
 * Date: Jun 25, 2002
 * Time: 1:32:48 PM
 */
package net.sourceforge.jaxor.tests;

import junit.framework.TestCase;
import net.sourceforge.jaxor.MetaField;
import net.sourceforge.jaxor.mappers.FieldAdapterImpl;
import net.sourceforge.jaxor.mappers.BooleanMapper;
import net.sourceforge.jaxor.util.SystemException;

public class EntityFieldTest extends TestCase {

    public void testValidate() {
        FieldAdapterImpl field = createMapper();
        try {
            field.validate();
            fail("Should fail validation");
        } catch (SystemException expected) {
        }
    }

    private FieldAdapterImpl createMapper() {
        FieldAdapterImpl field = new FieldAdapterImpl(new MetaField("name", false, BooleanMapper.class), null);
        return field;
    }

    public void testToString() {
        FieldAdapterImpl field = createMapper();
        assertEquals("name = null", field.toString());
        field.setValue(Boolean.FALSE);
        assertEquals("name = false", field.toString());
    }

    public void testEquals() {
        FieldAdapterImpl field = createMapper();
        field.setValue(Boolean.FALSE);

        FieldAdapterImpl field2 = createMapper();
        field2.setValue(Boolean.FALSE);
        assertEquals(field, field2);
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.