use of org.eclipse.persistence.exceptions.SDOException in project eclipselink by eclipse-ee4j.
the class DateConvertBug5672591TestCases method testExceptionSet.
public void testExceptionSet() {
DataObject testDataObject = dataFactory.create(rootType);
Calendar cal = Calendar.getInstance();
cal.clear();
cal.set(Calendar.YEAR, 1975);
cal.set(Calendar.MONTH, Calendar.FEBRUARY);
cal.set(Calendar.DATE, 21);
Date dateValue = cal.getTime();
try {
// value should be converted to a string with dataHelper but unsupported conversion
testDataObject.setDate(rootType.getProperty("theBooleanProp"), dateValue);
} catch (IllegalArgumentException e) {
assertTrue(e.getCause() instanceof SDOException);
// assertEquals(SDOException.WRONG_VALUE_FOR_PROPERTY ,((SDOException)e.getCause()).getErrorCode());
// changed from WRONG_VALUE_FOR_PROPERTY to conversion error...this is because of removal of datahelper.isconversionsupported
assertEquals(SDOException.CONVERSION_ERROR, ((SDOException) e.getCause()).getErrorCode());
return;
}
fail("An IllegalArgumentException should have occurred");
}
use of org.eclipse.persistence.exceptions.SDOException in project eclipselink by eclipse-ee4j.
the class SDOTypeHelperDefineInvalidTestCases method testDefineInvalidPropertyTypeName.
public void testDefineInvalidPropertyTypeName() {
SDOHelperContext ctx = new SDOHelperContext();
DataObject typeDataObject = ctx.getDataFactory().create(SDOConstants.SDO_URL, SDOConstants.TYPE);
typeDataObject.set("name", "ValidPropertyName");
DataObject propertyTypeDataObject = ctx.getDataFactory().create(SDOConstants.SDO_URL, SDOConstants.TYPE);
// invalid code point 0x36F at index 0
propertyTypeDataObject.set("name", "\u036FInvalidPropertyTypeName");
DataObject propertyDataObject = typeDataObject.createDataObject("property");
propertyDataObject.set("name", "ValidPropertyName");
propertyDataObject.set("type", propertyTypeDataObject);
try {
ctx.getTypeHelper().define(typeDataObject);
fail("IllegalArgumentException exception expected but did not occur.");
} catch (IllegalArgumentException e) {
assertNotNull("Not null cause expected.", e.getCause());
assertTrue("SDOException expected as cause.", e.getCause() instanceof SDOException);
assertEquals(SDOException.ERROR_DEFINING_TYPE_INVALID_NAME, ((SDOException) e.getCause()).getErrorCode());
}
}
use of org.eclipse.persistence.exceptions.SDOException in project eclipselink by eclipse-ee4j.
the class SDOTypeHelperDefineInvalidTestCases method testDefineInvalidPropertyName.
public void testDefineInvalidPropertyName() {
SDOHelperContext ctx = new SDOHelperContext();
DataObject typeDataObject = ctx.getDataFactory().create(SDOConstants.SDO_URL, SDOConstants.TYPE);
typeDataObject.set("name", "ValidTypeName");
DataObject propertyDataObject = typeDataObject.createDataObject("property");
// invalid code point \u00BA
propertyDataObject.set("name", "N\u00BANF");
propertyDataObject.set("type", ctx.getTypeHelper().getType(SDOConstants.SDO_URL, SDOConstants.STRING));
try {
ctx.getTypeHelper().define(typeDataObject);
fail("IllegalArgumentException exception expected but did not occur.");
} catch (IllegalArgumentException e) {
assertNotNull("Not null cause expected.", e.getCause());
assertTrue("SDOException expected as cause.", e.getCause() instanceof SDOException);
assertEquals(SDOException.ERROR_DEFINING_PROPERTY_INVALID_NAME, ((SDOException) e.getCause()).getErrorCode());
}
}
use of org.eclipse.persistence.exceptions.SDOException in project eclipselink by eclipse-ee4j.
the class SDOTypeHelperDefineNullTestCases method testPropertyWithNullType.
public void testPropertyWithNullType() {
DataObject purchaseOrderTypeType = dataFactory.create("commonj.sdo", "Type");
SDOProperty prop = (SDOProperty) purchaseOrderTypeType.getType().getProperty("uri");
purchaseOrderTypeType.set(prop, "http://example.com/");
prop = (SDOProperty) purchaseOrderTypeType.getType().getProperty("name");
purchaseOrderTypeType.set(prop, "PurchaseOrderType");
// create a orderDateProperty
addProperty(purchaseOrderTypeType, "orderDate", null);
try {
typeHelper.define(purchaseOrderTypeType);
} catch (SDOException e) {
assertEquals(e.getErrorCode(), SDOException.NO_TYPE_SPECIFIED_FOR_PROPERTY);
return;
} catch (Exception e) {
}
fail("An exception should have been thrown but wasn't");
}
use of org.eclipse.persistence.exceptions.SDOException in project eclipselink by eclipse-ee4j.
the class DefineFailsDontRegisterTypesTestCases method testDefine.
@Override
public void testDefine() {
InputStream is = getSchemaInputStream(getSchemaToDefine());
int sizeBefore = ((SDOTypeHelper) typeHelper).getTypesHashMap().size();
boolean exceptionCase = false;
List types = null;
try {
types = xsdHelper.define(is, getSchemaLocation());
} catch (SDOException e) {
exceptionCase = true;
// do nothing
}
assertTrue(exceptionCase);
assertEquals(sizeBefore, ((SDOTypeHelper) typeHelper).getTypesHashMap().size());
assertNull(types);
assertNull(typeHelper.getType("http://www.example.org", "address-type"));
assertNull(typeHelper.getType("http://www.example.org", "customer-type"));
assertNull(typeHelper.getType("http://www.example.org", "bad-type"));
assertNull(xsdHelper.getGlobalProperty("http://www.example.org", "customer", true));
}
Aggregations