You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ro...@apache.org on 2007/08/29 12:10:09 UTC
svn commit: r570733 - in /incubator/tuscany/cpp/sdo/runtime/core:
src/commonj/sdo/ test/
Author: robbinspg
Date: Wed Aug 29 03:10:03 2007
New Revision: 570733
URL: http://svn.apache.org/viewvc?rev=570733&view=rev
Log:
TUSCANY-1548 Apply Michael Yoder's patch
Modified:
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.cpp
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.h
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDORuntimeException.cpp
incubator/tuscany/cpp/sdo/runtime/core/test/main.cpp
incubator/tuscany/cpp/sdo/runtime/core/test/maintest.txt
incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.cpp
incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.h
incubator/tuscany/cpp/sdo/runtime/core/test/sdotest2.cpp
incubator/tuscany/cpp/sdo/runtime/core/test/setmany.txt
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.cpp?rev=570733&r1=570732&r2=570733&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.cpp Wed Aug 29 03:10:03 2007
@@ -41,6 +41,7 @@
#include "commonj/sdo/SDOUtils.h"
#include <string>
+#include <sstream>
#include <stdio.h>
#include <stdlib.h>
using std::string;
@@ -974,14 +975,11 @@
return;
}
- //////////////////////////////////////////////////////////////////////
- // Find a data object or return 0 if not found
- //////////////////////////////////////////////////////////////////////
- DataObjectImpl* DataObjectImpl::findDataObject(const SDOString& token, long* index)
+ void DataObjectImpl::getPathToken(const SDOString& propStr, PathToken& pathToken)
{
// name , name[int], name[x=y] name.int
- size_t beginbrace = token.find('[');
- size_t dot = token.find('.');
+ size_t beginbrace = propStr.find('[');
+ size_t dot = propStr.find('.');
size_t breaker = 0;
if (dot != string::npos)
@@ -1002,27 +1000,16 @@
if (breaker == string::npos)
{
- // its this object, and a property thereof
- *index = -1;
- PropertyPtr p = getInstanceProperty(token);
- if (!p) {
- throwPropertyNotFound(TUSCANY_SDO_EINFO,
- token);
- }
- return getDataObjectImpl(*p);
- }
-
- // We did find a breaker character.
- PropertyPtr p = getInstanceProperty(SDOString(token, 0, breaker));
- if (!p) {
- throwPropertyNotFound(TUSCANY_SDO_EINFO,
- SDOString(token, 0, breaker));
+ pathToken.index = -1;
+ pathToken.propertyName = propStr;
+ return;
}
+ pathToken.propertyName = propStr.substr(0, breaker);
breaker++;
-
- size_t endbrace = token.find(']');
- SDOString breakerStr = token.substr(breaker, (endbrace - breaker));
+ size_t endbrace = propStr.find(']');
+ SDOString breakerStr = propStr.substr(breaker, (endbrace - breaker));
+
// Search for the first occurence of an = sign starting at the previously
// identified "breaker" character and ending at the endbrace just found. We
// need to make a new SDOString to contain that substring.
@@ -1032,39 +1019,69 @@
if (eq == string::npos)
{
// There is no "=" sign
- unsigned int val = atoi(breakerStr.c_str());
- DataObjectList& list = getList(*p);
-
- // The spec says that depts[1] is the first element, as is depts.0
- if (beginbrace != string::npos) val--;
-
- if (val >=0 && val < list.size())
- {
- DataObject* dob = getRawPointer(list[val]);
- *index = val;
- return (DataObjectImpl*)dob;
- }
- *index = -1;
- return 0;
+ pathToken.index = atoi(breakerStr.c_str());
+ if (beginbrace != string::npos) --pathToken.index;
+ return;
}
// We did find an "=" sign.
- SDOString PropertyName = breakerStr.substr(0, eq);
+ pathToken.predicateName = breakerStr.substr(0, eq);
// breaker is now propname
eq++;
- SDOString PropertyValue = breakerStr.substr(eq);
- // eq is now propval
+ pathToken.predicateValue = breakerStr.substr(eq);
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // Find a data object or return 0 if not found
+ //////////////////////////////////////////////////////////////////////
+ DataObjectImpl* DataObjectImpl::findDataObject(const PathToken& pathToken)
+ {
+ PropertyPtr p = getInstanceProperty(pathToken.propertyName);
+ if (!p) {
+ throwPropertyNotFound(TUSCANY_SDO_EINFO,
+ pathToken.propertyName);
+ }
+ if (pathToken.index == -1 && !pathToken.predicateName.length())
+ {
+ if (p->isMany()) {
+ SDOString msg("Property '");
+ msg += pathToken.propertyName;
+ msg += "' is multi-valued and must have a xpath index.";
+ throw SDOUnsupportedOperationException(TUSCANY_SDO_EINFO,
+ msg.c_str());
+ }
+ return getDataObjectImpl(*p);
+ }
DataObjectList& list = getList(*p);
+ if (!pathToken.predicateName.length())
+ {
+ if (pathToken.index >=0 && (unsigned int)pathToken.index < list.size())
+ {
+ DataObject* dob = getRawPointer(list[pathToken.index]);
+ return (DataObjectImpl*)dob;
+ }
+ else {
+ std::stringstream msg;
+ msg << "Index out of range: property = '";
+ msg << pathToken.propertyName;
+ msg << "' index = '";
+ msg << pathToken.index;
+ msg << "'.";
+ throw SDOIndexOutOfRangeException(TUSCANY_SDO_EINFO,
+ msg.str().c_str());
+ }
+ }
+
for (unsigned int li = 0 ; li < list.size() ; ++li)
{
// TODO comparison for double not ok
const Type & t = list[li]->getType();
- PropertyPtr p = list[li]->getInstanceProperty(PropertyName);
+ PropertyPtr p = list[li]->getInstanceProperty(pathToken.predicateName);
if (!p) {
throwPropertyNotFound(TUSCANY_SDO_EINFO,
- PropertyName);
+ pathToken.predicateName);
}
int ok = 0;
@@ -1073,13 +1090,13 @@
case Type::BooleanType:
{
// getCString will return "true" or "false"
- if (!strcmp(PropertyValue.c_str(), list[li]->getCString(*p))) ok = 1;
+ if (!strcmp(pathToken.predicateValue.c_str(), list[li]->getCString(*p))) ok = 1;
}
break;
case Type::ByteType:
{
- char cc = PropertyValue[0];
+ char cc = pathToken.predicateValue[0];
// getByte return a char
if (cc == list[li]->getByte(*p)) ok = 1;
}
@@ -1087,7 +1104,7 @@
case Type::CharacterType:
{
- wchar_t wc = *((wchar_t*) PropertyValue.c_str());
+ wchar_t wc = *((wchar_t*) pathToken.predicateValue.c_str());
// wchar_t wc = (wchar_t)((wchar_t*)eq)[0];
// TODO - this is not a very accesible way of storing a wchar
if (wc == list[li]->getCharacter(*p)) ok = 1;
@@ -1096,14 +1113,14 @@
case Type::IntType:
{
- long ic = atol(PropertyValue.c_str());
+ long ic = atol(pathToken.predicateValue.c_str());
if (ic == list[li]->getInt(*p)) ok = 1;
}
break;
case Type::DateType:
{
- long dc = atol(PropertyValue.c_str());
+ long dc = atol(pathToken.predicateValue.c_str());
if (dc == (long)(list[li]->getDate(*p).getTime())) ok = 1;
}
break;
@@ -1111,14 +1128,14 @@
case Type::DoubleType:
{
// TODO - double needs a bigger size than float
- long double ldc = (long double)atof(PropertyValue.c_str());
+ long double ldc = (long double)atof(pathToken.predicateValue.c_str());
if (ldc == list[li]->getDouble(*p)) ok = 1;
}
break;
case Type::FloatType:
{
- float fc = atof(PropertyValue.c_str());
+ float fc = atof(pathToken.predicateValue.c_str());
if (fc == list[li]->getFloat(*p)) ok = 1;
}
break;
@@ -1126,9 +1143,9 @@
case Type::LongType:
{
#if defined(WIN32) || defined (_WINDOWS)
- int64_t lic = (int64_t)_atoi64(PropertyValue.c_str());
+ int64_t lic = (int64_t)_atoi64(pathToken.predicateValue.c_str());
#else
- int64_t lic = (int64_t)strtoll(PropertyValue.c_str(), NULL, 0);
+ int64_t lic = (int64_t)strtoll(pathToken.predicateValue.c_str(), NULL, 0);
#endif
if (lic == list[li]->getLong(*p)) ok = 1;
@@ -1137,7 +1154,7 @@
case Type::ShortType:
{
- short sic = atoi(PropertyValue.c_str());
+ short sic = atoi(pathToken.predicateValue.c_str());
if (sic == list[li]->getShort(*p)) ok = 1;
}
break;
@@ -1149,10 +1166,10 @@
case Type::UriType:
{
- if (!strcmp(PropertyValue.c_str(), list[li]->getCString(*p))) ok = 1;
+ if (!strcmp(pathToken.predicateValue.c_str(), list[li]->getCString(*p))) ok = 1;
// try with quotes too
- size_t firstquote = PropertyValue.find('"');
- size_t firstsingle = PropertyValue.find('\'');
+ size_t firstquote = pathToken.predicateValue.find('"');
+ size_t firstsingle = pathToken.predicateValue.find('\'');
char searchchar = 0;
@@ -1178,10 +1195,10 @@
if (searchchar != 0)
{
- size_t ender = PropertyValue.find(searchchar, firstquote + 1);
+ size_t ender = pathToken.predicateValue.find(searchchar, firstquote + 1);
if (ender != string::npos)
{
- if (!strcmp(PropertyValue.substr(firstquote + 1, ender - (firstquote+1)).c_str(), list[li]->getCString(*p)))
+ if (!strcmp(pathToken.predicateValue.substr(firstquote + 1, ender - (firstquote+1)).c_str(), list[li]->getCString(*p)))
ok = 1;
}
}
@@ -1198,12 +1215,18 @@
if (ok == 1)
{
DataObject* dob = getRawPointer(list[li]);
- *index = li;
return (DataObjectImpl*)dob;
}
-
- }
- return 0;
+ } // for
+ string msg("Invalid path: ");
+ msg += pathToken.propertyName;
+ msg += "[";
+ msg += pathToken.predicateName;
+ msg += "=";
+ msg += pathToken.predicateValue;
+ msg += "]";
+ throw SDOPathNotFoundException(TUSCANY_SDO_EINFO,
+ msg.c_str());
}
@@ -1287,8 +1310,9 @@
}
/* Try to find a property ....*/
- long l;
- d = findDataObject(token, &l);
+ PathToken pathToken;
+ getPathToken(token, pathToken);
+ d = findDataObject(pathToken);
if (d != 0) {
return d->findPropertyContainer(remaining, din);
}
@@ -1509,11 +1533,9 @@
if (p->isMany())
{
DataObjectList& dol = d->getList((Property&)*p);
- long idx;
- DataObjectImpl* dx = d->findDataObject(prop,&idx);
- // fix this. This is the only place the 2nd parm to findDataObject
- // is used. Need a better way to do this
- unsigned int index = (unsigned int) idx;
+ PathToken pathToken;
+ getPathToken(prop, pathToken);
+ unsigned int index = (unsigned int) pathToken.index;
if (index >= 0)
{
if(index < dol.size())
@@ -2114,41 +2136,16 @@
{
if (!prop.empty())
{
- if (prop.find_first_of("[.") != string::npos)
- {
- /* Its a multi-valued property */
- long l;
- DataObjectImpl* theob = d->findDataObject(prop, &l);
- if (theob == 0)
- {
- string msg("Get DataObject - index out of range:");
- msg += path;
- throw SDOIndexOutOfRangeException(TUSCANY_SDO_EINFO,
- msg.c_str());
- }
- return theob;
- }
- else
- {
- if (prop.length() == 0)
- {
- return d;
- }
- PropertyPtr p = d->getInstanceProperty(prop);
- if (!p) {
- throwPropertyNotFound(TUSCANY_SDO_EINFO,
- prop);
- }
- return d->getDataObjectImpl(*p);
- }
+ PathToken pathToken;
+ d->getPathToken(prop, pathToken);
+ return d->findDataObject(pathToken);
}
else
{
return d;
}
}
-
- string msg("Invalid path:");
+ string msg("Invalid path: ");
msg += path;
throw SDOPathNotFoundException(TUSCANY_SDO_EINFO,
msg.c_str());
@@ -3646,9 +3643,10 @@
if ((p->isMany()) || (p->getTypeImpl()->isFromList()))
{
- long l;
DataObjectList& dol = d->getList((Property&) *p);
- DataObjectImpl* doi = d->findDataObject(prop, &l);
+ PathToken pathToken;
+ getPathToken(prop, pathToken);
+ DataObjectImpl* doi = d->findDataObject(pathToken);
if (doi != 0)
{
doi->setSDOValue(sval);
@@ -3790,8 +3788,9 @@
{
if ((p->isMany()) || p->getTypeImpl()->isFromList())
{
- long l;
- DataObjectImpl* doi = d->findDataObject(prop, &l);
+ PathToken pathToken;
+ getPathToken(prop, pathToken);
+ DataObjectImpl* doi = d->findDataObject(pathToken);
if (doi != 0)
{
return doi->getSDOValue(propertyForDefault);
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.h?rev=570733&r1=570732&r2=570733&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.h (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.h Wed Aug 29 03:10:03 2007
@@ -72,6 +72,15 @@
typedef std::list< rdo > PropertyValueMap;
+class PathToken {
+public:
+ PathToken() : index(-1) {}
+ long index;
+ SDOString propertyName;
+ SDOString predicateName;
+ SDOString predicateValue;
+};
+
/**
* DataObjectImpl implements the abstract class DataObject.
@@ -627,13 +636,14 @@
const char* namespaceURI,
const char* typeName);
- DataObjectImpl* findDataObject(const SDOString& token, long* index);
- const Property* findInProperties(DataObject* ob);
+ void getPathToken(const SDOString& propStr, PathToken& pathToken);
+ DataObjectImpl* findDataObject(const PathToken& pathToken);
+ const Property* findInProperties(DataObject* ob);
- SDOString findPropertyContainer(const SDOString& path, DataObjectImpl** din);
+ SDOString findPropertyContainer(const SDOString& path, DataObjectImpl** din);
- char* stripPath(const char* path);
- void stripPath(const SDOString& path, SDOString& result);
+ char* stripPath(const char* path);
+ void stripPath(const SDOString& path, SDOString& result);
// Does not keep a reference counted pointer to the container.
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDORuntimeException.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDORuntimeException.cpp?rev=570733&r1=570732&r2=570733&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDORuntimeException.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDORuntimeException.cpp Wed Aug 29 03:10:03 2007
@@ -50,15 +50,15 @@
namespace sdo {
-SDOExceptionInfo::SDOExceptionInfo(const char* fileName,
- unsigned long lineNumber,
- const char* functionName)
- : lineNumber(lineNumber)
+SDOExceptionInfo::SDOExceptionInfo(const char* fileNameIN,
+ unsigned long lineNumberIN,
+ const char* functionNameIN)
+ : lineNumber(lineNumberIN)
, fileName(0)
, functionName(0)
{
- fileName = makeCopy(fileName);
- functionName = makeCopy(functionName);
+ fileName = makeCopy(fileNameIN);
+ functionName = makeCopy(functionNameIN);
}
SDOExceptionInfo::SDOExceptionInfo(const SDOExceptionInfo& second)
Modified: incubator/tuscany/cpp/sdo/runtime/core/test/main.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/main.cpp?rev=570733&r1=570732&r2=570733&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/main.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/main.cpp Wed Aug 29 03:10:03 2007
@@ -30,13 +30,27 @@
extern "C"{
-#define TEST(testname)\
- value = testname;\
- totaltests++;\
- if (value == 0) {\
- cout << "Test Failed: " << totaltests << " " << #testname << endl;\
- }\
- testspassed += value;
+#define TEST(testname) \
+ ++totaltests; \
+ try { \
+ value = testname; \
+ cout << "Test " << totaltests << ": " << #testname << " ..... "; \
+ if (value) { \
+ cout << "OK" << endl; \
+ ++testspassed; \
+ } \
+ else { \
+ cout << "FAILED" << endl; \
+ } \
+ } \
+ catch(const SDORuntimeException&) { \
+ cout << "Test " << totaltests << ": " << #testname << " ..... "; \
+ cout << "FAILED (unexpected SDO exception)" << endl; \
+ } \
+ catch(...) { \
+ cout << "Test " << totaltests << ": " << #testname << " ..... "; \
+ cout << "FAILED (unexpected unknown exception)" << endl; \
+ }
int main (int argc, char** argv)
{
@@ -192,6 +206,7 @@
TEST ( sdotest::elementFormDefaultQualifiedSequence() );
TEST ( sdotest::xsiTypeAbstract() );
TEST ( sdotest::refCount() );
+ TEST ( sdotest::jira1548() );
} catch(...)
{
Modified: incubator/tuscany/cpp/sdo/runtime/core/test/maintest.txt
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/maintest.txt?rev=570733&r1=570732&r2=570733&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/maintest.txt (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/maintest.txt Wed Aug 29 03:10:03 2007
@@ -183,6 +183,6 @@
Department: Architecture
Department: Pyrotechnics
Department: Accounts
-String in list type:department label
+Normal expected exception
Normal Invalid path exception
Normal SDOPropertyNotFound exception
Modified: incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.cpp?rev=570733&r1=570732&r2=570733&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.cpp Wed Aug 29 03:10:03 2007
@@ -1106,6 +1106,7 @@
{
cout << "WRONG unset and undefaulted" << endl;
}
+ cout << pe << endl;
return 0;
}
catch (SDOInvalidConversionException ec)
@@ -1397,9 +1398,9 @@
if (test->getUserData("unsetobject") != (void*)0) return 0;
- test->setUserData("objects", (void*)0x640);
+ test->setUserData("objects.0", (void*)0x640);
- if (test->getUserData("objects") != (void*)0x640) return 0;
+ if (test->getUserData("objects.0") != (void*)0x640) return 0;
test->setUserData("objects[1]", (void*)0x740);
@@ -3636,10 +3637,11 @@
school->setCString("name","King Norberts");
school->createDataObject("address");
- school->setCString("address/lines.0","The Place");
- school->setCString("address/lines.1","1 The Avenue");
- school->setCString("address/lines.2","Murchester");
- school->setCString("address/lines.3","England");
+ DataObjectList& lines = school->getList("address/lines");
+ lines.append("The Place");
+ lines.append("1 The Avenue");
+ lines.append("Murchester");
+ lines.append("England");
class1->setCString("name","Primary");
class2->setCString("name","Secondary");
@@ -3684,7 +3686,7 @@
fprintf(f," Pupil3 :%s\n",class2->getCString("children[4]/name"));
return 0;
}
- catch (SDOPathNotFoundException e)
+ catch (const SDOIndexOutOfRangeException&)
{
fprintf(f,"Expected path not found exception caught\n");
}
@@ -3733,8 +3735,7 @@
}
try {
- school->setCString("address/lines[6]","PostCode");
- fprintf(f, "Debatable behaviour - appended\n");
+ school->getList("address/lines").append("PostCode");
fprintf(f," Address4 :%s\n",school->getCString("address/lines[5]"));
}
catch (SDORuntimeException e)
@@ -7620,7 +7621,7 @@
DataObjectPtr pitem = dor->getDataObject("items[name=\"hello\"]");
return 0;
}
- catch (SDOIndexOutOfRangeException e)
+ catch (const SDOPathNotFoundException&)
{
//cout << "Normal exception in Graham4" << endl;
}
@@ -7629,7 +7630,7 @@
int inty = dor->getInt("ints[1]");
return 0;
}
- catch (SDOIndexOutOfRangeException e)
+ catch (const SDOIndexOutOfRangeException&)
{
//cout << "Normal exception in Graham4" << endl;
}
@@ -7643,7 +7644,7 @@
DataObjectPtr pitem2 = dor->getDataObject("items[name=\"hello\"]");
return 0;
}
- catch (SDOIndexOutOfRangeException e)
+ catch (const SDOPathNotFoundException&)
{
//cout << "Normal exception in Graham4" << endl;
}
@@ -7655,7 +7656,7 @@
int inty2 = dor->getInt("ints[2]");
return 0;
}
- catch (SDOIndexOutOfRangeException e)
+ catch (const SDOIndexOutOfRangeException&)
{
//cout << "Normal exception in Graham4" << endl;
}
Modified: incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.h?rev=570733&r1=570732&r2=570733&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.h (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.h Wed Aug 29 03:10:03 2007
@@ -215,4 +215,5 @@
static int elementFormDefaultQualified();
static int elementFormDefaultQualifiedSequence();
static int xsiTypeAbstract();
+ static int jira1548();
};
Modified: incubator/tuscany/cpp/sdo/runtime/core/test/sdotest2.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/sdotest2.cpp?rev=570733&r1=570732&r2=570733&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/sdotest2.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/sdotest2.cpp Wed Aug 29 03:10:03 2007
@@ -1935,7 +1935,7 @@
DataObjectPtr x = xsh->getDataFactory()->create("test","xT");
DataObjectPtr a = x->createDataObject("a");
- a->setCString("a1.1", "test data");
+ a->getList("a1").append("test data");
XMLDocumentPtr doc = xmh->createDocument(a, "", "a");
xmh->save(doc, "elementFormDefaultQualifiedSeq_out.xml", 2);
@@ -1980,3 +1980,100 @@
return 0;
}
}
+
+int sdotest::jira1548()
+{
+
+ try {
+
+ DataFactoryPtr mdg = DataFactory::getDataFactory();
+
+ mdg->addType("jira1548", "MyType");
+ mdg->addPropertyToType("jira1548","MyType",
+ "stringProp",
+ "commonj.sdo","String",
+ true, // isMany
+ false, // readOnly
+ false); // containment
+
+ mdg->addType("jira1548", "MyParentType");
+
+ mdg->addPropertyToType("jira1548","MyParentType",
+ "dobProp",
+ "jira1548","MyType",
+ true, // isMany
+ false, // readOnly
+ true); // containment
+
+ DataObjectPtr myTypeObj = mdg->create("jira1548", "MyType");
+ DataObjectList& stringPropList = myTypeObj->getList("stringProp");
+ stringPropList.append("stringPropValue1");
+
+ int success = 1;
+
+ SDOString expectedClass("SDOUnsupportedOperationException");
+ SDOString messageSubStr("must have a xpath index");
+ // should throw an exception, as accessing a multi-valued property with
+ // xpath, requires an index
+ try {
+ myTypeObj->getCString("stringProp");
+ success = 0;
+ }
+ catch(const SDORuntimeException& e) {
+ int correct = 1;
+ if (expectedClass != e.getEClassName()) correct = 0;
+ SDOString msg(e.getMessageText());
+ if (msg.find(messageSubStr) == std::string::npos) correct = 0;
+ if (!correct) {
+ cout << "Unexpected Exception in jira1548" << e << endl;
+ success = 0;
+ }
+ }
+
+ DataObjectPtr myParentTypeObj = mdg->create("jira1548", "MyParentType");
+ DataObjectList& dobPropList = myParentTypeObj->getList("dobProp");
+ dobPropList.append(myTypeObj);
+
+ // should throw an exception, as accessing a multi-valued property with
+ // xpath, requires an index
+ try {
+ myParentTypeObj->getDataObject("dobProp");
+ success = 0;
+ }
+ catch(const SDORuntimeException& e) {
+ int correct = 1;
+ if (expectedClass != e.getEClassName()) correct = 0;
+ SDOString msg(e.getMessageText());
+ if (msg.find(messageSubStr) == std::string::npos) correct = 0;
+ if (!correct) {
+ cout << "Unexpected Exception in jira1548" << e << endl;
+ success = 0;
+ }
+ }
+
+ // should throw an exception, as accessing a multi-valued property with
+ // xpath, requires an index (this test for an intermediate step)
+ try {
+ myParentTypeObj->getCString("dobProp/stringProp.0");
+ success = 0;
+ }
+ catch(const SDORuntimeException& e) {
+ int correct = 1;
+ if (expectedClass != e.getEClassName()) correct = 0;
+ SDOString msg(e.getMessageText());
+ if (msg.find(messageSubStr) == std::string::npos) correct = 0;
+ if (!correct) {
+ cout << "Unexpected Exception in jira1548" << e << endl;
+ success = 0;
+ }
+ }
+
+ return success;
+ }
+ catch (SDORuntimeException e)
+ {
+ cout << "Exception in jira1548" << e << endl;
+ return 0;
+ }
+}
+
Modified: incubator/tuscany/cpp/sdo/runtime/core/test/setmany.txt
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/setmany.txt?rev=570733&r1=570732&r2=570733&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/setmany.txt (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/setmany.txt Wed Aug 29 03:10:03 2007
@@ -20,5 +20,4 @@
Indexed as expected
Indexed as expected
Normal index out of range caught
-Debatable behaviour - appended
Address4 :PostCode
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org