use of org.apache.solr.util.PathTrie in project lucene-solr by apache.
the class TestApiFramework method testTrailingTemplatePaths.
public void testTrailingTemplatePaths() {
PathTrie<Api> registry = new PathTrie<>();
Api api = new Api(EMPTY_SPEC) {
@Override
public void call(SolrQueryRequest req, SolrQueryResponse rsp) {
}
};
Api intropsect = new ApiBag.IntrospectApi(api, false);
ApiBag.registerIntrospect(Collections.emptyMap(), registry, "/c/.system/blob/{name}", intropsect);
ApiBag.registerIntrospect(Collections.emptyMap(), registry, "/c/.system/{x}/{name}", intropsect);
assertEquals(intropsect, registry.lookup("/c/.system/blob/random_string/_introspect", new HashMap<>()));
assertEquals(intropsect, registry.lookup("/c/.system/blob/_introspect", new HashMap<>()));
assertEquals(intropsect, registry.lookup("/c/.system/_introspect", new HashMap<>()));
assertEquals(intropsect, registry.lookup("/c/.system/v1/_introspect", new HashMap<>()));
assertEquals(intropsect, registry.lookup("/c/.system/v1/v2/_introspect", new HashMap<>()));
}
use of org.apache.solr.util.PathTrie in project lucene-solr by apache.
the class TestPathTrie method testPathTrie.
public void testPathTrie() {
PathTrie<String> pathTrie = new PathTrie<>(ImmutableSet.of("_introspect"));
pathTrie.insert("/", emptyMap(), "R");
pathTrie.insert("/aa", emptyMap(), "d");
pathTrie.insert("/aa/bb/{cc}/dd", emptyMap(), "a");
pathTrie.insert("/$handlerName/{cc}/dd", singletonMap(HANDLER_NAME, "test"), "test");
pathTrie.insert("/aa/bb/{cc}/{xx}", emptyMap(), "b");
pathTrie.insert("/aa/bb", emptyMap(), "c");
HashMap templateValues = new HashMap<>();
assertEquals("R", pathTrie.lookup("/", templateValues, null));
assertEquals("d", pathTrie.lookup("/aa", templateValues, null));
assertEquals("a", pathTrie.lookup("/aa/bb/hello/dd", templateValues, null));
templateValues.clear();
assertEquals("test", pathTrie.lookup("/test/hello/dd", templateValues, null));
assertEquals("hello", templateValues.get("cc"));
templateValues.clear();
assertEquals("b", pathTrie.lookup("/aa/bb/hello/world", templateValues, null));
assertEquals("hello", templateValues.get("cc"));
assertEquals("world", templateValues.get("xx"));
Set<String> subPaths = new HashSet<>();
templateValues.clear();
pathTrie.lookup("/aa", templateValues, subPaths);
assertEquals(3, subPaths.size());
}
Aggregations