Added a simple test showing how to use Hbase testing utilities

This commit is contained in:
David Greco 2010-09-15 15:03:22 +02:00
parent a13c839096
commit 0541140b04
3 changed files with 36 additions and 11 deletions

View file

@ -6,20 +6,42 @@ import org.scalatest.BeforeAndAfterAll
import org.scalatest.junit.JUnitRunner
import org.junit.runner.RunWith
import org.junit.Test
import org.apache.hadoop.hbase.HBaseClusterTestCase
@Test
class PersistenceTest extends HBaseClusterTestCase with Spec with BeforeAndAfterAll {
import org.apache.hadoop.hbase.HBaseTestingUtility
@RunWith(classOf[JUnitRunner])
class PersistenceSpec extends Spec with BeforeAndAfterAll with ShouldMatchers {
import org.apache.hadoop.hbase.HBaseTestingUtility
val testUtil = new HBaseTestingUtility
override def beforeAll {
super.setUp
testUtil.startMiniCluster
}
@Test
def testPersistence {}
override def afterAll {
super.tearDown
testUtil.shutdownMiniCluster
}
describe("simple hbase persistence test") {
it("should create a table") {
import org.apache.hadoop.hbase.util.Bytes
import org.apache.hadoop.hbase.HTableDescriptor
import org.apache.hadoop.hbase.HColumnDescriptor
import org.apache.hadoop.hbase.client.HBaseAdmin
import org.apache.hadoop.hbase.client.HTable
val descriptor = new HTableDescriptor(Bytes.toBytes("ATable"))
descriptor.addFamily(new HColumnDescriptor(Bytes.toBytes("Family1")))
descriptor.addFamily(new HColumnDescriptor(Bytes.toBytes("Family2")))
val admin = new HBaseAdmin(testUtil.getConfiguration)
admin.createTable(descriptor)
val table = new HTable(testUtil.getConfiguration, Bytes.toBytes("ATable"))
table should not equal(null)
}
}
}

View file

@ -226,6 +226,8 @@ class AkkaParentProject(info: ProjectInfo) extends DefaultProject(info) {
lazy val scalatest = "org.scalatest" % "scalatest" % SCALATEST_VERSION % "test"
lazy val hadoop_test = "org.apache.hadoop" % "hadoop-test" % "0.20.2" % "test"
lazy val hbase_test = "org.apache.hbase" % "hbase-test" % "0.20.6" % "test"
lazy val log4j = "log4j" % "log4j" % "1.2.15" % "test"
lazy val jett_mortbay = "org.mortbay.jetty" % "jetty" % "6.1.14" % "test"
}
// -------------------------------------------------------------------------------------------------------------------
@ -529,12 +531,13 @@ class AkkaParentProject(info: ProjectInfo) extends DefaultProject(info) {
class AkkaHbaseProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) {
val zookeeper = Dependencies.zookeeper
val hadoop_core = Dependencies.hadoop_core
val hbase_core = Dependencies.hbase_core
// testing
val hadoop_test = Dependencies.hadoop_test
val hbase_test = Dependencies.hbase_test
override def testOptions = TestFilter((name: String) => name.endsWith("Test")) :: Nil
val jetty = Dependencies.jett_mortbay
val log4j = Dependencies.log4j
}
// -------------------------------------------------------------------------------------------------------------------