New tests
authorScott Cantor <cantor.2@osu.edu>
Thu, 11 May 2006 03:36:11 +0000 (03:36 +0000)
committerScott Cantor <cantor.2@osu.edu>
Thu, 11 May 2006 03:36:11 +0000 (03:36 +0000)
samltest/saml1/core/impl/AttributeDesignatorTest.h [new file with mode: 0644]
samltest/saml1/core/impl/AttributeStatementTest.h [new file with mode: 0644]
samltest/samltest.vcproj

diff --git a/samltest/saml1/core/impl/AttributeDesignatorTest.h b/samltest/saml1/core/impl/AttributeDesignatorTest.h
new file mode 100644 (file)
index 0000000..b6f005b
--- /dev/null
@@ -0,0 +1,66 @@
+/*\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 AttributeDesignatorTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {\r
+    XMLCh* expectedAttributeName;\r
+    XMLCh* expectedAttributeNamespace;\r
+\r
+public:\r
+    void setUp() {\r
+        expectedAttributeName=XMLString::transcode("AttributeName");\r
+        expectedAttributeNamespace=XMLString::transcode("namespace");\r
+        singleElementFile = data_path + "saml1/core/impl/singleAttributeDesignator.xml";\r
+        singleElementOptionalAttributesFile = data_path + "saml1/core/impl/singleAttributeDesignatorAttributes.xml";\r
+        SAMLObjectBaseTestCase::setUp();\r
+    }\r
+    \r
+    void tearDown() {\r
+        XMLString::release(&expectedAttributeName);\r
+        XMLString::release(&expectedAttributeNamespace);\r
+        SAMLObjectBaseTestCase::tearDown();\r
+    }\r
+\r
+    void testSingleElementUnmarshall() {\r
+        auto_ptr<XMLObject> xo(unmarshallElement(singleElementFile));\r
+        AttributeDesignator& ad = dynamic_cast<AttributeDesignator&>(*xo.get());\r
+        TSM_ASSERT("AttributeName", ad.getAttributeName()==NULL);\r
+        TSM_ASSERT("AttributeNamespace", ad.getAttributeNamespace()==NULL);\r
+    }\r
+\r
+    void testSingleElementOptionalAttributesUnmarshall() {\r
+        auto_ptr<XMLObject> xo(unmarshallElement(singleElementOptionalAttributesFile));\r
+        AttributeDesignator& ad = dynamic_cast<AttributeDesignator&>(*xo.get());\r
+        TSM_ASSERT_SAME_DATA("AttributeName", expectedAttributeName, ad.getAttributeName(), XMLString::stringLen(expectedAttributeName));\r
+        TSM_ASSERT_SAME_DATA("AttributeNamespace", expectedAttributeNamespace, ad.getAttributeNamespace(), XMLString::stringLen(expectedAttributeNamespace));\r
+    }\r
+\r
+    void testSingleElementMarshall() {\r
+        assertEquals(expectedDOM, AttributeDesignatorBuilder::buildAttributeDesignator());\r
+    }\r
+\r
+    void testSingleElementOptionalAttributesMarshall() {\r
+        AttributeDesignator* ad=AttributeDesignatorBuilder::buildAttributeDesignator();\r
+        ad->setAttributeName(expectedAttributeName);\r
+        ad->setAttributeNamespace(expectedAttributeNamespace);\r
+        assertEquals(expectedOptionalAttributesDOM, ad);\r
+    }\r
+\r
+};\r
diff --git a/samltest/saml1/core/impl/AttributeStatementTest.h b/samltest/saml1/core/impl/AttributeStatementTest.h
new file mode 100644 (file)
index 0000000..3b6c054
--- /dev/null
@@ -0,0 +1,69 @@
+/*\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 AttributeStatementTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {\r
+public:\r
+    void setUp() {\r
+        singleElementFile = data_path + "saml1/core/impl/singleAttributeStatement.xml";\r
+        childElementsFile = data_path + "saml1/core/impl/AttributeStatementWithChildren.xml";\r
+        SAMLObjectBaseTestCase::setUp();\r
+    }\r
+    \r
+    void tearDown() {\r
+        SAMLObjectBaseTestCase::tearDown();\r
+    }\r
+\r
+    void testSingleElementUnmarshall() {\r
+        auto_ptr<XMLObject> xo(unmarshallElement(singleElementFile));\r
+        AttributeStatement& as = dynamic_cast<AttributeStatement&>(*xo.get());\r
+        TSM_ASSERT("<Subject> element present", as.getSubject()==NULL);\r
+        TSM_ASSERT_EQUALS("Non zero count of <Attribute> elements", 0, as.getAttributes().size());\r
+    }\r
+\r
+    void testChildElementsUnmarshall() {\r
+        auto_ptr<XMLObject> xo(unmarshallElement(childElementsFile));\r
+        AttributeStatement& as = dynamic_cast<AttributeStatement&>(*xo.get());\r
+        TSM_ASSERT("<Subject> element not present", as.getSubject()!=NULL);\r
+        TSM_ASSERT_EQUALS("count of <Attribute> elements", 5, as.getAttributes().size());\r
+\r
+        as.getAttributes().erase(as.getAttributes().begin());\r
+        TSM_ASSERT_EQUALS("count of <Attribute> elements after single remove", 4, as.getAttributes().size());\r
+\r
+        as.getAttributes().erase(as.getAttributes().begin());\r
+        as.getAttributes().erase(as.getAttributes().begin()+1);\r
+        TSM_ASSERT_EQUALS("count of <Attribute> elements after double remove", 2, as.getAttributes().size());\r
+    }\r
+\r
+    void testSingleElementMarshall() {\r
+        assertEquals(expectedDOM, AttributeStatementBuilder::buildAttributeStatement());\r
+    }\r
+\r
+    void testChildElementsMarshall() {\r
+        AttributeStatement* as=AttributeStatementBuilder::buildAttributeStatement();\r
+        as->setSubject(SubjectBuilder::buildSubject());\r
+        for (int i = 0; i < 5; i++) {\r
+            as->getAttributes().push_back(AttributeBuilder::buildAttribute());\r
+        }\r
+\r
+        assertEquals(expectedChildElementsDOM, as);\r
+    }\r
+\r
+};\r
index 5c4b19d..09f17b3 100644 (file)
                                                        RelativePath=".\saml1\core\impl\AssertionTest.cpp"\r
                                                        >\r
                                                </File>\r
+                                               <File\r
+                                                       RelativePath=".\saml1\core\impl\AttributeDesignatorTest.cpp"\r
+                                                       >\r
+                                               </File>\r
+                                               <File\r
+                                                       RelativePath=".\saml1\core\impl\AttributeStatementTest.cpp"\r
+                                                       >\r
+                                               </File>\r
                                        </Filter>\r
                                </Filter>\r
                        </Filter>\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
+                                                                       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;&#x0D;&#x0A;"\r
                                                                        Outputs="&quot;$(InputDir)$(InputName)&quot;.cpp"\r
                                                                />\r
                                                        </FileConfiguration>\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
+                                                                       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;&#x0D;&#x0A;"\r
                                                                        Outputs="&quot;$(InputDir)$(InputName)&quot;.cpp"\r
                                                                />\r
                                                        </FileConfiguration>\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;&#x0D;&#x0A;"\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;&#x0D;&#x0A;"\r
+                                                                       Outputs="&quot;$(InputDir)$(InputName)&quot;.cpp"\r
+                                                               />\r
+                                                       </FileConfiguration>\r
+                                               </File>\r
+                                               <File\r
+                                                       RelativePath=".\saml1\core\impl\AssertionTest.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;&#x0D;&#x0A;"\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;&#x0D;&#x0A;"\r
+                                                                       Outputs="&quot;$(InputDir)$(InputName)&quot;.cpp"\r
+                                                               />\r
+                                                       </FileConfiguration>\r
+                                               </File>\r
+                                               <File\r
+                                                       RelativePath=".\saml1\core\impl\AttributeDesignatorTest.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
                                                </File>\r
                                                <File\r
-                                                       RelativePath=".\saml1\core\impl\AssertionTest.h"\r
+                                                       RelativePath=".\saml1\core\impl\AttributeStatementTest.h"\r
                                                        >\r
                                                        <FileConfiguration\r
                                                                Name="Debug|Win32"\r