2 * Licensed to the University Corporation for Advanced Internet
3 * Development, Inc. (UCAID) under one or more contributor license
4 * agreements. See the NOTICE file distributed with this work for
5 * additional information regarding copyright ownership.
7 * UCAID licenses this file to you under the Apache License,
8 * Version 2.0 (the "License"); you may not use this file except
9 * in compliance with the License. You may obtain a copy of the
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
17 * either express or implied. See the License for the specific
18 * language governing permissions and limitations under the License.
21 #include "XMLObjectBaseTestCase.h"
23 #include <xmltooling/util/StorageService.h>
25 class MemoryStorageServiceTest : public CxxTest::TestSuite {
33 void testMemoryService() {
34 auto_ptr<StorageService> storage(
35 XMLToolingConfig::getConfig().StorageServiceManager.newPlugin(MEMORY_STORAGE_SERVICE,nullptr)
39 TSM_ASSERT_EQUALS("Record found in storage.", 0, storage->readString("context", "foo1", &data));
40 storage->createString("context", "foo1", "bar1", time(nullptr) + 60);
41 storage->createString("context", "foo2", "bar2", time(nullptr) + 60);
42 TSM_ASSERT_EQUALS("Record not found in storage.", 1, storage->readString("context", "foo1", &data));
43 TSM_ASSERT_EQUALS("Record value doesn't match.", data, "bar1");
44 TSM_ASSERT_EQUALS("Update failed.", 2, storage->updateString("context", "foo2", "bar1", 0, 1));
45 TSM_ASSERT_EQUALS("Record not found in storage.", 2, storage->readString("context", "foo2", &data, nullptr, 1));
46 TSM_ASSERT_EQUALS("Record value doesn't match.", data, "bar1");
47 TSM_ASSERT("Delete failed.", storage->deleteString("context", "foo2"));
48 storage->reap("context");