use of java.util.Arrays.asList in project guava by hceylan.
the class MultisetCollectionTest method suite.
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(MultisetTestSuiteBuilder.using(hashMultisetGenerator()).withFeatures(CollectionSize.ANY, CollectionFeature.ALLOWS_NULL_VALUES, CollectionFeature.SERIALIZABLE, CollectionFeature.GENERAL_PURPOSE).named("HashMultiset").createTestSuite());
suite.addTest(MultisetTestSuiteBuilder.using(unmodifiableMultisetGenerator()).withFeatures(CollectionSize.ANY, CollectionFeature.KNOWN_ORDER, CollectionFeature.SERIALIZABLE, CollectionFeature.ALLOWS_NULL_QUERIES).named("UnmodifiableTreeMultiset").createTestSuite());
suite.addTest(SortedMultisetTestSuiteBuilder.using(new TestStringMultisetGenerator() {
@Override
protected Multiset<String> create(String[] elements) {
return TreeMultiset.create(Arrays.asList(elements));
}
@Override
public List<String> order(List<String> insertionOrder) {
return Ordering.natural().sortedCopy(insertionOrder);
}
}).withFeatures(CollectionSize.ANY, CollectionFeature.KNOWN_ORDER, CollectionFeature.GENERAL_PURPOSE, CollectionFeature.SERIALIZABLE, CollectionFeature.ALLOWS_NULL_QUERIES).named("TreeMultiset, Ordering.natural").createTestSuite());
suite.addTest(SortedMultisetTestSuiteBuilder.using(new TestStringMultisetGenerator() {
@Override
protected Multiset<String> create(String[] elements) {
Multiset<String> result = TreeMultiset.create(new NullsBeforeB());
result.addAll(Arrays.asList(elements));
return result;
}
@Override
public List<String> order(List<String> insertionOrder) {
return new NullsBeforeB().sortedCopy(insertionOrder);
}
}).withFeatures(CollectionSize.ANY, CollectionFeature.KNOWN_ORDER, CollectionFeature.GENERAL_PURPOSE, CollectionFeature.SERIALIZABLE, CollectionFeature.ALLOWS_NULL_VALUES).named("TreeMultiset, NullsBeforeB").createTestSuite());
suite.addTest(MultisetTestSuiteBuilder.using(forSetGenerator()).withFeatures(CollectionSize.ANY, CollectionFeature.ALLOWS_NULL_VALUES, CollectionFeature.SERIALIZABLE, CollectionFeature.REMOVE_OPERATIONS).suppressing(getReadsDuplicateInitializingMethods()).suppressing(getSetCountDuplicateInitializingMethods()).suppressing(getIteratorDuplicateInitializingMethods()).named("ForSetMultiset").createTestSuite());
suite.addTest(MultisetTestSuiteBuilder.using(concurrentMultisetGenerator()).withFeatures(CollectionSize.ANY, CollectionFeature.GENERAL_PURPOSE, CollectionFeature.SERIALIZABLE, CollectionFeature.ALLOWS_NULL_QUERIES).named("ConcurrentHashMultiset").createTestSuite());
suite.addTest(MultisetTestSuiteBuilder.using(enumMultisetGenerator()).withFeatures(CollectionSize.ANY, CollectionFeature.KNOWN_ORDER, CollectionFeature.GENERAL_PURPOSE, CollectionFeature.ALLOWS_NULL_QUERIES).named("EnumMultiset").createTestSuite());
suite.addTest(MultisetTestSuiteBuilder.using(intersectionGenerator()).withFeatures(CollectionSize.ANY, CollectionFeature.ALLOWS_NULL_VALUES, CollectionFeature.KNOWN_ORDER).named("IntersectionMultiset").createTestSuite());
suite.addTest(SortedMultisetTestSuiteBuilder.using(unmodifiableSortedMultisetGenerator()).withFeatures(CollectionSize.ANY, CollectionFeature.KNOWN_ORDER, CollectionFeature.ALLOWS_NULL_QUERIES).named("UnmodifiableSortedTreeMultiset").createTestSuite());
return suite;
}
use of java.util.Arrays.asList in project jackrabbit-oak by apache.
the class ScalabilityRunner method main.
public static void main(String[] args) throws Exception {
OptionParser parser = new OptionParser();
OptionSpec<File> base = parser.accepts("base", "Base directory").withRequiredArg().ofType(File.class).defaultsTo(new File("target"));
OptionSpec<String> host = parser.accepts("host", "MongoDB host").withRequiredArg().defaultsTo("localhost");
OptionSpec<Integer> port = parser.accepts("port", "MongoDB port").withRequiredArg().ofType(Integer.class).defaultsTo(27017);
OptionSpec<String> dbName = parser.accepts("db", "MongoDB database").withRequiredArg();
OptionSpec<Boolean> dropDBAfterTest = parser.accepts("dropDBAfterTest", "Whether to drop the MongoDB database after the test").withOptionalArg().ofType(Boolean.class).defaultsTo(true);
OptionSpec<String> rdbjdbcuri = parser.accepts("rdbjdbcuri", "RDB JDBC URI").withOptionalArg().defaultsTo("jdbc:h2:./target/benchmark");
OptionSpec<String> rdbjdbcuser = parser.accepts("rdbjdbcuser", "RDB JDBC user").withOptionalArg().defaultsTo("");
OptionSpec<String> rdbjdbcpasswd = parser.accepts("rdbjdbcpasswd", "RDB JDBC password").withOptionalArg().defaultsTo("");
OptionSpec<String> rdbjdbctableprefix = parser.accepts("rdbjdbctableprefix", "RDB JDBC table prefix").withOptionalArg().defaultsTo("");
OptionSpec<Boolean> mmap = parser.accepts("mmap", "TarMK memory mapping").withOptionalArg().ofType(Boolean.class).defaultsTo("64".equals(System.getProperty("sun.arch.data.model")));
OptionSpec<Integer> cache = parser.accepts("cache", "cache size (MB)").withRequiredArg().ofType(Integer.class).defaultsTo(100);
OptionSpec<Integer> fdsCache = parser.accepts("blobCache", "cache size (MB)").withRequiredArg().ofType(Integer.class).defaultsTo(32);
OptionSpec<Boolean> withStorage = parser.accepts("storage", "Index storage enabled").withOptionalArg().ofType(Boolean.class);
OptionSpec<File> csvFile = parser.accepts("csvFile", "File to write a CSV version of the benchmark data.").withOptionalArg().ofType(File.class);
OptionSpec help = parser.acceptsAll(asList("h", "?", "help"), "show help").forHelp();
OptionSpec<String> nonOption = parser.nonOptions();
OptionSet options = parser.parse(args);
if (options.has(help)) {
parser.printHelpOn(System.out);
System.exit(0);
}
int cacheSize = cache.value(options);
RepositoryFixture[] allFixtures = new RepositoryFixture[] { new JackrabbitRepositoryFixture(base.value(options), cacheSize), OakRepositoryFixture.getMemoryNS(cacheSize * MB), OakRepositoryFixture.getMongo(host.value(options), port.value(options), dbName.value(options), dropDBAfterTest.value(options), cacheSize * MB), OakRepositoryFixture.getMongoWithDS(host.value(options), port.value(options), dbName.value(options), dropDBAfterTest.value(options), cacheSize * MB, base.value(options), fdsCache.value(options)), OakRepositoryFixture.getMongoNS(host.value(options), port.value(options), dbName.value(options), dropDBAfterTest.value(options), cacheSize * MB), OakRepositoryFixture.getSegmentTar(base.value(options), 256, cacheSize, mmap.value(options)), OakRepositoryFixture.getSegmentTarWithBlobStore(base.value(options), 256, cacheSize, mmap.value(options), fdsCache.value(options)), OakRepositoryFixture.getRDB(rdbjdbcuri.value(options), rdbjdbcuser.value(options), rdbjdbcpasswd.value(options), rdbjdbctableprefix.value(options), dropDBAfterTest.value(options), cacheSize * MB), OakRepositoryFixture.getRDBWithDS(rdbjdbcuri.value(options), rdbjdbcuser.value(options), rdbjdbcpasswd.value(options), rdbjdbctableprefix.value(options), dropDBAfterTest.value(options), cacheSize * MB, base.value(options), fdsCache.value(options)) };
ScalabilitySuite[] allSuites = new ScalabilitySuite[] { new ScalabilityBlobSearchSuite(withStorage.value(options)).addBenchmarks(new FullTextSearcher(), new NodeTypeSearcher(), new FormatSearcher(), new FacetSearcher(), new LastModifiedSearcher(Date.LAST_2_HRS), new LastModifiedSearcher(Date.LAST_24_HRS), new LastModifiedSearcher(Date.LAST_7_DAYS), new LastModifiedSearcher(Date.LAST_MONTH), new LastModifiedSearcher(Date.LAST_YEAR), new OrderByDate()), new ScalabilityNodeSuite(withStorage.value(options)).addBenchmarks(new OrderBySearcher(), new SplitOrderBySearcher(), new OrderByOffsetPageSearcher(), new SplitOrderByOffsetPageSearcher(), new OrderByKeysetPageSearcher(), new SplitOrderByKeysetPageSearcher(), new MultiFilterOrderBySearcher(), new MultiFilterSplitOrderBySearcher(), new MultiFilterOrderByOffsetPageSearcher(), new MultiFilterSplitOrderByOffsetPageSearcher(), new MultiFilterOrderByKeysetPageSearcher(), new MultiFilterSplitOrderByKeysetPageSearcher(), new ConcurrentReader(), new ConcurrentWriter()), new ScalabilityNodeRelationshipSuite(withStorage.value(options)).addBenchmarks(new AggregateNodeSearcher()) };
Set<String> argset = Sets.newHashSet(nonOption.values(options));
List<RepositoryFixture> fixtures = Lists.newArrayList();
for (RepositoryFixture fixture : allFixtures) {
if (argset.remove(fixture.toString())) {
fixtures.add(fixture);
}
}
Map<String, List<String>> argmap = Maps.newHashMap();
// Split the args to get suites and benchmarks (i.e. suite:benchmark1,benchmark2)
for (String arg : argset) {
List<String> tokens = Splitter.on(":").limit(2).splitToList(arg);
if (tokens.size() > 1) {
argmap.put(tokens.get(0), Splitter.on(",").trimResults().splitToList(tokens.get(1)));
} else {
argmap.put(tokens.get(0), null);
}
argset.remove(arg);
}
if (argmap.isEmpty()) {
System.err.println("Warning: no scalability suites specified, " + "supported are: " + Arrays.asList(allSuites));
}
List<ScalabilitySuite> suites = Lists.newArrayList();
for (ScalabilitySuite suite : allSuites) {
if (argmap.containsKey(suite.toString())) {
List<String> benchmarks = argmap.get(suite.toString());
// Only keep requested benchmarks
if (benchmarks != null) {
Iterator<String> iter = suite.getBenchmarks().keySet().iterator();
for (; iter.hasNext(); ) {
String availBenchmark = iter.next();
if (!benchmarks.contains(availBenchmark)) {
iter.remove();
}
}
}
suites.add(suite);
argmap.remove(suite.toString());
}
}
if (argmap.isEmpty()) {
PrintStream out = null;
if (options.has(csvFile)) {
out = new PrintStream(FileUtils.openOutputStream(csvFile.value(options), true), false, Charsets.UTF_8.name());
}
for (ScalabilitySuite suite : suites) {
if (suite instanceof CSVResultGenerator) {
((CSVResultGenerator) suite).setPrintStream(out);
}
suite.run(fixtures);
}
if (out != null) {
out.close();
}
} else {
System.err.println("Unknown arguments: " + argset);
}
}
use of java.util.Arrays.asList in project lucene-solr by apache.
the class TestReqParamsAPI method testReqParams.
private void testReqParams() throws Exception {
CloudSolrClient cloudClient = cluster.getSolrClient();
DocCollection coll = cloudClient.getZkStateReader().getClusterState().getCollection(COLL_NAME);
List<String> urls = new ArrayList<>();
for (Slice slice : coll.getSlices()) {
for (Replica replica : slice.getReplicas()) urls.add("" + replica.get(ZkStateReader.BASE_URL_PROP) + "/" + replica.get(ZkStateReader.CORE_NAME_PROP));
}
RestTestHarness writeHarness = restTestHarnesses.get(random().nextInt(restTestHarnesses.size()));
String payload = "{\n" + "'create-requesthandler' : { 'name' : '/dump0', 'class': 'org.apache.solr.handler.DumpRequestHandler' }\n" + "}";
TestSolrConfigHandler.runConfigCommand(writeHarness, "/config?wt=json", payload);
payload = "{\n" + "'create-requesthandler' : { 'name' : '/dump1', 'class': 'org.apache.solr.handler.DumpRequestHandler', 'useParams':'x' }\n" + "}";
TestSolrConfigHandler.runConfigCommand(writeHarness, "/config?wt=json", payload);
AbstractFullDistribZkTestBase.waitForRecoveriesToFinish(COLL_NAME, cloudClient.getZkStateReader(), false, true, 90);
payload = " {\n" + " 'set' : {'x': {" + " 'a':'A val',\n" + " 'b': 'B val'}\n" + " }\n" + " }";
TestSolrConfigHandler.runConfigCommand(writeHarness, "/config/params?wt=json", payload);
Map result = TestSolrConfigHandler.testForResponseElement(null, urls.get(random().nextInt(urls.size())), "/config/params?wt=json", cloudClient, asList("response", "params", "x", "a"), "A val", 10);
compareValues(result, "B val", asList("response", "params", "x", "b"));
TestSolrConfigHandler.testForResponseElement(null, urls.get(random().nextInt(urls.size())), "/config/overlay?wt=json", cloudClient, asList("overlay", "requestHandler", "/dump0", "name"), "/dump0", 10);
result = TestSolrConfigHandler.testForResponseElement(null, urls.get(random().nextInt(urls.size())), "/dump0?wt=json&useParams=x", cloudClient, asList("params", "a"), "A val", 5);
compareValues(result, "", asList("params", RequestParams.USEPARAM));
TestSolrConfigHandler.testForResponseElement(null, urls.get(random().nextInt(urls.size())), "/dump0?wt=json&useParams=x&a=fomrequest", cloudClient, asList("params", "a"), "fomrequest", 5);
result = TestSolrConfigHandler.testForResponseElement(null, urls.get(random().nextInt(urls.size())), "/config/overlay?wt=json", cloudClient, asList("overlay", "requestHandler", "/dump1", "name"), "/dump1", 10);
result = TestSolrConfigHandler.testForResponseElement(null, urls.get(random().nextInt(urls.size())), "/dump1?wt=json", cloudClient, asList("params", "a"), "A val", 5);
writeHarness = restTestHarnesses.get(random().nextInt(restTestHarnesses.size()));
payload = " {\n" + " 'set' : {'y':{\n" + " 'c':'CY val',\n" + " 'b': 'BY val', " + " 'i': 20, " + " 'd': ['val 1', 'val 2']}\n" + " }\n" + " }";
TestSolrConfigHandler.runConfigCommand(writeHarness, "/config/params?wt=json", payload);
result = TestSolrConfigHandler.testForResponseElement(null, urls.get(random().nextInt(urls.size())), "/config/params?wt=json", cloudClient, asList("response", "params", "y", "c"), "CY val", 10);
compareValues(result, 20l, asList("response", "params", "y", "i"));
compareValues(result, null, asList("response", "params", "y", "a"));
result = TestSolrConfigHandler.testForResponseElement(null, urls.get(random().nextInt(urls.size())), "/dump1?wt=json&useParams=y", cloudClient, asList("params", "c"), "CY val", 5);
compareValues(result, "BY val", asList("params", "b"));
compareValues(result, "A val", asList("params", "a"));
compareValues(result, Arrays.asList("val 1", "val 2"), asList("params", "d"));
compareValues(result, "20", asList("params", "i"));
result = TestSolrConfigHandler.testForResponseElement(null, urls.get(random().nextInt(urls.size())), "/config/requestHandler?componentName=/dump1&expandParams=true&wt=json&useParams=y&c=CC", cloudClient, asList("config", "requestHandler", "/dump1", "_useParamsExpanded_", "x", "a"), "A val", 5);
compareValues(result, "B val", asList("config", "requestHandler", "/dump1", "_useParamsExpanded_", "x", "b"));
compareValues(result, "CY val", asList("config", "requestHandler", "/dump1", "_useParamsExpanded_", "y", "c"));
compareValues(result, "BY val", asList("config", "requestHandler", "/dump1", "_useParamsExpanded_", "y", "b"));
compareValues(result, "A val", asList("config", "requestHandler", "/dump1", "_effectiveParams_", "a"));
compareValues(result, "BY val", asList("config", "requestHandler", "/dump1", "_effectiveParams_", "b"));
compareValues(result, "CC", asList("config", "requestHandler", "/dump1", "_effectiveParams_", "c"));
payload = " {\n" + " 'update' : {'y': {\n" + " 'c':'CY val modified',\n" + " 'e':'EY val',\n" + " 'b': 'BY val'" + "}\n" + " }\n" + " }";
TestSolrConfigHandler.runConfigCommand(writeHarness, "/config/params?wt=json", payload);
result = TestSolrConfigHandler.testForResponseElement(null, urls.get(random().nextInt(urls.size())), "/config/params?wt=json", cloudClient, asList("response", "params", "y", "c"), "CY val modified", 10);
compareValues(result, "EY val", asList("response", "params", "y", "e"));
payload = " {\n" + " 'set' : {'y': {\n" + " 'p':'P val',\n" + " 'q': 'Q val'" + "}\n" + " }\n" + " }";
TestSolrConfigHandler.runConfigCommand(writeHarness, "/config/params?wt=json", payload);
result = TestSolrConfigHandler.testForResponseElement(null, urls.get(random().nextInt(urls.size())), "/config/params?wt=json", cloudClient, asList("response", "params", "y", "p"), "P val", 10);
compareValues(result, null, asList("response", "params", "y", "c"));
compareValues(result, 2l, asList("response", "params", "y", "", "v"));
compareValues(result, 0l, asList("response", "params", "x", "", "v"));
payload = "{update :{x : {_appends_ :{ add : 'first' }, _invariants_ : {fixed: f }}}}";
TestSolrConfigHandler.runConfigCommand(writeHarness, "/config/params?wt=json", payload);
result = TestSolrConfigHandler.testForResponseElement(null, urls.get(random().nextInt(urls.size())), "/config/params?wt=json", cloudClient, asList("response", "params", "x", "_appends_", "add"), "first", 10);
compareValues(result, "f", asList("response", "params", "x", "_invariants_", "fixed"));
result = TestSolrConfigHandler.testForResponseElement(null, urls.get(random().nextInt(urls.size())), "/dump1?wt=json&fixed=changeit&add=second", cloudClient, asList("params", "fixed"), "f", 5);
compareValues(result, new Predicate() {
@Override
public boolean test(Object o) {
List l = (List) o;
return l.contains("first") && l.contains("second");
}
}, asList("params", "add"));
payload = " {'delete' : 'y'}";
TestSolrConfigHandler.runConfigCommand(writeHarness, "/config/params?wt=json", payload);
TestSolrConfigHandler.testForResponseElement(null, urls.get(random().nextInt(urls.size())), "/config/params?wt=json", cloudClient, asList("response", "params", "y", "p"), null, 10);
}
Aggregations