r52166 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r52165‎ | r52166 | r52167 >
Date:15:57, 19 June 2009
Author:daniel
Status:deferred
Tags:
Comment:
fiddeling with hsql and dbunit
Modified paths:
  • /trunk/WikiWord/WikiWord/src/main/java/de/brightbyte/wikiword/schema/WikiWordStoreSchema.java (modified) (history)
  • /trunk/WikiWord/WikiWordIntegrator/src/test/java/de/brightbyte/wikiword/integrator/IntegratorAppTestBase.java (modified) (history)
  • /trunk/WikiWord/WikiWordIntegrator/src/test/java/de/brightbyte/wikiword/integrator/LoadForeignPropertiesTest-tableImport.properties (modified) (history)
  • /trunk/WikiWord/WikiWordIntegrator/src/test/java/de/brightbyte/wikiword/integrator/LoadForeignPropertiesTest-tripleImport.properties (modified) (history)
  • /trunk/WikiWord/WikiWordIntegrator/src/test/java/de/brightbyte/wikiword/integrator/LoadForeignPropertiesTest.java (modified) (history)
  • /trunk/WikiWord/WikiWordIntegrator/src/test/java/de/brightbyte/wikiword/integrator/LoadForeignPropertiesTest.xml (modified) (history)

Diff [purge]

Index: trunk/WikiWord/WikiWord/src/main/java/de/brightbyte/wikiword/schema/WikiWordStoreSchema.java
@@ -76,8 +76,6 @@
7777
7878 protected EntityTable logTable;
7979 protected EntityTable warningTable;
80 -
81 - protected boolean useBinaryText = true;
8280
8381 private DatasetIdentifier dataset;
8482
@@ -102,9 +100,10 @@
103101 String dbengine = tweaks.getTweak("dbstore.engine", "MyISAM");
104102 String defaultTableAttributes = "ENGINE="+dbengine+" CHARSET utf8 COLLATE utf8_bin";
105103 defaultTableAttributes = tweaks.getTweak("dbstore.table.attributes", defaultTableAttributes);
106 -
107104 hints.setHint(DefaultSqlDialect.HINT_DEFAULT_TABLE_ATTRIBUTES, defaultTableAttributes);
108105
 106+ hints.setHint(MySqlDialect.HINT_USE_BINARY_TEXT, tweaks.getTweak("dbstore.useBinaryText", true));
 107+
109108 return hints;
110109 }
111110
@@ -122,7 +121,6 @@
123122 this.setLogLevel(tweaks.getTweak("dbstore.logLevel", LOG_INFO));
124123
125124 this.dataset = dataset;
126 - this.useBinaryText = tweaks.getTweak("dbstore.useBinaryText", true);
127125
128126 logTable = DatabaseAgendaPersistor.makeTableSpec(this, "log");
129127 addTable(logTable);
@@ -138,21 +136,10 @@
139137
140138 groupStats.add( new GroupStatsSpec("warning", "problem", null));
141139 }
142 -
 140+
143141 public String getCollectionName() {
144142 return dataset.getCollection();
145143 }
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 - }
157144
158145 public List<GroupStatsSpec> getGroupStatsSpecs() {
159146 return groupStats;
Index: trunk/WikiWord/WikiWordIntegrator/src/test/java/de/brightbyte/wikiword/integrator/LoadForeignPropertiesTest-tableImport.properties
@@ -2,4 +2,5 @@
33 authority="acme"
44 property-subject-field="concept_name"
55 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 @@
22 <?xml version='1.0' encoding='UTF-8'?>
33 <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"/>
830 </dataset>
931
Index: trunk/WikiWord/WikiWordIntegrator/src/test/java/de/brightbyte/wikiword/integrator/LoadForeignPropertiesTest.java
@@ -1,9 +1,6 @@
22 package de.brightbyte.wikiword.integrator;
33
4 -import java.net.URL;
54
6 -import de.brightbyte.db.testing.DatabaseTestBase;
7 -
85 public class LoadForeignPropertiesTest extends IntegratorAppTestBase<LoadForeignProperties> {
96
107 public LoadForeignPropertiesTest() {
@@ -23,11 +20,11 @@
2421
2522 //-----------------------------------------------------------------------------------------------------
2623 public void testTableImport() throws Exception {
27 - runApp("tableImport");
 24+ runApp("tableImport", "external_authority", "external_id", "property", "value", "qualifier");
2825 }
2926
3027 public void testTripleImport() throws Exception {
31 - runApp("tripleImport");
 28+ runApp("tripleImport", "external_authority", "external_id", "property", "value", "qualifier");
3229 }
3330
3431 @Override
Index: trunk/WikiWord/WikiWordIntegrator/src/test/java/de/brightbyte/wikiword/integrator/LoadForeignPropertiesTest-tripleImport.properties
@@ -3,4 +3,4 @@
44 property-subject-field="concept_name"
55 property-name-field="property"
66 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 @@
33
44 import java.io.IOException;
55 import java.net.URL;
 6+import java.sql.Connection;
 7+import java.sql.DatabaseMetaData;
 8+import java.sql.ResultSet;
 9+import java.sql.Statement;
610
 11+import org.dbunit.dataset.Column;
 12+import org.dbunit.dataset.ITable;
713 import org.dbunit.operation.DatabaseOperation;
814
915 import de.brightbyte.db.testing.DatabaseTestBase;
@@ -40,20 +46,34 @@
4147 TweakSet tweaks = loadTweakSet();
4248 T app = createApp();
4349
 50+ app.setKeepAlive(true);
4451 app.testInit(testDataSource, DatasetIdentifier.forName("TEST", "xx"), tweaks, sourceDescriptor, targetTable);
4552 return app;
4653 }
4754
48 - protected void runApp(String testName) throws Exception {
 55+ protected void runApp(String testName, String... orderBy) throws Exception {
 56+ //get source description
4957 FeatureSetSourceDescriptor source = loadSourceDescriptor(testName);
50 - launchApp(source, testName);
5158
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);
5378 }
5479
55 - protected void launchApp(FeatureSetSourceDescriptor sourceDescriptor, String targetTable) throws Exception {
56 - T app = prepareApp(sourceDescriptor, targetTable);
57 - app.testLaunch();
58 - }
59 -
6080 }

Status & tagging log