2 * Copyright 2001-2005 Internet2
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
17 #include "XMLObjectBaseTestCase.h"
\r
20 #include <xercesc/util/XMLUniDefs.hpp>
\r
22 const XMLCh SimpleXMLObject::NAMESPACE[] = {
\r
23 chLatin_h, chLatin_t, chLatin_t, chLatin_p, chColon, chForwardSlash, chForwardSlash,
\r
24 chLatin_w, chLatin_w, chLatin_w, chPeriod,
\r
25 chLatin_e, chLatin_x, chLatin_a, chLatin_m, chLatin_p, chLatin_l, chLatin_e, chPeriod,
\r
26 chLatin_o, chLatin_r, chLatin_g, chForwardSlash,
\r
27 chLatin_t, chLatin_e, chLatin_s, chLatin_t,
\r
28 chLatin_O, chLatin_b, chLatin_j, chLatin_e, chLatin_c, chLatin_t, chLatin_s, chNull
\r
31 const XMLCh SimpleXMLObject::NAMESPACE_PREFIX[] = {
\r
32 chLatin_t, chLatin_e, chLatin_s, chLatin_t, chNull
\r
35 const XMLCh SimpleXMLObject::LOCAL_NAME[] = {
\r
36 chLatin_S, chLatin_i, chLatin_m, chLatin_p, chLatin_l, chLatin_e,
\r
37 chLatin_E, chLatin_l, chLatin_e, chLatin_m, chLatin_e, chLatin_n, chLatin_t, chNull
\r
40 const XMLCh SimpleXMLObject::ID_ATTRIB_NAME[] = {
\r
41 chLatin_I, chLatin_d, chNull
\r
44 class UnmarshallingTest : public CxxTest::TestSuite {
\r
47 UnmarshallingTest() : m_qname(SimpleXMLObject::NAMESPACE,SimpleXMLObject::LOCAL_NAME) {}
\r
50 XMLObjectBuilder::registerBuilder(m_qname, new SimpleXMLObjectBuilder());
51 Marshaller::registerMarshaller(m_qname, new SimpleXMLObjectMarshaller());
52 Unmarshaller::registerUnmarshaller(m_qname, new SimpleXMLObjectUnmarshaller());
56 XMLObjectBuilder::deregisterBuilder(m_qname);
57 Marshaller::deregisterMarshaller(m_qname);
58 Unmarshaller::deregisterUnmarshaller(m_qname);
61 void testUnmarshallingWithAttributes() {
\r
62 ifstream fs("../xmltoolingtest/data/SimpleXMLObjectWithAttribute.xml");
\r
63 DOMDocument* doc=nonvalidatingPool->parse(fs);
\r
64 TS_ASSERT(doc!=NULL);
\r
66 const Unmarshaller* u = Unmarshaller::getUnmarshaller(doc->getDocumentElement());
\r
69 auto_ptr<SimpleXMLObject> sxObject(dynamic_cast<SimpleXMLObject*>(u->unmarshall(doc->getDocumentElement(),true)));
\r
70 TS_ASSERT(sxObject.get()!=NULL);
\r
72 auto_ptr_XMLCh expectedId("Firefly");
\r
73 TSM_ASSERT_SAME_DATA("ID was not expected value", expectedId.get(), sxObject->getId(), XMLString::stringLen(expectedId.get()));
\r