use of com.emc.storageos.api.service.impl.resource.utils.MarshallingExcetion in project coprhd-controller by CoprHD.
the class DbAuditLogRetrieverTest method auditServiceDBExceptionsTestXML.
@Test
public void auditServiceDBExceptionsTestXML() throws WebApplicationException, IOException, JAXBException {
deleteIfExists(XmlTestOutputFile);
DummyDBClient dbClient = new DummyDBClient();
DbAuditLogRetriever dummyDbAuditLogRetriever = new DbAuditLogRetriever();
dummyDbAuditLogRetriever.setDbClient(dbClient);
String timeBucket = "2012-01-02T00";
AuditLogRequest auditLogRequest = getAuditLogRequest(timeBucket);
MediaType mediaType = MediaType.APPLICATION_XML_TYPE;
File of = new File(XmlTestOutputFile);
OutputStream os = new FileOutputStream(of);
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(os));
try {
dummyDbAuditLogRetriever.getBulkAuditLogs(auditLogRequest, mediaType, out);
} catch (RetryableDatabaseException e) {
Assert.assertTrue(e.toString().contains("I/O"));
} catch (MarshallingExcetion e) {
Assert.fail(e.getMessage());
}
out.close();
}
use of com.emc.storageos.api.service.impl.resource.utils.MarshallingExcetion in project coprhd-controller by CoprHD.
the class JSONEventMarchallerTest method testJsonEventMarshallingForIOExceptions.
@Test
public void testJsonEventMarshallingForIOExceptions() throws URISyntaxException, IOException, MarshallingExcetion {
deleteIfExists(JsonTestOutputFile);
JSONEventMarshaller jm = new JSONEventMarshaller();
Event evt = new Event();
evt.setEventId("eid1");
evt.setTenantId(new URI("http://tenant.1"));
OutputStream output = new OutputStream() {
private StringBuilder string = new StringBuilder();
@Override
public void write(int b) throws IOException {
this.string.append((char) b);
}
public String toString() {
return this.string.toString();
}
};
try {
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(output));
writer.close();
jm.header(writer);
} catch (MarshallingExcetion e) {
Assert.assertTrue(e.toString().contains("JSON head Streaming failed"));
}
try {
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(output));
writer.close();
jm.marshal(evt, writer);
} catch (MarshallingExcetion e) {
Assert.assertTrue(e.toString().contains("JSON streaming failed"));
}
try {
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(output));
writer.close();
jm.tailer(writer);
} catch (MarshallingExcetion e) {
Assert.assertTrue(e.toString().contains("JSON tail Streaming failed"));
}
deleteIfExists(JsonTestOutputFile);
}
use of com.emc.storageos.api.service.impl.resource.utils.MarshallingExcetion in project coprhd-controller by CoprHD.
the class XMLAuditLogMarshallerTest method testXmlAuditLogMarshallingForIOExceptions.
@Test
public void testXmlAuditLogMarshallingForIOExceptions() throws URISyntaxException, IOException, MarshallingExcetion {
deleteIfExists(XmlTestOutputFile);
XMLAuditLogMarshaller jm = new XMLAuditLogMarshaller();
AuditLog log = new AuditLog();
log.setProductId("productId.2");
log.setTenantId(new URI("http://tenant.2"));
log.setUserId(new URI("http://user.2"));
log.setServiceType("serviceType.2");
log.setAuditType("auditType.2");
log.setDescription("description.2");
log.setOperationalStatus("operationalStatus.2");
OutputStream output = new OutputStream() {
private StringBuilder string = new StringBuilder();
@Override
public void write(int b) throws IOException {
this.string.append((char) b);
}
public String toString() {
return this.string.toString();
}
};
try {
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(output));
writer.close();
jm.header(writer);
} catch (MarshallingExcetion e) {
Assert.assertTrue(e.toString().contains("XML head Streaming failed"));
}
try {
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(output));
writer.close();
jm.marshal(log, writer);
} catch (MarshallingExcetion e) {
Assert.assertTrue(e.toString().contains("XML Streaming Error"));
}
try {
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(output));
writer.close();
jm.tailer(writer);
} catch (MarshallingExcetion e) {
Assert.assertTrue(e.toString().contains("XML tail Streaming failed"));
}
deleteIfExists(XmlTestOutputFile);
}
use of com.emc.storageos.api.service.impl.resource.utils.MarshallingExcetion in project coprhd-controller by CoprHD.
the class XMLEventMarshallerTest method testXmlEventMarshallingForIOExceptions.
@Test
public void testXmlEventMarshallingForIOExceptions() throws URISyntaxException, IOException, MarshallingExcetion {
deleteIfExists(XmlTestOutputFile);
XMLEventMarshaller jm = new XMLEventMarshaller();
Event evt = new Event();
evt.setEventId("eid1");
evt.setTenantId(new URI("http://tenant.1"));
OutputStream output = new OutputStream() {
private StringBuilder string = new StringBuilder();
@Override
public void write(int b) throws IOException {
this.string.append((char) b);
}
public String toString() {
return this.string.toString();
}
};
try {
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(output));
writer.close();
jm.header(writer);
} catch (MarshallingExcetion e) {
Assert.assertTrue(e.toString().contains("XML head Streaming failed"));
}
try {
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(output));
writer.close();
jm.marshal(evt, writer);
} catch (MarshallingExcetion e) {
Assert.assertTrue(e.toString().contains("XML Streaming Error"));
}
try {
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(output));
writer.close();
jm.tailer(writer);
} catch (MarshallingExcetion e) {
Assert.assertTrue(e.toString().contains("XML tail Streaming failed"));
}
deleteIfExists(XmlTestOutputFile);
}
Aggregations