2 * Copyright 2001-2007 Internet2
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "XMLObjectBaseTestCase.h"
19 #include <xmltooling/util/StorageService.h>
21 class MemoryStorageServiceTest : public CxxTest::TestSuite {
29 void testMemoryService() {
30 auto_ptr<StorageService> storage(
31 XMLToolingConfig::getConfig().StorageServiceManager.newPlugin(MEMORY_STORAGE_SERVICE,NULL)
35 TSM_ASSERT_EQUALS("Record found in storage.", 0, storage->readString("context", "foo1", &data));
36 storage->createString("context", "foo1", "bar1", time(NULL) + 60);
37 storage->createString("context", "foo2", "bar2", time(NULL) + 60);
38 TSM_ASSERT_EQUALS("Record not found in storage.", 1, storage->readString("context", "foo1", &data));
39 TSM_ASSERT_EQUALS("Record value doesn't match.", data, "bar1");
40 TSM_ASSERT_EQUALS("Update failed.", 2, storage->updateString("context", "foo2", "bar1", 0, 1));
41 TSM_ASSERT_EQUALS("Record not found in storage.", 2, storage->readString("context", "foo2", &data, NULL, 1));
42 TSM_ASSERT_EQUALS("Record value doesn't match.", data, "bar1");
43 TSM_ASSERT("Delete failed.", storage->deleteString("context", "foo2"));
44 storage->reap("context");