1   /**
2    * Copyright 2009 The Apache Software Foundation
3    *
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *     http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS,
16   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17   * See the License for the specific language governing permissions and
18   * limitations under the License.
19   */
20  
21  package org.apache.hadoop.hbase.client;
22  
23  import java.io.IOException;
24  import java.util.ArrayList;
25  import java.util.List;
26  
27  import org.apache.commons.logging.Log;
28  import org.apache.commons.logging.LogFactory;
29  import org.apache.hadoop.hbase.HBaseTestingUtility;
30  import org.junit.AfterClass;
31  import org.junit.BeforeClass;
32  import org.junit.Test;
33  
34  import org.jruby.embed.ScriptingContainer;
35  import org.jruby.embed.PathType;
36  
37  /**
38   *
39   * @author scoundrel
40   */
41  public class TestShell {
42    final Log LOG = LogFactory.getLog(getClass());
43    private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
44    private final static ScriptingContainer jruby = new ScriptingContainer();
45  
46    @BeforeClass
47    public static void setUpBeforeClass() throws Exception {
48      // Start mini cluster
49      TEST_UTIL.getConfiguration().setInt("hbase.regionserver.msginterval", 100);
50      TEST_UTIL.getConfiguration().setInt("hbase.client.pause", 250);
51      TEST_UTIL.getConfiguration().setInt("hbase.client.retries.number", 6);
52      TEST_UTIL.startMiniCluster();
53  
54      // Configure jruby runtime
55      List<String> loadPaths = new ArrayList();
56      loadPaths.add("src/main/ruby");
57      loadPaths.add("src/test/ruby");
58      jruby.getProvider().setLoadPaths(loadPaths);
59      jruby.put("$TEST_CLUSTER", TEST_UTIL);
60    }
61  
62    @AfterClass
63    public static void tearDownAfterClass() throws Exception {
64      TEST_UTIL.shutdownMiniCluster();
65    }
66  
67    @Test
68    public void testRunShellTests() throws IOException {
69      // Start all ruby tests
70      jruby.runScriptlet(PathType.ABSOLUTE, "src/test/ruby/tests_runner.rb");
71    }
72  }