From 1504523273f3cc8b04d0494a3277663e51743d4a Mon Sep 17 00:00:00 2001 From: Luke Inman-Semerau Date: Fri, 29 Jan 2016 10:54:53 -0800 Subject: [PATCH] add a way to add to the list of capabilities to consider to the default capability matcher also enable it to be extensible --- .../grid/internal/utils/DefaultCapabilityMatcher.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/java/server/src/org/openqa/grid/internal/utils/DefaultCapabilityMatcher.java b/java/server/src/org/openqa/grid/internal/utils/DefaultCapabilityMatcher.java index 20de65d67b162..ca2cf7cf007c3 100644 --- a/java/server/src/org/openqa/grid/internal/utils/DefaultCapabilityMatcher.java +++ b/java/server/src/org/openqa/grid/internal/utils/DefaultCapabilityMatcher.java @@ -36,8 +36,7 @@ public class DefaultCapabilityMatcher implements CapabilityMatcher { private static final Logger log = Logger.getLogger(DefaultCapabilityMatcher.class.getName()); private static final String GRID_TOKEN = "_"; - // temporary fix to only check to most meaningful desiredCapability params - private final List toConsider = new ArrayList<>(); + protected final List toConsider = new ArrayList<>(); public DefaultCapabilityMatcher() { toConsider.add(CapabilityType.PLATFORM); @@ -47,6 +46,13 @@ public DefaultCapabilityMatcher() { } + /** + * @param capabilityName capability name to have grid match requested with test slot + */ + public void addToConsider(String capabilityName) { + toConsider.add(capabilityName); + } + public boolean matches(Map nodeCapability, Map requestedCapability) { if (nodeCapability == null || requestedCapability == null) { return false; @@ -54,7 +60,6 @@ public boolean matches(Map nodeCapability, Map r for (String key : requestedCapability.keySet()) { // ignore capabilities that are targeted at grid internal for the // matching - // TODO freynaud only consider version, browser and OS for now if (!key.startsWith(GRID_TOKEN) && toConsider.contains(key)) { if (requestedCapability.get(key) != null) { String value = requestedCapability.get(key).toString();