DriveConfigTest.cpp 5.06 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/******************************************************************************
 *
 * This file is part of the Castor project.
 * See http://castor.web.cern.ch/castor
 *
 * Copyright (C) 2003  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 2
 * 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, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 * 
 *
 * @author Castor Dev team, castor-dev@cern.ch
 *****************************************************************************/

#include "castor/tape/tapeserver/daemon/DriveConfig.hpp"

#include <gtest/gtest.h>

namespace unitTests {

class castor_tape_tapeserver_daemon_DriveConfigTest : public ::testing::Test {
protected:

  virtual void SetUp() {
  }

  virtual void TearDown() {
  }
};

TEST_F(castor_tape_tapeserver_daemon_DriveConfigTest, manual_drive_slot) {
  using namespace castor::tape::tapeserver::daemon;

  DriveConfig config(
    "unit",
    "dgn",
    "devFilename",
    "manual");

  ASSERT_EQ("unit", config.getUnitName());
50
  ASSERT_EQ("dgn", config.getLogicalLibrary());
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
  ASSERT_EQ("devFilename", config.getDevFilename());
  ASSERT_NO_THROW(config.getLibrarySlot());
  {
    const castor::mediachanger::LibrarySlot &librarySlot =
      config.getLibrarySlot();
    ASSERT_EQ("manual", librarySlot.str());
    ASSERT_EQ(castor::mediachanger::TAPE_LIBRARY_TYPE_MANUAL,
      librarySlot.getLibraryType());
  }
}

TEST_F(castor_tape_tapeserver_daemon_DriveConfigTest, copy_constructor) {
  using namespace castor::tape::tapeserver::daemon;

  DriveConfig config1(
    "unit1",
    "dgn1",
    "devFilename1",
    "manual1");
  ASSERT_EQ("unit1", config1.getUnitName());
71
  ASSERT_EQ("dgn1", config1.getLogicalLibrary());
72
73
74
75
76
77
78
79
80
81
82
83
  ASSERT_EQ("devFilename1", config1.getDevFilename());
  ASSERT_NO_THROW(config1.getLibrarySlot());
  {
    const castor::mediachanger::LibrarySlot &librarySlot1 =
      config1.getLibrarySlot();
    ASSERT_EQ("manual1", librarySlot1.str());
    ASSERT_EQ(castor::mediachanger::TAPE_LIBRARY_TYPE_MANUAL,
      librarySlot1.getLibraryType());
  }

  DriveConfig config2(config1);
  ASSERT_EQ("unit1", config2.getUnitName());
84
  ASSERT_EQ("dgn1", config2.getLogicalLibrary());
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
  ASSERT_EQ("devFilename1", config2.getDevFilename());
  ASSERT_NO_THROW(config2.getLibrarySlot());
  {
    const castor::mediachanger::LibrarySlot &librarySlot2 =
      config2.getLibrarySlot();
    ASSERT_EQ("manual1", librarySlot2.str());
    ASSERT_EQ(castor::mediachanger::TAPE_LIBRARY_TYPE_MANUAL,
      librarySlot2.getLibraryType());
  }
}

TEST_F(castor_tape_tapeserver_daemon_DriveConfigTest, assignment) {
  using namespace castor::tape::tapeserver::daemon;

  DriveConfig config1(
    "unit1",
    "dgn1",
    "devFilename1",
    "manual1");
  ASSERT_EQ("unit1", config1.getUnitName());
105
  ASSERT_EQ("dgn1", config1.getLogicalLibrary());
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
  ASSERT_EQ("devFilename1", config1.getDevFilename());
  ASSERT_NO_THROW(config1.getLibrarySlot());
  {
    const castor::mediachanger::LibrarySlot &librarySlot1 =
      config1.getLibrarySlot();
    ASSERT_EQ("manual1", librarySlot1.str());
    ASSERT_EQ(castor::mediachanger::TAPE_LIBRARY_TYPE_MANUAL,
      librarySlot1.getLibraryType());
  }

  DriveConfig config2(
    "unit2",
    "dgn2",
    "devFilename2",
    "manual2");
  ASSERT_EQ("unit2", config2.getUnitName());
122
  ASSERT_EQ("dgn2", config2.getLogicalLibrary());
123
124
125
126
127
128
129
130
131
132
133
134
135
  ASSERT_EQ("devFilename2", config2.getDevFilename());
  ASSERT_NO_THROW(config2.getLibrarySlot());
  {
    const castor::mediachanger::LibrarySlot &librarySlot2 =
      config2.getLibrarySlot();
    ASSERT_EQ("manual2", librarySlot2.str());
    ASSERT_EQ(castor::mediachanger::TAPE_LIBRARY_TYPE_MANUAL,
      librarySlot2.getLibraryType());
  }

  config1 = config2;

  ASSERT_EQ("unit2", config1.getUnitName());
136
  ASSERT_EQ("dgn2", config1.getLogicalLibrary());
137
138
139
140
141
142
143
144
145
146
147
  ASSERT_EQ("devFilename2", config1.getDevFilename());
  ASSERT_NO_THROW(config1.getLibrarySlot());
  {
    const castor::mediachanger::LibrarySlot &librarySlot1 =
      config2.getLibrarySlot();
    ASSERT_EQ("manual2", librarySlot1.str());
    ASSERT_EQ(castor::mediachanger::TAPE_LIBRARY_TYPE_MANUAL,
      librarySlot1.getLibraryType());
  }

  ASSERT_EQ("unit2", config2.getUnitName());
148
  ASSERT_EQ("dgn2", config2.getLogicalLibrary());
149
150
151
152
153
154
155
156
157
158
159
160
  ASSERT_EQ("devFilename2", config2.getDevFilename());
  ASSERT_NO_THROW(config2.getLibrarySlot());
  {
    const castor::mediachanger::LibrarySlot &librarySlot2 =
      config2.getLibrarySlot();
    ASSERT_EQ("manual2", librarySlot2.str());
    ASSERT_EQ(castor::mediachanger::TAPE_LIBRARY_TYPE_MANUAL,
      librarySlot2.getLibraryType());
  }
}

} // namespace unitTests