AnnotationDescriptor<Pattern> descriptor = new AnnotationDescriptor<Pattern>( Pattern.class );
descriptor.setValue( "regexp", "|^.*foo$" );
descriptor.setValue( "message", "pattern does not match" );
Pattern p = AnnotationFactory.create( descriptor );
PatternValidator constraint = new PatternValidator();
constraint.initialize( p );
assertTrue( constraint.isValid( null, null ) );
assertTrue( constraint.isValid( "", null ) );
assertFalse( constraint.isValid( "bla bla", null ) );
assertTrue( constraint.isValid( "foo", null ) );
assertTrue( constraint.isValid( "a b c foo", null ) );
}