2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
22 #include "gtest/gtest.h"
23 #include "async/hbase_mutations.h"
24 #include "async/hbase_client.h"
27 pthread_mutex_t mutex
;
31 TEST(ClientTest
, EasyTest
) {
35 void mutate_cb(int32_t status
,
36 hb_client_t client
, hb_mutation_t mutation
,
37 hb_result_t result
, void * extra
) {
41 EXPECT_TRUE(client
!= NULL
);
42 EXPECT_TRUE(mutation
!= NULL
);
44 pthread_mutex_lock(&mutex
);
46 pthread_cond_signal(&cv
);
47 pthread_mutex_unlock(&mutex
);
51 pthread_mutex_lock(&mutex
);
53 pthread_cond_wait(&cv
, &mutex
);
55 pthread_mutex_unlock(&mutex
);
58 TEST(MutationTest
, TestPut
) {
60 hb_byte_t row
[] = "ROW";
62 hb_byte_t qual
[] = "QUAL";
63 hb_byte_t data
[] = "Z";
65 hb_client_t client
= NULL
;
70 cell
.family_length
= 1;
76 cell
.value_length
= 1;
80 status
= hb_client_create(&client
, NULL
);
84 hb_mutation_set_table((hb_mutation_t
) put
, tn
, 2);
85 hb_mutation_set_row((hb_mutation_t
) put
, row
, 3);
86 hb_put_add_cell(put
, &cell
);
88 pthread_cond_init(&cv
, NULL
);
89 pthread_mutex_init(&mutex
, NULL
);
91 status
= hb_mutation_send(client
, (hb_mutation_t
) put
, &mutate_cb
, NULL
);
94 // Now wait a while for things to send.
96 EXPECT_EQ(true, sent
);
98 hb_mutation_destroy((hb_mutation_t
*) put
);
99 hb_client_destroy(client
, NULL
, NULL
);
101 EXPECT_EQ(0, status
);