@Test
public void testInvalidReadRequests() throws Exception {
ValueType stringType = typeManager.getValueType("STRING");
ValueType blobType = typeManager.getValueType("BLOB");
FieldType nonBlobField = typeManager.newFieldType(stringType, new QName(namespace, "NonBlobField"),
Scope.VERSIONED);
nonBlobField = typeManager.createFieldType(nonBlobField);
FieldType absentField = typeManager
.newFieldType(blobType, new QName(namespace, "AbsentField"), Scope.VERSIONED);
absentField = typeManager.createFieldType(absentField);
RecordType rt = typeManager.newRecordType(new QName(namespace, "NoBlobsRT"));
rt.addFieldTypeEntry(nonBlobField.getId(), false);
rt = typeManager.createRecordType(rt);
Record record = repository.newRecord();
record.setRecordType(rt.getName());
record.setField(nonBlobField.getName(), "This is not a blob");
record = repository.create(record);
try {
repository.getInputStream(record.getId(), record.getVersion(), nonBlobField.getName(), null, null);
fail("Expected exception");
} catch (BlobException e) {
// ok
}
try {
repository.getInputStream(record.getId(), record.getVersion(), absentField.getName(), null, null);
fail("Expected exception");
} catch (FieldNotFoundException e) {
// ok
}
try {
repository.getInputStream(record.getId(), record.getVersion(),
new QName(namespace, "nonExistingFieldType"),
null, null);
fail("Expected exception");
} catch (FieldTypeNotFoundException e) {
// ok
}
try {
repository.getInputStream(record.getId(), record.getVersion(), null, null, null);
fail("Expected exception");
} catch (IllegalArgumentException e) {
// ok
}
try {
repository.getInputStream(repoSetup.getIdGenerator().fromString("USER.nonexistingrecord"), null,
absentField.getName());
fail("Expected exception");
} catch (RecordNotFoundException e) {
// ok
}
}