aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/com/healthmarketscience/jackcess/PropertiesTest.java
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2014-09-11 01:33:45 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2014-09-11 01:33:45 +0000
commit84089cb1372dc7f12ddacdfd165b0c1e8633f8ed (patch)
tree927e2f9742e97e13740056970315654130070168 /src/test/java/com/healthmarketscience/jackcess/PropertiesTest.java
parent7d4abaafe28d9dfb61480c9d29b24bbd9a0001e3 (diff)
downloadjackcess-84089cb1372dc7f12ddacdfd165b0c1e8633f8ed.tar.gz
jackcess-84089cb1372dc7f12ddacdfd165b0c1e8633f8ed.zip
add tests for builder property setters
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@872 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src/test/java/com/healthmarketscience/jackcess/PropertiesTest.java')
-rw-r--r--src/test/java/com/healthmarketscience/jackcess/PropertiesTest.java53
1 files changed, 51 insertions, 2 deletions
diff --git a/src/test/java/com/healthmarketscience/jackcess/PropertiesTest.java b/src/test/java/com/healthmarketscience/jackcess/PropertiesTest.java
index f689328..1a17c9f 100644
--- a/src/test/java/com/healthmarketscience/jackcess/PropertiesTest.java
+++ b/src/test/java/com/healthmarketscience/jackcess/PropertiesTest.java
@@ -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)
{