use of commonj.sdo.Property in project eclipselink by eclipse-ee4j.
the class SDOSequenceTestXSD method test_voidReturnFrom_add_int_Property_Object_propertyIsAttribute.
public void test_voidReturnFrom_add_int_Property_Object_propertyIsAttribute() {
// int index, Property property, Object value) {
defineAndLoadRoot(false, false);
// detach shipTo
SDOSequence aSequence = getSequence(root, PO_SEQUENCE_PATH, PO_SEQUENCE_SIZE);
DataObject po = (DataObject) root.get(PO_SEQUENCE_PATH);
int treeSizeBeforeAdd = preOrderTraversalDataObjectList(po).size();
assertEquals(PO_TREE_SIZE, treeSizeBeforeAdd);
assertEquals(PO_SEQUENCE_SIZE, aSequence.size());
int listSizeBefore = ((ListWrapper) po.get("item")).size();
assertEquals(2, listSizeBefore);
int indexToPlaceAtEnd = aSequence.size();
// object to add
DataObject item2 = (DataObject) root.get("item[2]");
assertNotNull(item2);
Property orderDateProperty = po.getInstanceProperty("orderDate");
// add to sequence
try {
aSequence.add(indexToPlaceAtEnd, orderDateProperty, "1999-10-19");
} catch (Exception e) {
}
// get back new Setting value
ListWrapper item2Value = null;
boolean exceptionThrown = false;
try {
item2Value = (ListWrapper) aSequence.getValue(indexToPlaceAtEnd);
} catch (SDOException e) {
assertEquals(SDOException.INVALID_INDEX, e.getErrorCode());
exceptionThrown = true;
}
assertNull(item2Value);
assertTrue(exceptionThrown);
}
use of commonj.sdo.Property in project eclipselink by eclipse-ee4j.
the class XmlElementPropertyTestCases method testPropertyFromDataObjectWithOpenContentPropertySet.
public void testPropertyFromDataObjectWithOpenContentPropertySet() {
String controlProperty = "CONTROL_PROPERTY";
String controlValue = "CONTROL_VALUE";
Type stringType = typeHelper.getType("commonj.sdo", "String");
DataObject propertyDO = dataFactory.create("commonj.sdo", "Property");
propertyDO.set("name", "foo");
propertyDO.set("type", stringType);
propertyDO.set(controlProperty, controlValue);
Property property = typeHelper.defineOpenContentProperty("urn:example", propertyDO);
assertEquals(1, property.getInstanceProperties().size());
}
use of commonj.sdo.Property in project eclipselink by eclipse-ee4j.
the class XmlElementPropertyTestCases method testPropertyFromDataObjectWithOpenContentPropertySetAndXmlElementPropertySetToTrue.
public void testPropertyFromDataObjectWithOpenContentPropertySetAndXmlElementPropertySetToTrue() {
String controlProperty = "CONTROL_PROPERTY";
String controlValue = "CONTROL_VALUE";
Type stringType = typeHelper.getType("commonj.sdo", "String");
DataObject propertyDO = dataFactory.create("commonj.sdo", "Property");
propertyDO.set("name", "foo");
propertyDO.set("type", stringType);
propertyDO.set(controlProperty, controlValue);
propertyDO.set(SDOConstants.XMLELEMENT_PROPERTY, Boolean.TRUE);
Property property = typeHelper.defineOpenContentProperty("urn:example", propertyDO);
assertTrue((Boolean) property.get(SDOConstants.XMLELEMENT_PROPERTY));
assertEquals(2, property.getInstanceProperties().size());
}
use of commonj.sdo.Property in project eclipselink by eclipse-ee4j.
the class SDOSequenceTestXSD method testAddSimpleSingleAttributeFailsViaSequenceAdd.
public void testAddSimpleSingleAttributeFailsViaSequenceAdd() {
defineAndLoadRoot(false, false);
SDOSequence aSequence = getSequence(root, CUSTOMER_PATH, PO_SEQUENCE_SIZE);
DataObject cust = (DataObject) root.get(CUSTOMER_PATH);
Property custProperty = cust.getInstanceProperty("custID");
int errorCode = -1;
try {
aSequence.add(custProperty, "0001");
} catch (SDOException e) {
errorCode = e.getErrorCode();
}
assertEquals(SDOException.SEQUENCE_ERROR_PROPERTY_IS_ATTRIBUTE, errorCode);
}
use of commonj.sdo.Property in project eclipselink by eclipse-ee4j.
the class SDOSequenceTestXSD method testMoveSameIndex.
public void testMoveSameIndex() {
defineAndLoadRoot(false, false);
DataObject po = (DataObject) root.get(PO_SEQUENCE_PATH);
assertNotNull(po);
assertTrue(po.getType().isSequenced());
SDOSequence aSequence = (SDOSequence) po.getSequence();
// move 2 sequenced objects
Property beforeMoveProp1 = aSequence.getProperty(1);
assertNotNull(beforeMoveProp1);
aSequence.move(1, 1);
Property afterMoveProp1 = aSequence.getProperty(1);
assertTrue(beforeMoveProp1 == afterMoveProp1);
}
Aggregations