RetrieveQueueTest.cpp 1.67 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 <gtest/gtest.h>
20
#include "RetrieveQueue.hpp"
21
#include "BackendVFS.hpp"
22
#include "AgentReference.hpp"
23
24
25

namespace unitTests {
  
26
TEST(ObjectStore, RetrieveQueueBasicAccess) {
27
  cta::objectstore::BackendVFS be;
28
29
  cta::objectstore::AgentReference agentRef("unitTest");
  std::string retrieveQueueAddress = agentRef.nextId("RetrieveQueue");
30
31
  { 
    // Try to create the tape entry
32
    cta::objectstore::RetrieveQueue rq(retrieveQueueAddress, be);
33
    rq.initialize("V12345");
34
    rq.insert();
35
36
37
  }
  {
    // Try to read back and dump the tape
38
39
40
41
42
    cta::objectstore::RetrieveQueue rq(retrieveQueueAddress, be);
    ASSERT_THROW(rq.fetch(), cta::exception::Exception);
    cta::objectstore::ScopedSharedLock lock(rq);
    ASSERT_NO_THROW(rq.fetch());
    rq.dump();
43
44
  }
  // Delete the root entry
45
46
47
48
49
  cta::objectstore::RetrieveQueue rq(retrieveQueueAddress, be);
  cta::objectstore::ScopedExclusiveLock lock(rq);
  rq.fetch();
  rq.removeIfEmpty();
  ASSERT_FALSE(rq.exists());
50
51
}
}