public void testSupportSerializableDataType() throws Exception { SerializedObject value = new SerializedObject(); value.value = 5; test = EntityPropertyTest.FACTORY.initInstance("test1"); test.putIfAbsent(); EntityPropertyImpl<EntityPropertyTest, SerializedObject> prop = new EntityPropertyImpl<EntityPropertyTest, SerializedObject>( test.getEntityBasePropertyAccess(), SerializedObject.class, "serializable", SerializableDataTypeTranslatorImpl.getInstance(SerializedObject.class), true); prop.set(value); test.put(); prop = new EntityPropertyImpl<EntityPropertyTest, SerializedObject>( test.getEntityBasePropertyAccess(), SerializedObject.class, "serializable", SerializableDataTypeTranslatorImpl.getInstance(SerializedObject.class), true); assertEquals(value, SerializedObject.class.cast(prop.get())); }
public void testShortBlob() throws Exception { EntityPropertyImpl<EntityPropertyTest, ShortBlob> prop = new EntityPropertyImpl<EntityPropertyTest, ShortBlob>( test.getEntityBasePropertyAccess(), ShortBlob.class, "shortBlobProperty", DataTypeTranslatorFactory.getUnindexedTranslator(ShortBlob.class), true); prop.set(new ShortBlob("testShortBlob".getBytes())); test.put(); assertEquals("testShortBlob", new String(prop.get().getBytes())); }
public void testStringProperty() throws Exception { EntityPropertyImpl<EntityPropertyTest, String> prop = new EntityPropertyImpl<EntityPropertyTest, String>( test.getEntityBasePropertyAccess(), String.class, "stringProperty", DataTypeTranslatorFactory.getUnindexedTranslator(String.class), true); prop.set("testString"); test.put(); assertEquals("testString", prop.get()); }
public <T> void checkPropertyType(Class<T> typeClass, T... values) throws Exception { String propName = typeClass.getSimpleName() + "Property"; EntityPropertyImpl<EntityPropertyTest, T> prop = createProperty(typeClass, propName); test.putIfAbsent(); for (T value : values) { prop.set(value); test.put(); prop = createProperty(typeClass, propName); assertEquals(value, typeClass.cast(prop.get())); } }
protected void setUp() throws Exception { super.setUp(); doc = TestDocument.NAME_FACTORY.initInstance("doc1"); doc.putIfAbsent(); test = EntityPropertyTest.FACTORY.initInstance("test1"); test.putIfAbsent(); }
public void testBool() throws Exception { EntityPropertyImpl<EntityPropertyTest, Boolean> prop = new EntityPropertyImpl<EntityPropertyTest, Boolean>( test.getEntityBasePropertyAccess(), Boolean.class, "booleanProperty", DataTypeTranslatorFactory.getUnindexedTranslator(Boolean.class), true); prop.set(true); test.put(); assertTrue(prop.get()); prop.set(false); test.put(); assertFalse(prop.get()); }
private <T> EntityPropertyImpl<EntityPropertyTest, T> createProperty( Class<T> typeClass, String name) throws Exception { test = EntityPropertyTest.FACTORY.initInstance("test1"); return new EntityPropertyImpl<EntityPropertyTest, T>( test.getEntityBasePropertyAccess(), typeClass, name, DataTypeTranslatorFactory.getUnindexedTranslator(typeClass), true); }