示例#1
0
  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()));
  }
示例#2
0
 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()));
 }
示例#3
0
 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());
 }
示例#4
0
  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()));
    }
  }
示例#5
0
 protected void setUp() throws Exception {
   super.setUp();
   doc = TestDocument.NAME_FACTORY.initInstance("doc1");
   doc.putIfAbsent();
   test = EntityPropertyTest.FACTORY.initInstance("test1");
   test.putIfAbsent();
 }
示例#6
0
  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());
  }
示例#7
0
 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);
 }