build in an integration test facility for now. probably need to think through a better way here but this will satisfy immediate need of being able to full exercise a command
Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/e14690dd Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/e14690dd Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/e14690dd Branch: refs/heads/blur-384-random-port-cleanup Commit: e14690dd0f0b62d1e0f36dcaca7555e550c62984 Parents: 4e0759d Author: twilliams <[email protected]> Authored: Fri Sep 26 19:53:30 2014 -0400 Committer: twilliams <[email protected]> Committed: Fri Sep 26 19:53:30 2014 -0400 ---------------------------------------------------------------------- blur-command/pom.xml | 7 ++ .../blur/command/IntegrationTestSuite.java | 76 ++++++++++++++++++++ .../blur/command/TermsCommandIntTests.java | 58 +++++++++++++++ 3 files changed, 141 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/e14690dd/blur-command/pom.xml ---------------------------------------------------------------------- diff --git a/blur-command/pom.xml b/blur-command/pom.xml index 7c8417a..3198075 100644 --- a/blur-command/pom.xml +++ b/blur-command/pom.xml @@ -73,6 +73,13 @@ under the License. <version>${junit.version}</version> <scope>test</scope> </dependency> + <dependency> + <groupId>org.apache.blur</groupId> + <artifactId>blur-core</artifactId> + <version>${project.version}</version> + <type>test-jar</type> + <scope>test</scope> + </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/e14690dd/blur-command/src/test/java/org/apache/blur/command/IntegrationTestSuite.java ---------------------------------------------------------------------- diff --git a/blur-command/src/test/java/org/apache/blur/command/IntegrationTestSuite.java b/blur-command/src/test/java/org/apache/blur/command/IntegrationTestSuite.java new file mode 100644 index 0000000..a5a8024 --- /dev/null +++ b/blur-command/src/test/java/org/apache/blur/command/IntegrationTestSuite.java @@ -0,0 +1,76 @@ +package org.apache.blur.command; + +import java.io.IOException; +import java.util.List; + +import org.apache.blur.thirdparty.thrift_0_9_0.TException; +import org.apache.blur.thrift.FacetTests; +import org.apache.blur.thrift.SuiteCluster; +import org.apache.blur.thrift.TermsTests; +import org.apache.blur.thrift.generated.BlurException; +import org.apache.blur.thrift.generated.Blur.Iface; +import org.junit.After; +import org.junit.ClassRule; +import org.junit.rules.ExternalResource; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +@RunWith(Suite.class) [email protected]({ TermsCommandIntTests.class }) +public class IntegrationTestSuite { + @ClassRule + public static ExternalResource testCluster = new ExternalResource() { + + private boolean _managing; + + @Override + protected void after() { + if (_managing) { + try { + SuiteCluster.shutdownMiniCluster(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } + + @Override + protected void before() throws Throwable { + if (!SuiteCluster.isClusterSetup()) { + _managing = true; + try { + SuiteCluster.setupMiniCluster(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } + }; + + @After + public void tearDown() throws BlurException, TException { + Iface client = SuiteCluster.getClient(); + List<String> tableList = client.tableList(); + for (String table : tableList) { + client.disableTable(table); + client.removeTable(table, true); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/e14690dd/blur-command/src/test/java/org/apache/blur/command/TermsCommandIntTests.java ---------------------------------------------------------------------- diff --git a/blur-command/src/test/java/org/apache/blur/command/TermsCommandIntTests.java b/blur-command/src/test/java/org/apache/blur/command/TermsCommandIntTests.java new file mode 100644 index 0000000..5c88d15 --- /dev/null +++ b/blur-command/src/test/java/org/apache/blur/command/TermsCommandIntTests.java @@ -0,0 +1,58 @@ +package org.apache.blur.command; + +import static org.junit.Assert.assertEquals; + +import java.io.IOException; +import java.util.List; + +import org.apache.blur.thirdparty.thrift_0_9_0.TException; +import org.apache.blur.thrift.BaseClusterTest; +import org.apache.blur.thrift.TableGen; +import org.apache.blur.thrift.generated.BlurException; +import org.junit.Test; + +import com.google.common.collect.Lists; + +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +public class TermsCommandIntTests extends BaseClusterTest { + + @Test + public void testTermsList() throws BlurException, TException, IOException, InterruptedException { + final String tableName = "testTermsList"; + TableGen + .define(tableName) + .cols("test", "col1") + .addRows(100, 20, "r1", "rec-###", "value") + .build(getClient()); + + TermsCommand command = new TermsCommand(); + + Args arguments = new Args(); + arguments.set("table", tableName); + BlurObject params = new BlurObject(); + params.put("fieldName", "test.col1"); + arguments.set("params", params); + + BlurArray blurArray = command.run(arguments, getClient()); + List<String> list = Lists.newArrayList("value"); + System.out.println("RESP: " + blurArray.toString()); + assertEquals(list, blurArray.asList()); + } + +}
