X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=xmltoolingtest%2FMemoryStorageServiceTest.h;h=509ac6d179a96cf0759fa1c740e350118a663797;hb=4a4b8fd387a7c03b4ea3d052104c8ca70ceb4a35;hp=99e2e0e9bb0b3d7090bdd135c294f1c631d25220;hpb=1634821217afa6ee6751d075afdf23a53f9b73c8;p=shibboleth%2Fcpp-xmltooling.git diff --git a/xmltoolingtest/MemoryStorageServiceTest.h b/xmltoolingtest/MemoryStorageServiceTest.h index 99e2e0e..509ac6d 100644 --- a/xmltoolingtest/MemoryStorageServiceTest.h +++ b/xmltoolingtest/MemoryStorageServiceTest.h @@ -1,48 +1,46 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "XMLObjectBaseTestCase.h" - -#include - -class MemoryStorageServiceTest : public CxxTest::TestSuite { -public: - void setUp() { - } - - void tearDown() { - } - - void testMemoryService() { - auto_ptr storage( - XMLToolingConfig::getConfig().StorageServiceManager.newPlugin(MEMORY_STORAGE_SERVICE,NULL) - ); - auto_ptr handle(storage->createHandle()); - - string data; - TSM_ASSERT("Record found in storage.", !storage->readString(handle.get(), "foo1", data)); - storage->createString(handle.get(), "foo1", "bar1", time(NULL) - 300); - storage->createString(handle.get(), "foo2", "bar2", time(NULL)); - TSM_ASSERT("Record not found in storage.", storage->readString(handle.get(), "foo1", data)); - TSM_ASSERT_EQUALS("Record value doesn't match.", data, "bar1"); - TSM_ASSERT("Update failed.", storage->updateString(handle.get(), "foo2", "bar1")); - TSM_ASSERT("Record not found in storage.", storage->readString(handle.get(), "foo2", data)); - TSM_ASSERT_EQUALS("Record value doesn't match.", data, "bar1"); - TSM_ASSERT("Delete failed.", storage->deleteString(handle.get(), "foo2")); - storage->reap(handle.get()); - Thread::sleep(1); - } -}; +/* + * Copyright 2001-2010 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "XMLObjectBaseTestCase.h" + +#include + +class MemoryStorageServiceTest : public CxxTest::TestSuite { +public: + void setUp() { + } + + void tearDown() { + } + + void testMemoryService() { + auto_ptr storage( + XMLToolingConfig::getConfig().StorageServiceManager.newPlugin(MEMORY_STORAGE_SERVICE,nullptr) + ); + + string data; + TSM_ASSERT_EQUALS("Record found in storage.", 0, storage->readString("context", "foo1", &data)); + storage->createString("context", "foo1", "bar1", time(nullptr) + 60); + storage->createString("context", "foo2", "bar2", time(nullptr) + 60); + TSM_ASSERT_EQUALS("Record not found in storage.", 1, storage->readString("context", "foo1", &data)); + TSM_ASSERT_EQUALS("Record value doesn't match.", data, "bar1"); + TSM_ASSERT_EQUALS("Update failed.", 2, storage->updateString("context", "foo2", "bar1", 0, 1)); + TSM_ASSERT_EQUALS("Record not found in storage.", 2, storage->readString("context", "foo2", &data, nullptr, 1)); + TSM_ASSERT_EQUALS("Record value doesn't match.", data, "bar1"); + TSM_ASSERT("Delete failed.", storage->deleteString("context", "foo2")); + storage->reap("context"); + } +};