-
Notifications
You must be signed in to change notification settings - Fork 2k
/
Copy pathClasspathPluginIT.java
58 lines (45 loc) · 1.81 KB
/
ClasspathPluginIT.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/
package org.opensearch.plugins;
import org.opensearch.test.OpenSearchIntegTestCase;
import java.io.IOException;
import java.util.Collection;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static org.hamcrest.Matchers.equalTo;
@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.TEST, numDataNodes = 0)
public class ClasspathPluginIT extends OpenSearchIntegTestCase {
public interface SampleExtension {}
public static class SampleExtensiblePlugin extends Plugin implements ExtensiblePlugin {
public SampleExtensiblePlugin() {}
@Override
public void loadExtensions(ExtensiblePlugin.ExtensionLoader loader) {
int nLoaded = 0;
for (SampleExtension e : loader.loadExtensions(SampleExtension.class)) {
nLoaded++;
}
assertThat(nLoaded, equalTo(1));
}
}
public static class SampleExtendingPlugin extends Plugin implements SampleExtension {
public SampleExtendingPlugin() {}
};
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Stream.concat(super.nodePlugins().stream(), Stream.of(SampleExtensiblePlugin.class, SampleExtendingPlugin.class))
.collect(Collectors.toList());
}
@Override
protected Map<Class<? extends Plugin>, Class<? extends Plugin>> extendedPlugins() {
return Map.of(SampleExtendingPlugin.class, SampleExtensiblePlugin.class);
}
public void testPluginExtensionWithClasspathPlugins() throws IOException {
internalCluster().startNode();
}
}