Examples of AllFieldTypesTest


Examples of org.apache.openjpa.persistence.kernel.common.apps.AllFieldTypesTest

        BigInteger testBigInteger, BigDecimal testBigDecimal)
        throws Exception {
        OpenJPAEntityManager pm = getPM(true, false);
        startTx(pm);

        AllFieldTypesTest test = new AllFieldTypesTest();
        pm.persist(test);
        Object testID = pm.getObjectId(test);

        test.setTestint(testint);
        test.setTestlong(testlong);
        test.setTestdouble(testdouble);
        test.setTestshort(testshort);
        test.setTestfloat(testfloat);
        test.setTestbyte(testbyte);
        test.setTestboolean(testboolean);
        test.setTestchar(testchar);
        test.setTestString(testString);
        test.setTestDate(testDate);
        test.setTestObject(testObject);
        test.setTestBigInteger(testBigInteger);
        test.setTestBigDecimal(testBigDecimal);

        try {
            endTx(pm);
        } catch (Exception e) {
            if (e instanceof Exception &&
                ((Exception) e).getMessage().indexOf
                    ("Maximum length is 8000") != -1) {
                bug(AbstractTestCase.Platform.SQLSERVER, 5, e,
                    "SQLServer cannot deal"
                        + " with numbers with more than 8000 digits");
            } else {
                throw e;
            }
        }

        endEm(pm);

        //assertPersistent (test, true, false, false, false);

        pm = getPM(true, false);
        startTx(pm);

        AllFieldTypesTest retrievedObject =
            (AllFieldTypesTest) pm.find(AllFieldTypesTest.class, testID);

        assertEquals("Field type int", testint,
            retrievedObject.getTestint());
        assertEquals("Field type short", testshort,
            retrievedObject.getTestshort());
        assertEquals("Field type boolean", testboolean,
            retrievedObject.getTestboolean());
        assertEquals("Field type char", testchar,
            retrievedObject.getTestchar());
        assertEquals("Field type long", testlong,
            retrievedObject.getTestlong());

        assertEquals("Field type byte", testbyte,
            retrievedObject.getTestbyte());
        assertEquals("Field type String", testString,
            retrievedObject.getTestString());

        int i1 = (int) (testDate.getTime() / 1000);
        int i2 = (int) (retrievedObject.getTestDate().getTime() / 1000);

        int testDateDay = testDate.getDay();
        int testDateMonth = testDate.getMonth();
        int testDateYear = testDate.getYear();

        int retrievedObjectDay = retrievedObject.getTestDate().getDay();
        int retrievedObjectMonth = retrievedObject.getTestDate().getMonth();
        int retrievedObjectYear = retrievedObject.getTestDate().getYear();

        System.out.println("i1 : " + i1 + "\ni2 : " + i2);

        //CR346162. In this CR, it was stated that @Temporal(DATE) fields will be equal for year, month, day but not for hours,
        //minutes, seconds. So, we removed the time check and checked only for the equality of day, month and year

        /* assertEquals("Field type Date: "
     + testDate.getTime() + "!="
     + retrievedObject.getTestDate().getTime()
     + "[" + new Date(testDate.getTime()) + " != "
     + new Date(retrievedObject.getTestDate().getTime()) + "]",
     (int) (testDate.getTime() / 1000),
     (int) (retrievedObject.getTestDate().getTime() / 1000));*/

        if ((testDateDay != retrievedObjectDay) ||
            (testDateMonth != retrievedObjectMonth) ||
            (testDateYear != retrievedObjectYear)) {
            Assert.fail(
                "Field type Date not stored properly. One or more of the components of the date (day, month or year) do not match. \n" +
                    " Value that should be stored : " + testDate.toGMTString() +
                    ". \nValue that is actually" +
                    "stored : " + retrievedObject.getTestDate().toGMTString());
        }
        //assertEquals ("Field type Object", testObject,
        //retrievedObject.getTestObject ());
        assertEquals("Field type BigInteger", testBigInteger,
            retrievedObject.getTestBigInteger());

        try {
            assertEquals("Field type BigDecimal (BigInteger part)",
                testBigDecimal.toBigInteger(),
                retrievedObject.getTestBigDecimal().toBigInteger());

            assertEquals("Field type BigDecimal",
                testBigDecimal,
                retrievedObject.getTestBigDecimal());

            assertEquals("Field type float", testfloat,
                retrievedObject.getTestfloat(), 0.01f);
            assertEquals("Field type double", testdouble,
                retrievedObject.getTestdouble(), 0.01d);
        } catch (AssertionFailedError afe) {
            bug(3, afe,
                "Doubles and Floats lose precision in some data stores");
        }

View Full Code Here

Examples of org.apache.openjpa.persistence.kernel.common.apps.AllFieldTypesTest

                    "Empress cannot store min values");
        }
    }
   
    public void testLongMax() {
        AllFieldTypesTest aftt = new AllFieldTypesTest();
        aftt.setTestlong(Long.MAX_VALUE);
        saveAndQuery(aftt, "testlong =", new Long(Long.MAX_VALUE));
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.kernel.common.apps.AllFieldTypesTest

        saveAndQuery(aftt, "testlong =", new Long(Long.MAX_VALUE));
    }
   
    public void testLongMin() {
        try {
            AllFieldTypesTest aftt = new AllFieldTypesTest();
            aftt.setTestlong(Long.MIN_VALUE);
            saveAndQuery(aftt, "testlong =", new Long(Long.MIN_VALUE));
        } catch (Throwable t) {
            bug(AbstractTestCase.Platform.HYPERSONIC, 474, t,
                    "Some databases cannot store Long.MIN_VALUE");
        }
View Full Code Here

Examples of org.apache.openjpa.persistence.kernel.common.apps.AllFieldTypesTest

                    "Some databases cannot store Long.MIN_VALUE");
        }
    }
   
    public void testIntegerMax() {
        AllFieldTypesTest aftt = new AllFieldTypesTest();
        aftt.setTestint(Integer.MAX_VALUE);
        saveAndQuery(aftt, "testint =",
                new Integer(Integer.MAX_VALUE));
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.kernel.common.apps.AllFieldTypesTest

        saveAndQuery(aftt, "testint =",
                new Integer(Integer.MAX_VALUE));
    }
   
    public void testIntegerMin() {
        AllFieldTypesTest aftt = new AllFieldTypesTest();
        aftt.setTestint(Integer.MIN_VALUE);
        try {
            saveAndQuery(aftt, "testint =",
                    new Integer(Integer.MIN_VALUE));
        } catch (Throwable t) {
            bug(AbstractTestCase.Platform.EMPRESS, 889, t,
View Full Code Here

Examples of org.apache.openjpa.persistence.kernel.common.apps.AllFieldTypesTest

        }
    }
   
    public void testFloatMax() {
        try {
          AllFieldTypesTest aftt = new AllFieldTypesTest();
            aftt.setTestfloat(Float.MAX_VALUE);
            saveAndQuery(aftt, "testfloat =",
                    new Float(Float.MAX_VALUE));
        } catch (Exception e) {
            bug(getCurrentPlatform(), 494, e,
                    "Some datastores cannot store Float.MAX_VALUE");
View Full Code Here

Examples of org.apache.openjpa.persistence.kernel.common.apps.AllFieldTypesTest

        }
    }
   
    public void testFloatMin() {
        try {
            AllFieldTypesTest aftt = new AllFieldTypesTest();
            aftt.setTestfloat(Float.MIN_VALUE);
            saveAndQuery(aftt, "testfloat =",
                    new Float(Float.MIN_VALUE));
        } catch (Exception e) {
            bug(getCurrentPlatform(), 494, e,
                    "Some databases cannot store Float.MIN_VALUE");
View Full Code Here

Examples of org.apache.openjpa.persistence.kernel.common.apps.AllFieldTypesTest

        }
    }
   
    public void testFloatNaN() {
        try {
            AllFieldTypesTest aftt = new AllFieldTypesTest();
            aftt.setTestfloat(Float.NaN);
            saveAndQuery(aftt, "testfloat =", new Float(Float.NaN));
        } catch (Throwable t) {
            bug(461, t, "NaN problems");
        }
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.kernel.common.apps.AllFieldTypesTest

        }
    }
   
    public void testFloatNegativeInfinity() {
        try {
            AllFieldTypesTest aftt = new AllFieldTypesTest();
            aftt.setTestfloat(Float.NEGATIVE_INFINITY);
            saveAndQuery(aftt, "testfloat =",
                    new Float(Float.NEGATIVE_INFINITY));
        } catch (Exception e) {
            bug(getCurrentPlatform(), 494, e,
                    "Some databases cannot store Float.NEGATIVE_INFINITY");
View Full Code Here

Examples of org.apache.openjpa.persistence.kernel.common.apps.AllFieldTypesTest

        }
    }
   
    public void testFloatPostivieInfinity() {
        try {
            AllFieldTypesTest aftt = new AllFieldTypesTest();
            aftt.setTestfloat(Float.POSITIVE_INFINITY);
            saveAndQuery(aftt, "testfloat =",
                    new Float(Float.POSITIVE_INFINITY));
        } catch (Exception e) {
            bug(getCurrentPlatform(), 494, e,
                    "Some databases cannot store Float.POSITIVE_INFINITY");
View Full Code Here
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.