Index: trunk/WikiWord/WikiWord/src/main/java/de/brightbyte/wikiword/schema/WikiWordStoreSchema.java |
— | — | @@ -76,8 +76,6 @@ |
77 | 77 | |
78 | 78 | protected EntityTable logTable; |
79 | 79 | protected EntityTable warningTable; |
80 | | - |
81 | | - protected boolean useBinaryText = true; |
82 | 80 | |
83 | 81 | private DatasetIdentifier dataset; |
84 | 82 | |
— | — | @@ -102,9 +100,10 @@ |
103 | 101 | String dbengine = tweaks.getTweak("dbstore.engine", "MyISAM"); |
104 | 102 | String defaultTableAttributes = "ENGINE="+dbengine+" CHARSET utf8 COLLATE utf8_bin"; |
105 | 103 | defaultTableAttributes = tweaks.getTweak("dbstore.table.attributes", defaultTableAttributes); |
106 | | - |
107 | 104 | hints.setHint(DefaultSqlDialect.HINT_DEFAULT_TABLE_ATTRIBUTES, defaultTableAttributes); |
108 | 105 | |
| 106 | + hints.setHint(MySqlDialect.HINT_USE_BINARY_TEXT, tweaks.getTweak("dbstore.useBinaryText", true)); |
| 107 | + |
109 | 108 | return hints; |
110 | 109 | } |
111 | 110 | |
— | — | @@ -122,7 +121,6 @@ |
123 | 122 | this.setLogLevel(tweaks.getTweak("dbstore.logLevel", LOG_INFO)); |
124 | 123 | |
125 | 124 | this.dataset = dataset; |
126 | | - this.useBinaryText = tweaks.getTweak("dbstore.useBinaryText", true); |
127 | 125 | |
128 | 126 | logTable = DatabaseAgendaPersistor.makeTableSpec(this, "log"); |
129 | 127 | addTable(logTable); |
— | — | @@ -138,21 +136,10 @@ |
139 | 137 | |
140 | 138 | groupStats.add( new GroupStatsSpec("warning", "problem", null)); |
141 | 139 | } |
142 | | - |
| 140 | + |
143 | 141 | public String getCollectionName() { |
144 | 142 | return dataset.getCollection(); |
145 | 143 | } |
146 | | - |
147 | | - public String getTextType(int length) { |
148 | | - //TODO: dialects |
149 | | - //NOTE: for MySQL: VARBINARY != VARCHAR BINARY |
150 | | - |
151 | | - if (length<=256-1) return useBinaryText ? "VARBINARY("+length+")" : "VARCHAR("+length+")"; |
152 | | - else if (length<=256*4-2) return useBinaryText ? "VARBINARY("+length+")" : "VARCHAR("+length+")"; |
153 | | - else if (length<=256*256-2) return useBinaryText ? "BLOB" : "TEXT"; |
154 | | - else if (length<=256*256*256-3) return useBinaryText ? "MEDIUMBLOB" : "MEDIUMTEXT"; |
155 | | - else return useBinaryText ? "LONGBLOB" : "LONGTEXT"; |
156 | | - } |
157 | 144 | |
158 | 145 | public List<GroupStatsSpec> getGroupStatsSpecs() { |
159 | 146 | return groupStats; |
Index: trunk/WikiWord/WikiWordIntegrator/src/test/java/de/brightbyte/wikiword/integrator/LoadForeignPropertiesTest-tableImport.properties |
— | — | @@ -2,4 +2,5 @@ |
3 | 3 | authority="acme" |
4 | 4 | property-subject-field="concept_name" |
5 | 5 | fields=(concept_name,name,firstName,phone) |
6 | | - |
| 6 | +skip-header=true |
| 7 | +file-format="csv" |
Index: trunk/WikiWord/WikiWordIntegrator/src/test/java/de/brightbyte/wikiword/integrator/LoadForeignPropertiesTest.xml |
— | — | @@ -1,8 +1,30 @@ |
2 | 2 | <?xml version='1.0' encoding='UTF-8'?> |
3 | 3 | <dataset> |
4 | | - <tripleImport concept_name="FooBar" name="Foo" firstName="Bar" phone="12345"/> |
5 | | - <tripleImport concept_name="XyzzyQuux" name="Xyzzy" firstName="Quux" phone="67890"/> |
6 | | - <tableImport concept_name="FooBar" name="Foo" firstName="Bar" phone="12345"/> |
7 | | - <tableImport concept_name="XyzzyQuux" name="Xyzzy" firstName="Quux" phone="67890"/> |
| 4 | + table.addField( new DatabaseField(this, "external_authority", getTextType(64), null, true, null) ); |
| 5 | + table.addField( new DatabaseField(this, "external_id", getTextType(255), null, true, null) ); |
| 6 | + |
| 7 | + table.addField( new DatabaseField(this, "property", getTextType(255), null, true, KeyType.INDEX) ); |
| 8 | + table.addField( new DatabaseField(this, "value", getTextType(255), null, true, null) ); |
| 9 | + table.addField( new DatabaseField(this, "qualifier", getTextType(64), null, false, null) ); |
| 10 | + |
| 11 | + <tripleImport external_authority="acme" external_id="FooBar" property="concept_name" value="FooBar"/> |
| 12 | + <tripleImport external_authority="acme" external_id="FooBar" property="firstName" value="Bar"/> |
| 13 | + <tripleImport external_authority="acme" external_id="FooBar" property="name" value="Foo"/> |
| 14 | + <tripleImport external_authority="acme" external_id="FooBar" property="phone" value="12345"/> |
| 15 | + |
| 16 | + <tripleImport external_authority="acme" external_id="XyzzyQuux" property="concept_name" value="XyzzyQuux"/> |
| 17 | + <tripleImport external_authority="acme" external_id="XyzzyQuux" property="firstName" value="Quux"/> |
| 18 | + <tripleImport external_authority="acme" external_id="XyzzyQuux" property="name" value="Xyzzy"/> |
| 19 | + <tripleImport external_authority="acme" external_id="XyzzyQuux" property="phone" value="67890"/> |
| 20 | + |
| 21 | + <tableImport external_authority="acme" external_id="FooBar" property="concept_name" value="FooBar"/> |
| 22 | + <tableImport external_authority="acme" external_id="FooBar" property="firstName" value="Bar"/> |
| 23 | + <tableImport external_authority="acme" external_id="FooBar" property="name" value="Foo"/> |
| 24 | + <tableImport external_authority="acme" external_id="FooBar" property="phone" value="12345"/> |
| 25 | + |
| 26 | + <tableImport external_authority="acme" external_id="XyzzyQuux" property="concept_name" value="XyzzyQuux"/> |
| 27 | + <tableImport external_authority="acme" external_id="XyzzyQuux" property="firstName" value="Quux"/> |
| 28 | + <tableImport external_authority="acme" external_id="XyzzyQuux" property="name" value="Xyzzy"/> |
| 29 | + <tableImport external_authority="acme" external_id="XyzzyQuux" property="phone" value="67890"/> |
8 | 30 | </dataset> |
9 | 31 | |
Index: trunk/WikiWord/WikiWordIntegrator/src/test/java/de/brightbyte/wikiword/integrator/LoadForeignPropertiesTest.java |
— | — | @@ -1,9 +1,6 @@ |
2 | 2 | package de.brightbyte.wikiword.integrator; |
3 | 3 | |
4 | | -import java.net.URL; |
5 | 4 | |
6 | | -import de.brightbyte.db.testing.DatabaseTestBase; |
7 | | - |
8 | 5 | public class LoadForeignPropertiesTest extends IntegratorAppTestBase<LoadForeignProperties> { |
9 | 6 | |
10 | 7 | public LoadForeignPropertiesTest() { |
— | — | @@ -23,11 +20,11 @@ |
24 | 21 | |
25 | 22 | //----------------------------------------------------------------------------------------------------- |
26 | 23 | public void testTableImport() throws Exception { |
27 | | - runApp("tableImport"); |
| 24 | + runApp("tableImport", "external_authority", "external_id", "property", "value", "qualifier"); |
28 | 25 | } |
29 | 26 | |
30 | 27 | public void testTripleImport() throws Exception { |
31 | | - runApp("tripleImport"); |
| 28 | + runApp("tripleImport", "external_authority", "external_id", "property", "value", "qualifier"); |
32 | 29 | } |
33 | 30 | |
34 | 31 | @Override |
Index: trunk/WikiWord/WikiWordIntegrator/src/test/java/de/brightbyte/wikiword/integrator/LoadForeignPropertiesTest-tripleImport.properties |
— | — | @@ -3,4 +3,4 @@ |
4 | 4 | property-subject-field="concept_name" |
5 | 5 | property-name-field="property" |
6 | 6 | property-value-field="value" |
7 | | - |
| 7 | +file-format="csv" |
Index: trunk/WikiWord/WikiWordIntegrator/src/test/java/de/brightbyte/wikiword/integrator/IntegratorAppTestBase.java |
— | — | @@ -2,7 +2,13 @@ |
3 | 3 | |
4 | 4 | import java.io.IOException; |
5 | 5 | import java.net.URL; |
| 6 | +import java.sql.Connection; |
| 7 | +import java.sql.DatabaseMetaData; |
| 8 | +import java.sql.ResultSet; |
| 9 | +import java.sql.Statement; |
6 | 10 | |
| 11 | +import org.dbunit.dataset.Column; |
| 12 | +import org.dbunit.dataset.ITable; |
7 | 13 | import org.dbunit.operation.DatabaseOperation; |
8 | 14 | |
9 | 15 | import de.brightbyte.db.testing.DatabaseTestBase; |
— | — | @@ -40,20 +46,34 @@ |
41 | 47 | TweakSet tweaks = loadTweakSet(); |
42 | 48 | T app = createApp(); |
43 | 49 | |
| 50 | + app.setKeepAlive(true); |
44 | 51 | app.testInit(testDataSource, DatasetIdentifier.forName("TEST", "xx"), tweaks, sourceDescriptor, targetTable); |
45 | 52 | return app; |
46 | 53 | } |
47 | 54 | |
48 | | - protected void runApp(String testName) throws Exception { |
| 55 | + protected void runApp(String testName, String... orderBy) throws Exception { |
| 56 | + //get source description |
49 | 57 | FeatureSetSourceDescriptor source = loadSourceDescriptor(testName); |
50 | | - launchApp(source, testName); |
51 | 58 | |
52 | | - assertTableContent(testName, "SELECT * FROM "+testName); //FIXME: sort order |
| 59 | + //run application |
| 60 | + T app = prepareApp(source, testName); |
| 61 | + app.testLaunch(); |
| 62 | + |
| 63 | + //build order string |
| 64 | + StringBuilder order = new StringBuilder(); |
| 65 | + for (String by: orderBy) { |
| 66 | + if (order.length()>0) order.append(", "); |
| 67 | + order.append('"'); |
| 68 | + order.append(by); |
| 69 | + order.append('"'); |
| 70 | + } |
| 71 | + |
| 72 | + //get real table name and build query |
| 73 | + String tableName = app.getConfiguredDataset().getDbPrefix()+testName; |
| 74 | + String sql = "SELECT * FROM \""+tableName+"\" ORDER BY "+order; |
| 75 | + |
| 76 | + //compare query result to expected data from XML file. |
| 77 | + assertTableContent(testName, sql); |
53 | 78 | } |
54 | 79 | |
55 | | - protected void launchApp(FeatureSetSourceDescriptor sourceDescriptor, String targetTable) throws Exception { |
56 | | - T app = prepareApp(sourceDescriptor, targetTable); |
57 | | - app.testLaunch(); |
58 | | - } |
59 | | - |
60 | 80 | } |