Search in sources :

Example 1 with WritablePdxInstance

use of org.apache.geode.pdx.WritablePdxInstance in project geode by apache.

the class CopyJUnitTest method testIsWellKnownImmutableInstance.

@Test
public void testIsWellKnownImmutableInstance() {
    assertEquals(true, CopyHelper.isWellKnownImmutableInstance("abc"));
    assertEquals(true, CopyHelper.isWellKnownImmutableInstance(Integer.valueOf(0)));
    assertEquals(true, CopyHelper.isWellKnownImmutableInstance(Long.valueOf(0)));
    assertEquals(true, CopyHelper.isWellKnownImmutableInstance(Byte.valueOf((byte) 0)));
    assertEquals(true, CopyHelper.isWellKnownImmutableInstance(Short.valueOf((short) 0)));
    assertEquals(true, CopyHelper.isWellKnownImmutableInstance(Float.valueOf((float) 1.2)));
    assertEquals(true, CopyHelper.isWellKnownImmutableInstance(Double.valueOf(1.2)));
    assertEquals(true, CopyHelper.isWellKnownImmutableInstance(Character.valueOf((char) 0)));
    assertEquals(true, CopyHelper.isWellKnownImmutableInstance(new BigInteger("1234")));
    assertEquals(true, CopyHelper.isWellKnownImmutableInstance(new BigDecimal("123.4556")));
    assertEquals(true, CopyHelper.isWellKnownImmutableInstance(new UUID(1L, 2L)));
    PdxInstance pi = new PdxInstance() {

        public Object getObject() {
            return null;
        }

        public Object getObject(Object pdxObject) {
            return null;
        }

        public boolean hasField(String fieldName) {
            return false;
        }

        public List<String> getFieldNames() {
            return null;
        }

        public boolean isIdentityField(String fieldName) {
            return false;
        }

        public Object getField(String fieldName) {
            return null;
        }

        public WritablePdxInstance createWriter() {
            return null;
        }

        public String getClassName() {
            return null;
        }

        public boolean isEnum() {
            return false;
        }
    };
    WritablePdxInstance wpi = new WritablePdxInstance() {

        public Object getObject() {
            return null;
        }

        public Object getObject(Object pdxObject) {
            return null;
        }

        public boolean hasField(String fieldName) {
            return false;
        }

        public List<String> getFieldNames() {
            return null;
        }

        public boolean isIdentityField(String fieldName) {
            return false;
        }

        public Object getField(String fieldName) {
            return null;
        }

        public WritablePdxInstance createWriter() {
            return null;
        }

        public void setField(String fieldName, Object value) {
        }

        public String getClassName() {
            return null;
        }

        public boolean isEnum() {
            return false;
        }
    };
    assertEquals(true, CopyHelper.isWellKnownImmutableInstance(pi));
    assertEquals(false, CopyHelper.isWellKnownImmutableInstance(wpi));
    assertEquals(false, CopyHelper.isWellKnownImmutableInstance(new Object()));
}
Also used : PdxInstance(org.apache.geode.pdx.PdxInstance) WritablePdxInstance(org.apache.geode.pdx.WritablePdxInstance) BigInteger(java.math.BigInteger) BigDecimal(java.math.BigDecimal) WritablePdxInstance(org.apache.geode.pdx.WritablePdxInstance) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Aggregations

BigDecimal (java.math.BigDecimal)1 BigInteger (java.math.BigInteger)1 PdxInstance (org.apache.geode.pdx.PdxInstance)1 WritablePdxInstance (org.apache.geode.pdx.WritablePdxInstance)1 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)1 Test (org.junit.Test)1