|
| 1 | +/* |
| 2 | + * Copyright 2014 Twitter inc. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package com.twitter.storehaus.hbase |
| 18 | + |
| 19 | +import com.twitter.storehaus.Store |
| 20 | +import com.twitter.storehaus.testing.generator.NonEmpty |
| 21 | +import com.twitter.util.Await |
| 22 | +import org.scalacheck.{Arbitrary, Gen, Properties} |
| 23 | +import org.scalacheck.Prop._ |
| 24 | + |
| 25 | +/** |
| 26 | + * @author Mansur Ashraf |
| 27 | + * @since 9/8/13 |
| 28 | + */ |
| 29 | +object HBaseStoreProperties extends Properties("HBaseStore") |
| 30 | + with DefaultHBaseCluster[Store[String, String]] { |
| 31 | + |
| 32 | + def putAndGetTest[K: Arbitrary, V: Arbitrary : Equiv]( |
| 33 | + store: Store[K, V], pairs: Gen[List[(K, Option[V])]]) = |
| 34 | + forAll(pairs) { examples => |
| 35 | + examples.forall { |
| 36 | + case (k, v) => |
| 37 | + Await.result(store.put((k, v))) |
| 38 | + val found = Await.result(store.get(k)) |
| 39 | + Equiv[Option[V]].equiv(found, v) |
| 40 | + } |
| 41 | + } |
| 42 | + |
| 43 | + val closeable = |
| 44 | + HBaseStringStore(quorumNames, table, columnFamily, column, createTable, pool, conf, 4) |
| 45 | + property("HBaseStore[String, String]") = |
| 46 | + putAndGetTest(closeable, NonEmpty.Pairing.alphaStrs()) |
| 47 | +} |
0 commit comments