Package org.apache.torque.test.dbobject

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


    public void testDateTime() throws Exception
    {
        cleanDateTimeTimestampTable();

        // insert new DateTest object to db
        DateTimeTimestampType dateTimeTimestamp = new DateTimeTimestampType();
        Date now = new Date();
        dateTimeTimestamp.setDateValue(now);
        dateTimeTimestamp.setTimeValue(now);
        dateTimeTimestamp.setTimestampValue(now);
        dateTimeTimestamp.save();

        // reload dateTest from db
        DateTimeTimestampType loaded = DateTimeTimestampTypePeer.retrieveByPK(
                dateTimeTimestamp.getPrimaryKey());

        // calculate expected value
        Date expected;
//        if (adapter instanceof DBOracle)
//        {
//            expected = new Date(now.getTime() / 1000L * 1000L);
//        }
//        else
        {
            Calendar calendar = new GregorianCalendar();
            calendar.setTime(now);
            calendar.set(Calendar.MILLISECOND, 0);
            calendar.set(Calendar.SECOND, 0);
            calendar.set(Calendar.MINUTE, 0);
            calendar.set(Calendar.HOUR_OF_DAY, 0);
            expected = calendar.getTime();
        }

        // verify
        assertEquals(expected, loaded.getDateValue());
    }
View Full Code Here


    public void testTime() throws Exception
    {
        cleanDateTimeTimestampTable();

        // insert new DateTest object to db
        DateTimeTimestampType dateTimeTimestamp = new DateTimeTimestampType();
        Date now = new Date();
        dateTimeTimestamp.setDateValue(now);
        dateTimeTimestamp.setTimeValue(now);
        dateTimeTimestamp.setTimestampValue(now);
        dateTimeTimestamp.save();

        // reload dateTest from db
        DateTimeTimestampType loaded = DateTimeTimestampTypePeer.retrieveByPK(
                dateTimeTimestamp.getPrimaryKey());

        // calculate expected value
        Date expected;
//        if (adapter instanceof DBOracle)
//        {
//            expected = new Date(now.getTime() / 1000L * 1000L);
//        }
//        else
        {
            Calendar calendar = new GregorianCalendar();
            calendar.setTime(now);
            calendar.set(Calendar.DAY_OF_MONTH, 1);
            calendar.set(Calendar.MONTH, Calendar.JANUARY);
            calendar.set(Calendar.YEAR, 1970);
            calendar.set(Calendar.MILLISECOND, 0);
            expected = calendar.getTime();
        }

        // verify
        long loadedTimestampRounded
                = loaded.getTimeValue().getTime() / 1000L * 1000L;
        assertEquals(expected, new Date(loadedTimestampRounded));
    }
