Skip to content

Commit

Permalink
fix(#1046): bugs in resource path resolvers
Browse files Browse the repository at this point in the history
* make use of auto-closeable on `InputStream`
* fix loading from XML properties
  • Loading branch information
bbortt committed Nov 3, 2023
1 parent d918fe3 commit 1aabea7
Show file tree
Hide file tree
Showing 2 changed files with 135 additions and 112 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public interface MessageSelector {
/**
* Resolves all available selectors from resource path lookup. Scans classpath for validator meta information
* and instantiates those selectors.
*
* @return
*/
static Map<String, MessageSelectorFactory> lookup() {
Expand All @@ -39,21 +40,24 @@ static Map<String, MessageSelectorFactory> lookup() {
factories.forEach((k, v) -> logger.debug(String.format("Found message selector '%s' as %s", k, v.getClass())));
}
}

return factories;
}

/**
* Checks weather this selector should accept given message or not. When accepting the message the
* selective consumer is provided with the message otherwise the message is skipped for this consumer.
* @param message
* @return true to accept the message, false to decline.
*
* @param message the message to check
* @return true if the message will be accepted, false otherwise.
*/
boolean accept(Message message);

/**
* Special message selector accepts all messages on queue.
*/
final class AllAcceptingMessageSelector implements MessageSelector {

public boolean accept(Message message) {
return true;
}
Expand All @@ -65,18 +69,21 @@ public boolean accept(Message message) {
interface MessageSelectorFactory {

/**
* Check if this factories is able to create a message selector for given key.
* @param key
* @return
* Check if this factory is able to create a message selector for given key.
*
* @param key selector key
* @return true if the factory accepts the key, false otherwise.
*/
boolean supports(String key);

/**
* Create new message selector for given predicates.
* @param key
* @param value
* @param context
* @return
*
* @param key selector key
* @param value selector value
* @param context test context
*
* @return the created selector
*/
MessageSelector create(String key, String value, TestContext context);
}
Expand Down
Loading

0 comments on commit 1aabea7

Please sign in to comment.