/** * Tests the like operator with unicode chars. * * @throws IllegalFilterException If the constructed filter is not valid. */ public void testUnicodeLike() throws IllegalFilterException { // Set up string PropertyName testAttribute = new AttributeExpressionImpl(testSchema, "unicodeString"); PropertyIsLike filter = fac.like(testAttribute, "Barañá*", "*", ".", "!", false); assertTrue(filter.evaluate(testFeature)); filter = fac.like(testAttribute, "Barañá*", "*", ".", "!", true); assertTrue(filter.evaluate(testFeature)); filter = fac.like(testAttribute, "barañá*", "*", ".", "!", false); assertTrue(filter.evaluate(testFeature)); filter = fac.like(testAttribute, "barañá*", "*", ".", "!", true); assertFalse(filter.evaluate(testFeature)); filter = fac.like(testAttribute, "BARAÑÁ*", "*", ".", "!", false); assertTrue(filter.evaluate(testFeature)); filter = fac.like(testAttribute, "BARAÑÁ*", "*", ".", "!", true); assertFalse(filter.evaluate(testFeature)); }
/** * Tests the like operator. * * @throws IllegalFilterException If the constructed filter is not valid. */ public void testLike() throws IllegalFilterException { Pattern compPattern = java.util.regex.Pattern.compile("test.*"); Matcher matcher = compPattern.matcher("test string"); assertTrue(matcher.matches()); PropertyName testAttribute = null; // Set up string testAttribute = new AttributeExpressionImpl(testSchema, "testString"); PropertyIsLike filter = fac.like(testAttribute, "test*", "*", ".", "!"); assertTrue(filter.evaluate(testFeature)); // Test for false positive. filter = fac.like(testAttribute, "cows*", "*", ".", "!"); assertFalse(filter.evaluate(testFeature)); // Test we don't match if single character is missing filter = fac.like(testAttribute, "test*a.", "*", ".", "!"); assertFalse(filter.evaluate(testFeature)); // Test we do match if the single char is there filter = fac.like(testAttribute, "test*dat.", "*", ".", "!"); assertTrue(filter.evaluate(testFeature)); }
@Test public void testEmptyEscape() { PropertyIsLike like = ff.like(ff.literal("abc def"), "*de*", "*", "_", ""); assertTrue(like.evaluate(null)); } }