View Full Code Here

    public void testTimestamp() throws Exception
    {
        cleanDateTimeTimestampTable();

        // insert new DateTest object to db
        DateTimeTimestampType dateTimeTimestamp = new DateTimeTimestampType();
        Date now = new Date();
        dateTimeTimestamp.setDateValue(now);
        dateTimeTimestamp.setTimeValue(now);
        dateTimeTimestamp.setTimestampValue(now);
        dateTimeTimestamp.save();

        // reload dateTest from db
        DateTimeTimestampType loaded = DateTimeTimestampTypePeer.retrieveByPK(
                dateTimeTimestamp.getPrimaryKey());

        // calculate expected value
        Date min = new Date(now.getTime() / 1000L * 1000L);;
        Date max = new Date(min.getTime() + 999L);

        // verify
        DateFormat dateFormat = new SimpleDateFormat();
        Date actual = loaded.getTimestampValue();
        assertFalse(
                "the loaded value " + dateFormat.format(actual)
                    + " should not be after " + dateFormat.format(min),
                min.after(actual));
        assertFalse(
View Full Code Here

    public void testSelectWithUtilDateOnDate() throws TorqueException
    {
        cleanDateTimeTimestampTable();

        // insert new DateTest object to db
        DateTimeTimestampType dateTimeTimestamp = new DateTimeTimestampType();
        dateTimeTimestamp.setDateValue(
                new GregorianCalendar(2010, 1, 23).getTime());
        dateTimeTimestamp.setTimeValue(new Date());
        dateTimeTimestamp.setTimestampValue(new Date());
        dateTimeTimestamp.save();

        // execute select
        Criteria criteria = new Criteria();
        criteria.where(DateTimeTimestampTypePeer.DATE_VALUE,
                new GregorianCalendar(2010, 1, 23).getTime());
View Full Code Here

            return;
        }
        cleanDateTimeTimestampTable();

        // insert new DateTest object to db
        DateTimeTimestampType dateTimeTimestamp = new DateTimeTimestampType();
        dateTimeTimestamp.setDateValue(new Date());
        dateTimeTimestamp.setTimeValue(new Date(1234000));
        dateTimeTimestamp.setTimestampValue(new Date());
        dateTimeTimestamp.save();

        // execute select
        Criteria criteria = new Criteria();
        criteria.where(DateTimeTimestampTypePeer.TIME_VALUE, new Date(1234000));
        List<DateTimeTimestampType> result
View Full Code Here

            return;
        }
        cleanDateTimeTimestampTable();

        // insert new DateTest object to db
        DateTimeTimestampType dateTimeTimestamp = new DateTimeTimestampType();
        dateTimeTimestamp.setDateValue(new Date());
        dateTimeTimestamp.setTimeValue(new Date(1234000));
        dateTimeTimestamp.setTimestampValue(new Date());
        dateTimeTimestamp.save();

        // execute select
        Criteria criteria = new Criteria();
        criteria.where(
                DateTimeTimestampTypePeer.TIME_VALUE,
View Full Code Here

    public void testSelectWithUtilDateOnTimestamp() throws TorqueException
    {
        cleanDateTimeTimestampTable();

        // insert new DateTest object to db
        DateTimeTimestampType dateTimeTimestamp = new DateTimeTimestampType();
        dateTimeTimestamp.setDateValue(new Date());
        dateTimeTimestamp.setTimeValue(new Date());
        dateTimeTimestamp.setTimestampValue(
                new GregorianCalendar(2010, 1, 23).getTime());
        dateTimeTimestamp.save();

        // execute select
        Criteria criteria = new Criteria();
        criteria.where(DateTimeTimestampTypePeer.TIMESTAMP_VALUE,
                new GregorianCalendar(2010, 1, 23).getTime());
View Full Code Here

            throws TorqueException
    {
        cleanDateTimeTimestampTable();

        // insert new DateTest object to db
        DateTimeTimestampType dateTimeTimestamp = new DateTimeTimestampType();
        dateTimeTimestamp.setDateValue(new Date());
        dateTimeTimestamp.setTimeValue(new Date());
        dateTimeTimestamp.setTimestampValue(
                new GregorianCalendar(2010, 1, 23).getTime());
        dateTimeTimestamp.save();

        // execute select
        Criteria criteria = new Criteria();
        Date toSelect = new GregorianCalendar(2010, 1, 23).getTime();
        toSelect = new Date(toSelect.getTime() - 1000L);
View Full Code Here

            throws TorqueException
    {
        cleanDateTimeTimestampTable();

        // insert new DateTest object to db
        DateTimeTimestampType dateTimeTimestamp = new DateTimeTimestampType();
        dateTimeTimestamp.setDateValue(new Date());
        dateTimeTimestamp.setTimeValue(new Date());
        GregorianCalendar calendar = new GregorianCalendar(2010, 1, 23);
        calendar.set(GregorianCalendar.MILLISECOND, 123);
        dateTimeTimestamp.setTimestampValue(calendar.getTime());
        dateTimeTimestamp.save();

        // execute matching select
        Criteria criteria = new Criteria();
        calendar = new GregorianCalendar(2010, 1, 23);
        calendar.set(GregorianCalendar.MILLISECOND, 123);
View Full Code Here

            return;
        }
        cleanDateTimeTimestampTable();

        // insert new DateTest object to db
        DateTimeTimestampType dateTimeTimestamp = new DateTimeTimestampType();
        dateTimeTimestamp.setDateValue(new Date());
        dateTimeTimestamp.setTimeValue(new Date());
        GregorianCalendar calendar = new GregorianCalendar(2010, 1, 23);
        calendar.set(GregorianCalendar.MILLISECOND, 123);
        dateTimeTimestamp.setTimestampValue(calendar.getTime());
        dateTimeTimestamp.save();

        // execute matching select
        Criteria criteria = new Criteria();
        calendar = new GregorianCalendar(2010, 1, 23);
        calendar.set(GregorianCalendar.MILLISECOND, 124);
View Full Code Here

TOP

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

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.