Package org.apache.torque.test.dbobject

Examples of org.apache.torque.test.dbobject.TypesObject


     */
    public void testSetByNameMethod() throws Exception
    {

        // Testing SetByName method for Object Types
        ColumnAccessByName objectTypes = new TypesObject();
        try
        {
            for (int i = 0; i < OBJECT_COLUMN_NAMES.length; i++)
            {
                boolean status = objectTypes.setByName(OBJECT_COLUMN_NAMES[i],
                        OBJECT_TEST_VALUES[i]);
                assertTrue("setByName returned false setting column "
                        + OBJECT_COLUMN_NAMES[i], status);
            }
        }
View Full Code Here


     * @throws Exception
     */
    public void testGetByNameMethod() throws Exception
    {
        // Testing GetByName method for Object Types
        ColumnAccessByName objectTypes = new TypesObject();
        try
        {
            for (int i = 0; i < OBJECT_COLUMN_NAMES.length; i++)
            {
                objectTypes.setByName(OBJECT_COLUMN_NAMES[i],
                        OBJECT_TEST_VALUES[i]);
            }
        }
        catch (TorqueException e)
        {
            fail("Exception caught trying to call TypesObject.setByName() "
                 + "method!\nWas OM generated with torque.addGetByNameMethod "
                 + "property = true?\nError message was: '" + e.getMessage()
                 + "'");
        }
        String eMsg = "Did not get expected value for object column: ";
        for (int i = 0; i < OBJECT_COLUMN_NAMES.length; i++)
        {
            assertTrue(eMsg + OBJECT_COLUMN_NAMES[i], OBJECT_TEST_VALUES[i]
                    .equals(objectTypes.getByName(OBJECT_COLUMN_NAMES[i])));
        }

        // Test Primative Types
        ColumnAccessByName primitiveTypes = new TypesPrimitive();
        try
View Full Code Here

     * known object and primitive types.
     */
    public void testSetByPeerNameMethod() throws Exception
    {
        // Testing GetByName method for Object Types
        ColumnAccessByName objectTypes = new TypesObject();
        try
        {
            for (int i = 0; i < OBJECT_PEER_NAMES.length; i++)
            {
                boolean status = objectTypes.setByPeerName(
                        OBJECT_PEER_NAMES[i].getSqlExpression(),
                        OBJECT_TEST_VALUES[i]);
                assertTrue("setByPeerName returned false setting column "
                        + OBJECT_PEER_NAMES[i], status);
            }
        }
        catch (TorqueException e)
        {
            fail("Exception caught trying to call TypesObject.setByName() "
                 + "method!\nWas OM generated with torque.addGetByNameMethod "
                 + "property = true?\nError message was: '" + e.getMessage()
                 + "'");
        }
        String eMsg = "Did not get expected value for object column: ";
        for (int i = 0; i < OBJECT_COLUMN_NAMES.length; i++)
        {
            assertTrue(eMsg + OBJECT_COLUMN_NAMES[i], OBJECT_TEST_VALUES[i]
                    .equals(objectTypes.getByName(OBJECT_COLUMN_NAMES[i])));
        }

        // Test Primitive Types
        ColumnAccessByName primitiveTypes = new TypesPrimitive();
        try
View Full Code Here

     * for all known object and primitive types.
     */
    public void testSetByPositionMethod() throws Exception
    {
        // Testing GetByName method for Object Types
        ColumnAccessByName objectTypes = new TypesObject();
        try
        {
            for (int i = 0; i < OBJECT_PEER_NAMES.length; i++)
            {
                boolean status = objectTypes.setByPosition(i + 1,
                        OBJECT_TEST_VALUES[i]);
                assertTrue("objectTypes.setByPosition(int, Object ) returned "
                                + "false setting position " + (i + 1), status);
            }
        }
        catch (TorqueException e)
        {
            fail("Exception caught trying to call TypesObject.setByName() "
                 + "method!\nWas OM generated with torque.addGetByNameMethod "
                 + "property = true?\nError message was: '" + e.getMessage()
                 + "'");
        }
        String eMsg = "Did not get expected value for object column: ";
        for (int i = 0; i < OBJECT_COLUMN_NAMES.length; i++)
        {
            assertTrue(eMsg + OBJECT_COLUMN_NAMES[i], OBJECT_TEST_VALUES[i]
                    .equals(objectTypes.getByName(OBJECT_COLUMN_NAMES[i])));
        }

        // Test Primitive Types
        ColumnAccessByName primitiveTypes = new TypesPrimitive();
        try
View Full Code Here

     * Validate that various an IllegalArgumentException if thrown if the
     * Object type of the value is not correct.
     */
    public void testInvalidObjectErrors() throws Exception
    {
        ColumnAccessByName objectTypes = new TypesObject();
        ColumnAccessByName primitiveTypes = new TypesPrimitive();
        // Test catching invalid object types
        boolean error = false;
        try
        {
            objectTypes.setByName("OBit", new Integer(1));
        }
        catch (IllegalArgumentException e)
        {
            error = true;
        }
View Full Code Here

    /*
     * Validate that a false rc is returned if non-column names passed to methods.
     */
    public void testInvalidNameErrors() throws Exception
    {
        ColumnAccessByName objectTypes = new TypesObject();
        // Test that false status is returned for invalid column names.
        boolean status = objectTypes.setByName("xxxOBit", new Integer(1));
        assertFalse("Did not get a false status from setByName with "
                        + "invalid column name!", status);

        status = objectTypes.setByPeerName("xxxOBit", new Integer(1));
        assertFalse("Did not get a false status from setByPeerName with "
                        + "invalid column name!", status);

        status = objectTypes.setByPosition(1000, new Integer(1));
        assertFalse("Did not get a false status from setByPosition with "
                        + "invalid position!", status);
    }
View Full Code Here

    /**
     *  Verify that null handling (can't use them for primitives) works.
     */
    public void testNullHandling() throws Exception
    {
        ColumnAccessByName objectTypes = new TypesObject();
        ColumnAccessByName primitiveTypes = new TypesPrimitive();
        // Object type fields should allow nulls
        boolean error = false;
        try
        {
            objectTypes.setByName("OBit", null);
        }
        catch (IllegalArgumentException e)
        {
            error = true;
        }
View Full Code Here

TOP

Related Classes of org.apache.torque.test.dbobject.TypesObject

Copyright © 2018 www.massapicom. 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.