ConnPoolTest.cpp 1.87 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
 * The CERN Tape Archive (CTA) project
 * Copyright (C) 2015  CERN
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "common/exception/Exception.hpp"
20
#include "rdbms/ConnPool.hpp"
21
#include "rdbms/Login.hpp"
22
23
24
25
26

#include <gtest/gtest.h>

namespace unitTests {

27
class cta_rdbms_ConnPoolTest : public ::testing::Test {
28
29
30
31
32
33
34
35
36
protected:

  virtual void SetUp() {
  }

  virtual void TearDown() {
  }
};

37
TEST_F(cta_rdbms_ConnPoolTest, getPooledConn) {
38
39
  using namespace cta::rdbms;

40
  const Login login(Login::DBTYPE_SQLITE, "", "", "file::memory:?cache=shared", "", 0);
41
  const uint64_t nbConns = 2;
42
  ConnPool pool(login, nbConns);
43

44
  Conn conn = pool.getConn();
45
46
47
48
49
}

TEST_F(cta_rdbms_ConnPoolTest, assignment) {
  using namespace cta::rdbms;

50
  const Login login(Login::DBTYPE_SQLITE, "", "", "file::memory:?cache=shared", "", 0);
51
  const uint64_t nbConns = 2;
52
  ConnPool pool(login, nbConns);
53

54
  Conn conn = pool.getConn();
55

56
  Conn conn2(nullptr, nullptr);
57

58
  conn2 = pool.getConn();
59
60
}

61
62
63
TEST_F(cta_rdbms_ConnPoolTest, moveConstructor) {
  using namespace cta::rdbms;

64
  const Login login(Login::DBTYPE_SQLITE, "", "", "file::memory:?cache=shared", "", 0);
65
  const uint64_t nbConns = 2;
66
  ConnPool pool(login, nbConns);
67

68
  Conn conn = pool.getConn();
69

70
  Conn conn2(std::move(conn));
71
72
}

73
} // namespace unitTests