/** Test regex that matches everything */
@Test
public void testMatchAll()
{
// set up which should match every rule
RegexRules rules = new RegexRules( new RegexMatcher()
{
@Override
public boolean match( String pathPattern, String rulePattern )
{
return true;
}
} );
rules.add( "/a/b/b", new TestRule( "alpha" ) );
rules.add( "/a/d", new TestRule( "beta" ) );
rules.add( "/b", new TestRule( "gamma" ) );
// now test a few patterns
// check that all are return in the order which they were added
List<Rule> matches = rules.match( "", "x/g/e", null, null );
assertEquals( "Wrong number of rules returned (1)", 3, matches.size() );
assertEquals( "Rule Out Of Order (1)", "alpha", ( (TestRule) matches.get( 0 ) ).getIdentifier() );
assertEquals( "Rule Out Of Order (2)", "beta", ( (TestRule) matches.get( 1 ) ).getIdentifier() );
assertEquals( "Rule Out Of Order (3)", "gamma", ( (TestRule) matches.get( 2 ) ).getIdentifier() );
matches = rules.match( "", "/a", null, null );
assertEquals( "Wrong number of rules returned (2)", 3, matches.size() );
assertEquals( "Rule Out Of Order (4)", "alpha", ( (TestRule) matches.get( 0 ) ).getIdentifier() );
assertEquals( "Rule Out Of Order (5)", "beta", ( (TestRule) matches.get( 1 ) ).getIdentifier() );
assertEquals( "Rule Out Of Order (6)", "gamma", ( (TestRule) matches.get( 2 ) ).getIdentifier() );
}