More unit tests.
authorScott Cantor <cantor.2@osu.edu>
Wed, 10 May 2006 18:04:21 +0000 (18:04 +0000)
committerScott Cantor <cantor.2@osu.edu>
Wed, 10 May 2006 18:04:21 +0000 (18:04 +0000)
samltest/.gitignore
samltest/data/saml1/core/impl/AdviceWithChildren.xml
samltest/internal.h
samltest/saml1/core/impl/.gitignore [new file with mode: 0644]
samltest/saml1/core/impl/ActionTest.h
samltest/saml1/core/impl/AdviceTest.h [new file with mode: 0644]
samltest/saml1/core/impl/AssertionIDReferenceTest.h [new file with mode: 0644]
samltest/samltest.vcproj

index 994c81d..39a97ca 100644 (file)
@@ -1,2 +1,3 @@
 /Debug
 /*.user
+/*.cpp
index eeab16c..a341c10 100644 (file)
Binary files a/samltest/data/saml1/core/impl/AdviceWithChildren.xml and b/samltest/data/saml1/core/impl/AdviceWithChildren.xml differ
index 6707e1f..251b3c1 100644 (file)
@@ -76,6 +76,7 @@ protected:
 
     void assertEquals(DOMDocument* expectedDOM, XMLObject* xmlObject) {
         assertEquals("Marshalled DOM was not the same as the expected DOM", expectedDOM, xmlObject);
+        delete xmlObject;
     }
 
 public:
diff --git a/samltest/saml1/core/impl/.gitignore b/samltest/saml1/core/impl/.gitignore
new file mode 100644 (file)
index 0000000..e16b497
--- /dev/null
@@ -0,0 +1 @@
+/*.cpp
index 26e4580..65c5fc1 100644 (file)
@@ -22,7 +22,6 @@ using namespace opensaml::saml1;
 class ActionTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {\r
     XMLCh* expectedContents;\r
     XMLCh* expectedNamespace;\r
-    QName* qname;\r
 \r
 public:\r
     void setUp() {\r
@@ -30,12 +29,10 @@ public:
         singleElementOptionalAttributesFile  = data_path + "saml1/core/impl/singleActionAttributes.xml";    \r
         expectedContents = XMLString::transcode("Action Contents");\r
         expectedNamespace = XMLString::transcode("namespace");\r
-        qname = new QName(SAMLConstants::SAML1_NS, Action::LOCAL_NAME, SAMLConstants::SAML1_PREFIX);\r
         SAMLObjectBaseTestCase::setUp();\r
     }\r
     \r
     void tearDown() {\r
-        delete qname;\r
         XMLString::release(&expectedContents);\r
         XMLString::release(&expectedNamespace);\r
         SAMLObjectBaseTestCase::tearDown();\r
@@ -57,15 +54,14 @@ public:
     }\r
 \r
     void testSingleElementMarshall() {\r
-        auto_ptr<Action> action(ActionBuilder::buildAction());\r
-        assertEquals(expectedDOM, action.get());\r
+        assertEquals(expectedDOM, ActionBuilder::buildAction());\r
     }\r
 \r
     void testSingleElementOptionalAttributesMarshall() {\r
-        auto_ptr<Action> action(ActionBuilder::buildAction());\r
+        Action* action=ActionBuilder::buildAction();\r
         action->setNamespace(expectedNamespace);\r
         action->setValue(expectedContents);\r
-        assertEquals(expectedOptionalAttributesDOM, action.get());\r
+        assertEquals(expectedOptionalAttributesDOM, action);\r
     }\r
 \r
 };\r
diff --git a/samltest/saml1/core/impl/AdviceTest.h b/samltest/saml1/core/impl/AdviceTest.h
new file mode 100644 (file)
index 0000000..50d5eed
--- /dev/null
@@ -0,0 +1,73 @@
+/*\r
+ *  Copyright 2001-2006 Internet2\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#include "internal.h"\r
+#include <saml/saml1/core/Assertions.h>\r
+\r
+using namespace opensaml::saml1;\r
+\r
+class AdviceTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {\r
+    XMLCh* AssertionID;\r
+    XMLCh* IssueInstant;\r
+\r
+public:\r
+    void setUp() {\r
+        AssertionID=XMLString::transcode("_123456789");\r
+        IssueInstant=XMLString::transcode("1971-03-19T13:23:00Z");\r
+        singleElementFile = data_path + "saml1/core/impl/singleAdvice.xml";\r
+        childElementsFile  = data_path + "saml1/core/impl/AdviceWithChildren.xml";    \r
+        SAMLObjectBaseTestCase::setUp();\r
+    }\r
+    \r
+    void tearDown() {\r
+        XMLString::release(&AssertionID);\r
+        XMLString::release(&IssueInstant);\r
+        SAMLObjectBaseTestCase::tearDown();\r
+    }\r
+\r
+    void testSingleElementUnmarshall() {\r
+        auto_ptr<XMLObject> xo(unmarshallElement(singleElementFile));\r
+        Advice* advice = dynamic_cast<Advice*>(xo.get());\r
+        TS_ASSERT(advice!=NULL);\r
+        TSM_ASSERT_EQUALS("Number of child AssertIDReference elements", 0, advice->getAssertionIDReferences().size());\r
+        TSM_ASSERT_EQUALS("Number of child Assertion elements", 0, advice->getAssertions().size());\r
+    }\r
+\r
+    void testChildElementsUnmarshall() {\r
+        auto_ptr<XMLObject> xo(unmarshallElement(childElementsFile));\r
+        Advice* advice = dynamic_cast<Advice*>(xo.get());\r
+        TSM_ASSERT_EQUALS("Number of child AssertIDReference elements", 2, advice->getAssertionIDReferences().size());\r
+        TSM_ASSERT_EQUALS("Number of child Assertion elements", 1, advice->getAssertions().size());\r
+    }\r
+\r
+    void testSingleElementMarshall() {\r
+        assertEquals(expectedDOM, AdviceBuilder::buildAdvice());\r
+    }\r
+\r
+    void testChildElementsMarshall() {\r
+        Advice* advice=AdviceBuilder::buildAdvice();\r
+        \r
+        advice->getAssertionIDReferences().push_back(AssertionIDReferenceBuilder::buildAssertionIDReference());\r
+        Assertion* assertion=AssertionBuilder::buildAssertion();\r
+        assertion->setAssertionID(AssertionID);\r
+        assertion->setIssueInstant(IssueInstant);\r
+        advice->getAssertions().push_back(assertion);\r
+        advice->getAssertionIDReferences().push_back(AssertionIDReferenceBuilder::buildAssertionIDReference());\r
+\r
+        assertEquals(expectedChildElementsDOM, advice);\r
+    }\r
+\r
+};\r
diff --git a/samltest/saml1/core/impl/AssertionIDReferenceTest.h b/samltest/saml1/core/impl/AssertionIDReferenceTest.h
new file mode 100644 (file)
index 0000000..e7ca8c5
--- /dev/null
@@ -0,0 +1,61 @@
+/*\r
+ *  Copyright 2001-2006 Internet2\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#include "internal.h"\r
+#include <saml/saml1/core/Assertions.h>\r
+\r
+using namespace opensaml::saml1;\r
+\r
+class AssertionIDReferenceTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {\r
+    XMLCh* expectedNCName;\r
+\r
+public:\r
+    void setUp() {\r
+        singleElementFile = data_path + "saml1/core/impl/singleAssertionIDReference.xml";\r
+        singleElementOptionalAttributesFile  = data_path + "saml1/core/impl/singleAssertionIDReferenceContents.xml";    \r
+        expectedNCName = XMLString::transcode("NibbleAHappyWarthog");\r
+        SAMLObjectBaseTestCase::setUp();\r
+    }\r
+    \r
+    void tearDown() {\r
+        XMLString::release(&expectedNCName);\r
+        SAMLObjectBaseTestCase::tearDown();\r
+    }\r
+\r
+    void testSingleElementUnmarshall() {\r
+        auto_ptr<XMLObject> xo(unmarshallElement(singleElementFile));\r
+        AssertionIDReference* assertionIDReference = dynamic_cast<AssertionIDReference*>(xo.get());\r
+        TS_ASSERT(assertionIDReference!=NULL);\r
+        TSM_ASSERT("NCName present", assertionIDReference->getReference()==NULL);\r
+    }\r
+\r
+    void testSingleElementOptionalAttributesUnmarshall() {\r
+        auto_ptr<XMLObject> xo(unmarshallElement(singleElementOptionalAttributesFile));\r
+        AssertionIDReference* assertionIDReference = dynamic_cast<AssertionIDReference*>(xo.get());\r
+        TSM_ASSERT_SAME_DATA("NCName ", expectedNCName, assertionIDReference->getReference(), XMLString::stringLen(expectedNCName));\r
+    }\r
+\r
+    void testSingleElementMarshall() {\r
+        assertEquals(expectedDOM, AssertionIDReferenceBuilder::buildAssertionIDReference());\r
+    }\r
+\r
+    void testSingleElementOptionalAttributesMarshall() {\r
+        AssertionIDReference* assertionIDReference=AssertionIDReferenceBuilder::buildAssertionIDReference();\r
+        assertionIDReference->setReference(expectedNCName);\r
+        assertEquals(expectedOptionalAttributesDOM, assertionIDReference);\r
+    }\r
+\r
+};\r
index bca3280..7e39b7f 100644 (file)
                                                        RelativePath=".\saml1\core\impl\ActionTest.cpp"\r
                                                        >\r
                                                </File>\r
+                                               <File\r
+                                                       RelativePath=".\saml1\core\impl\AdviceTest.cpp"\r
+                                                       >\r
+                                               </File>\r
+                                               <File\r
+                                                       RelativePath=".\saml1\core\impl\AssertionIDReferenceTest.cpp"\r
+                                                       >\r
+                                               </File>\r
                                        </Filter>\r
                                </Filter>\r
                        </Filter>\r
                                                                />\r
                                                        </FileConfiguration>\r
                                                </File>\r
+                                               <File\r
+                                                       RelativePath=".\saml1\core\impl\AdviceTest.h"\r
+                                                       >\r
+                                                       <FileConfiguration\r
+                                                               Name="Debug|Win32"\r
+                                                               >\r
+                                                               <Tool\r
+                                                                       Name="VCCustomBuildTool"\r
+                                                                       CommandLine="\perl\bin\perl.exe -w \cxxtest\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o &quot;$(InputDir)$(InputName)&quot;.cpp &quot;$(InputPath)&quot;"\r
+                                                                       Outputs="&quot;$(InputDir)$(InputName)&quot;.cpp"\r
+                                                               />\r
+                                                       </FileConfiguration>\r
+                                                       <FileConfiguration\r
+                                                               Name="Release|Win32"\r
+                                                               >\r
+                                                               <Tool\r
+                                                                       Name="VCCustomBuildTool"\r
+                                                                       CommandLine="\perl\bin\perl.exe -w \cxxtest\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o &quot;$(InputDir)$(InputName)&quot;.cpp &quot;$(InputPath)&quot;"\r
+                                                                       Outputs="&quot;$(InputDir)$(InputName)&quot;.cpp"\r
+                                                               />\r
+                                                       </FileConfiguration>\r
+                                               </File>\r
+                                               <File\r
+                                                       RelativePath=".\saml1\core\impl\AssertionIDReferenceTest.h"\r
+                                                       >\r
+                                                       <FileConfiguration\r
+                                                               Name="Debug|Win32"\r
+                                                               >\r
+                                                               <Tool\r
+                                                                       Name="VCCustomBuildTool"\r
+                                                                       CommandLine="\perl\bin\perl.exe -w \cxxtest\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o &quot;$(InputDir)$(InputName)&quot;.cpp &quot;$(InputPath)&quot;"\r
+                                                                       Outputs="&quot;$(InputDir)$(InputName)&quot;.cpp"\r
+                                                               />\r
+                                                       </FileConfiguration>\r
+                                                       <FileConfiguration\r
+                                                               Name="Release|Win32"\r
+                                                               >\r
+                                                               <Tool\r
+                                                                       Name="VCCustomBuildTool"\r
+                                                                       CommandLine="\perl\bin\perl.exe -w \cxxtest\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o &quot;$(InputDir)$(InputName)&quot;.cpp &quot;$(InputPath)&quot;"\r
+                                                                       Outputs="&quot;$(InputDir)$(InputName)&quot;.cpp"\r
+                                                               />\r
+                                                       </FileConfiguration>\r
+                                               </File>\r
                                        </Filter>\r
                                </Filter>\r
                        </Filter>\r