teiid SVN: r4599 - in branches/7.7.x/engine/src: test/java/org/teiid/query/sql/lang and 1 other directory.
by teiid-commits@lists.jboss.org
Author: jolee
Date: 2013-10-02 11:37:12 -0400 (Wed, 02 Oct 2013)
New Revision: 4599
Modified:
branches/7.7.x/engine/src/main/java/org/teiid/query/sql/lang/MatchCriteria.java
branches/7.7.x/engine/src/test/java/org/teiid/query/sql/lang/TestMatchCriteria.java
Log:
TEIID-2138 adding an emulation option to match criteria
Modified: branches/7.7.x/engine/src/main/java/org/teiid/query/sql/lang/MatchCriteria.java
===================================================================
--- branches/7.7.x/engine/src/main/java/org/teiid/query/sql/lang/MatchCriteria.java 2013-10-02 15:37:04 UTC (rev 4598)
+++ branches/7.7.x/engine/src/main/java/org/teiid/query/sql/lang/MatchCriteria.java 2013-10-02 15:37:12 UTC (rev 4599)
@@ -31,6 +31,7 @@
import org.teiid.core.util.EquivalenceUtil;
import org.teiid.core.util.HashCodeUtil;
import org.teiid.core.util.LRUCache;
+import org.teiid.core.util.PropertiesUtils;
import org.teiid.language.Like.MatchMode;
import org.teiid.query.QueryPlugin;
import org.teiid.query.sql.LanguageVisitor;
@@ -62,8 +63,10 @@
/** The internal null escape character */
public static final char NULL_ESCAPE_CHAR = 0;
+ static char DEFAULT_ESCAPE_CHAR = PropertiesUtils.getBooleanProperty(System.getProperties(), "org.teiid.backslashDefaultMatchEscape", false)?'\\':NULL_ESCAPE_CHAR; //$NON-NLS-1$
+
/** The escape character or '' if there is none */
- private char escapeChar = NULL_ESCAPE_CHAR;
+ private char escapeChar = DEFAULT_ESCAPE_CHAR;
/** Negation flag. Indicates whether the criteria expression contains a NOT. */
private boolean negated;
Modified: branches/7.7.x/engine/src/test/java/org/teiid/query/sql/lang/TestMatchCriteria.java
===================================================================
--- branches/7.7.x/engine/src/test/java/org/teiid/query/sql/lang/TestMatchCriteria.java 2013-10-02 15:37:04 UTC (rev 4598)
+++ branches/7.7.x/engine/src/test/java/org/teiid/query/sql/lang/TestMatchCriteria.java 2013-10-02 15:37:12 UTC (rev 4599)
@@ -22,20 +22,15 @@
package org.teiid.query.sql.lang;
+import static org.junit.Assert.*;
+
+import org.junit.Test;
import org.teiid.core.util.UnitTestUtil;
-import org.teiid.query.sql.lang.MatchCriteria;
-import org.teiid.query.sql.symbol.*;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
-import junit.framework.*;
+public class TestMatchCriteria {
-public class TestMatchCriteria extends TestCase {
-
- // ################################## FRAMEWORK ################################
-
- public TestMatchCriteria(String name) {
- super(name);
- }
-
// ################################## TEST HELPERS ################################
public static MatchCriteria example(String element, String str) {
@@ -62,13 +57,13 @@
// ################################## ACTUAL TESTS ################################
- public void testEquals1() {
+ @Test public void testEquals1() {
MatchCriteria c1 = example("abc"); //$NON-NLS-1$
MatchCriteria c2 = example("abc"); //$NON-NLS-1$
assertTrue("Equivalent match criteria don't compare as equal: " + c1 + ", " + c2, c1.equals(c2)); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testEquals2() {
+ @Test public void testEquals2() {
MatchCriteria c1 = example("abc", '#'); //$NON-NLS-1$
c1.setNegated(true);
MatchCriteria c2 = example("abc", '#'); //$NON-NLS-1$
@@ -76,46 +71,46 @@
assertTrue("Equivalent match criteria don't compare as equal: " + c1 + ", " + c2, c1.equals(c2)); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testEquals3() {
+ @Test public void testEquals3() {
MatchCriteria c1 = example("abc", '#'); //$NON-NLS-1$
c1.setNegated(true);
MatchCriteria c2 = (MatchCriteria) c1.clone();
assertTrue("Equivalent match criteria don't compare as equal: " + c1 + ", " + c2, c1.equals(c2)); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testEquals4() {
+ @Test public void testEquals4() {
MatchCriteria c1 = example("abc"); //$NON-NLS-1$
MatchCriteria c2 = example("abc", '#'); //$NON-NLS-1$
assertTrue("Different match criteria compare as equal: " + c1 + ", " + c2, ! c1.equals(c2)); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testEquals5() {
+ @Test public void testEquals5() {
MatchCriteria c1 = example("e1", "abc"); //$NON-NLS-1$ //$NON-NLS-2$
MatchCriteria c2 = example("e2", "abc"); //$NON-NLS-1$ //$NON-NLS-2$
assertTrue("Different match criteria compare as equal: " + c1 + ", " + c2, ! c1.equals(c2)); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testSelfEquivalence(){
+ @Test public void testSelfEquivalence(){
MatchCriteria c1 = example("abc"); //$NON-NLS-1$
int equals = 0;
UnitTestUtil.helpTestEquivalence(equals, c1, c1);
}
- public void testEquivalence(){
+ @Test public void testEquivalence(){
MatchCriteria c1 = example("abc"); //$NON-NLS-1$
MatchCriteria c2 = example("abc"); //$NON-NLS-1$
int equals = 0;
UnitTestUtil.helpTestEquivalence(equals, c1, c2);
}
- public void testCloneEquivalence(){
+ @Test public void testCloneEquivalence(){
MatchCriteria c1 = example("abc"); //$NON-NLS-1$
MatchCriteria c2 = (MatchCriteria)c1.clone();
int equals = 0;
UnitTestUtil.helpTestEquivalence(equals, c1, c2);
}
- public void testNonEquivalence1(){
+ @Test public void testNonEquivalence1(){
//test transitivity with two nonequal Objects
MatchCriteria c1 = example("e1", "abc"); //$NON-NLS-1$ //$NON-NLS-2$
MatchCriteria c2 = example("ozzy", '#'); //$NON-NLS-1$
@@ -123,7 +118,7 @@
UnitTestUtil.helpTestEquivalence(equals, c1, c2);
}
- public void testNonEquivalence2(){
+ @Test public void testNonEquivalence2(){
MatchCriteria c1 = example("abc", '#'); //$NON-NLS-1$
c1.setNegated(true);
MatchCriteria c2 = example("abc", '#'); //$NON-NLS-1$