Rework StringUtilsTest from plain JUnit to ESTestCase

Original commit: elastic/x-pack-elasticsearch@cd16043f23
This commit is contained in:
Costin Leau 2017-09-30 01:17:33 +03:00
parent e0d02033de
commit e1a7c59d15
1 changed files with 2 additions and 11 deletions

View File

@ -5,49 +5,40 @@
*/
package org.elasticsearch.xpack.sql.util;
import org.junit.Test;
import org.elasticsearch.test.ESTestCase;
import static org.elasticsearch.xpack.sql.util.StringUtils.sqlToJavaPattern;
import static org.junit.Assert.assertEquals;
public class StringUtilsTest {
public class StringUtilsTests extends ESTestCase {
@Test
public void testNoRegex() {
assertEquals("^fooBar$", sqlToJavaPattern("fooBar"));
}
@Test
public void testEscapedJavaRegex() {
assertEquals("^\\.\\d$", sqlToJavaPattern("\\.\\d"));
}
@Test
public void testSimpleSqlRegex1() {
assertEquals("^foo.bar$", sqlToJavaPattern("foo_bar"));
}
@Test
public void testSimpleSqlRegex2() {
assertEquals("^foo.*bar$", sqlToJavaPattern("foo%bar"));
}
@Test
public void testMultipleSqlRegexes() {
assertEquals("^foo.*bar.$", sqlToJavaPattern("foo%bar_"));
}
@Test
public void testJavaRegexNoSqlRegex() {
assertEquals("^foo\\.\\*bar$", sqlToJavaPattern("foo.*bar"));
}
@Test
public void testMultipleRegexAndSqlRegex() {
assertEquals("^foo\\.\\*bar\\..*$", sqlToJavaPattern("foo.*bar.%"));
}
@Test
public void testComplicatedJavaRegex() {
assertEquals("^\\^\\[\\d\\]\\.\\*\\$$", sqlToJavaPattern("^[\\d].*$"));
}