]> source.dussan.org Git - jackcess.git/commitdiff
add tests for builder property setters
authorJames Ahlborn <jtahlborn@yahoo.com>
Thu, 11 Sep 2014 01:33:45 +0000 (01:33 +0000)
committerJames Ahlborn <jtahlborn@yahoo.com>
Thu, 11 Sep 2014 01:33:45 +0000 (01:33 +0000)
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@872 f203690c-595d-4dc9-a70b-905162fa7fd2

src/main/java/com/healthmarketscience/jackcess/impl/PropertyMapImpl.java
src/test/java/com/healthmarketscience/jackcess/PropertiesTest.java

index 0667ac83cce0e923cacc3838d18b7016934983b2..648272e42040ba4a43b9c6aa7c017608c9c8e693 100644 (file)
@@ -47,7 +47,7 @@ public class PropertyMapImpl implements PropertyMap
 
     DEFAULT_TYPES.put(DEFAULT_VALUE_PROP, DataType.MEMO);
     DEFAULT_TYPES.put(REQUIRED_PROP, DataType.BOOLEAN);
-    DEFAULT_TYPES.put(ALLOW_ZERO_LEN_PROP, DataType.MEMO);
+    DEFAULT_TYPES.put(ALLOW_ZERO_LEN_PROP, DataType.BOOLEAN);
     DEFAULT_TYPES.put(DECIMAL_PLACES_PROP, DataType.BYTE);
     DEFAULT_TYPES.put(FORMAT_PROP, DataType.TEXT);
     DEFAULT_TYPES.put(INPUT_MASK_PROP, DataType.TEXT);
index f689328eec7f821fd97c83a37b2ccc5c9ab59d5c..1a17c9f70689f39de4a464e6fdf87e96040b2ba8 100644 (file)
@@ -24,11 +24,10 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
+import java.util.UUID;
 
 import static com.healthmarketscience.jackcess.Database.*;
 import static com.healthmarketscience.jackcess.DatabaseTest.*;
-import com.healthmarketscience.jackcess.impl.ByteUtil;
 import com.healthmarketscience.jackcess.impl.DatabaseImpl;
 import static com.healthmarketscience.jackcess.impl.JetFormatTest.*;
 import com.healthmarketscience.jackcess.impl.PropertyMapImpl;
@@ -349,6 +348,56 @@ public class PropertiesTest extends TestCase
     }
   }
 
+  public void testCreateDbProperties() throws Exception
+  {
+    for(FileFormat ff : SUPPORTED_FILEFORMATS) {
+      File file = DatabaseTest.createTempFile(false);
+      Database db = new DatabaseBuilder(file)
+        .setFileFormat(ff)
+        .putUserDefinedProperty("testing", "123")
+        .create();
+
+      UUID u1 = UUID.randomUUID();
+      UUID u2 = UUID.randomUUID();
+      Table t = new TableBuilder("Test")
+        .putProperty("awesome_table", true)
+        .addColumn(new ColumnBuilder("id", DataType.LONG)
+                   .setAutoNumber(true)
+                   .putProperty(PropertyMap.REQUIRED_PROP, true)
+                   .putProperty(PropertyMap.GUID_PROP, u1))
+        .addColumn(new ColumnBuilder("data", DataType.TEXT)
+                   .putProperty(PropertyMap.ALLOW_ZERO_LEN_PROP, false)
+                   .putProperty(PropertyMap.GUID_PROP, u2))
+        .toTable(db);
+
+      t.addRow(Column.AUTO_NUMBER, "value");
+
+      db.close();
+
+      db = new DatabaseBuilder(file).open();
+      
+      assertEquals("123", db.getUserDefinedProperties().getValue("testing"));
+
+      t = db.getTable("Test");
+
+      assertEquals(Boolean.TRUE, 
+                   t.getProperties().getValue("awesome_table"));
+
+      Column c = t.getColumn("id");
+      assertEquals(Boolean.TRUE, 
+                   c.getProperties().getValue(PropertyMap.REQUIRED_PROP));
+      assertEquals("{" + u1.toString().toUpperCase() + "}",
+                   c.getProperties().getValue(PropertyMap.GUID_PROP));
+
+      c = t.getColumn("data");
+      assertEquals(Boolean.FALSE,
+                   c.getProperties().getValue(PropertyMap.ALLOW_ZERO_LEN_PROP));
+      assertEquals("{" + u2.toString().toUpperCase() + "}", 
+                   c.getProperties().getValue(PropertyMap.GUID_PROP));
+
+    }
+  }
+
   private static void checkProperties(PropertyMap propMap1, 
                                       PropertyMap propMap2)
   {