Apache Solr open-source search software
SOLR-2045: workaround for Locales not supported by Derby
James Dyer84b624f028bd
diff --git a/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/AbstractDIHJdbcTestCase.java b/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/AbstractDIHJdbcTestCase.javaindex 0a8d3426146..5d6934f4c98 100644--- a/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/AbstractDIHJdbcTestCase.java+++ b/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/AbstractDIHJdbcTestCase.java@@ -22,14 +22,17 @@ import java.sql.Connection;import java.sql.DriverManager;import java.sql.SQLException;import java.sql.Statement;+import java.util.Locale;import java.util.regex.Matcher;import java.util.regex.Pattern;import junit.framework.Assert;+import org.apache.derby.iapi.error.StandardException;import org.apache.solr.request.LocalSolrQueryRequest;import org.junit.After;import org.junit.AfterClass;+import org.junit.Assume;import org.junit.Before;import org.junit.BeforeClass;@@ -45,9 +48,11 @@ public abstract class AbstractDIHJdbcTestCase extendsRANDOM, DERBY, HSQLDB}+ protected boolean skipThisTest = false;+private static final Pattern totalRequestsPattern = Pattern.compile(".str name..Total Requests made to DataSource..(\\d+)..str.");-+@BeforeClasspublic static void beforeClassDihJdbcTest() throws Exception {try {@@ -78,7 +83,8 @@ public abstract class AbstractDIHJdbcTestCase extends}@Before- public void beforeDihJdbcTest() throws Exception {+ public void beforeDihJdbcTest() throws Exception {+ skipThisTest = false;dbToUse = setAllowedDatabases();if (dbToUse == Database.RANDOM) {if (random().nextBoolean()) {@@ -113,7 +119,9 @@ public abstract class AbstractDIHJdbcTestCase extendss.executeUpdate("shutdown");}} catch (SQLException e) {- throw e;+ if(!skipThisTest) {+ throw e;+ }} finally {try {s.close();@@ -145,10 +153,26 @@ public abstract class AbstractDIHJdbcTestCase extendsthrow new AssertionError("Invalid database to use: " + dbToUse);}populateData(conn);- } catch (Exception e) {- throw e;+ } catch (SQLException sqe) {+ Throwable cause = sqe;+ while(cause.getCause()!=null) {+ cause = cause.getCause();+ }+ String message = cause.getMessage();+ if(cause instanceof StandardException) {+ message = ((StandardException) cause).getMessageId();+ }+ //Derby INVALID_LOCALE_DESCRIPTION+ if("XBM0X.D".equals(message)) {+ log.warn("Skipping test because Database " + dbToUse + " does not support the locale " + Locale.getDefault());+ skipThisTest = true;+ Assume.assumeNoException(sqe);+ throw sqe;+ }} finally {-+ try {+ conn.close();+ } catch (Exception e1) {}}}