Search in sources :

Example 6 with MarshallingExcetion

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();
}
Also used : MarshallingExcetion(com.emc.storageos.api.service.impl.resource.utils.MarshallingExcetion) DbAuditLogRetriever(com.emc.storageos.api.service.impl.resource.utils.DbAuditLogRetriever) MediaType(javax.ws.rs.core.MediaType) DummyDBClient(com.emc.storageos.api.service.utils.DummyDBClient) AuditLogRequest(com.emc.storageos.security.audit.AuditLogRequest) RetryableDatabaseException(com.emc.storageos.db.exceptions.RetryableDatabaseException) Test(org.junit.Test)

Example 7 with MarshallingExcetion

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);
}
Also used : MarshallingExcetion(com.emc.storageos.api.service.impl.resource.utils.MarshallingExcetion) JSONEventMarshaller(com.emc.storageos.api.service.impl.resource.utils.JSONEventMarshaller) OutputStream(java.io.OutputStream) Event(com.emc.storageos.db.client.model.Event) OutputStreamWriter(java.io.OutputStreamWriter) URI(java.net.URI) BufferedWriter(java.io.BufferedWriter) Test(org.junit.Test)

Example 8 with MarshallingExcetion

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);
}
Also used : MarshallingExcetion(com.emc.storageos.api.service.impl.resource.utils.MarshallingExcetion) OutputStream(java.io.OutputStream) OutputStreamWriter(java.io.OutputStreamWriter) XMLAuditLogMarshaller(com.emc.storageos.api.service.impl.resource.utils.XMLAuditLogMarshaller) URI(java.net.URI) AuditLog(com.emc.storageos.db.client.model.AuditLog) BufferedWriter(java.io.BufferedWriter) Test(org.junit.Test)

Example 9 with MarshallingExcetion

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);
}
Also used : MarshallingExcetion(com.emc.storageos.api.service.impl.resource.utils.MarshallingExcetion) XMLEventMarshaller(com.emc.storageos.api.service.impl.resource.utils.XMLEventMarshaller) OutputStream(java.io.OutputStream) Event(com.emc.storageos.db.client.model.Event) OutputStreamWriter(java.io.OutputStreamWriter) URI(java.net.URI) BufferedWriter(java.io.BufferedWriter) Test(org.junit.Test)

Aggregations

MarshallingExcetion (com.emc.storageos.api.service.impl.resource.utils.MarshallingExcetion)9 Test (org.junit.Test)8 URI (java.net.URI)5 DbAuditLogRetriever (com.emc.storageos.api.service.impl.resource.utils.DbAuditLogRetriever)4 DummyDBClient (com.emc.storageos.api.service.utils.DummyDBClient)4 AuditLogRequest (com.emc.storageos.security.audit.AuditLogRequest)4 BufferedWriter (java.io.BufferedWriter)4 OutputStream (java.io.OutputStream)4 OutputStreamWriter (java.io.OutputStreamWriter)4 MediaType (javax.ws.rs.core.MediaType)4 AuditLog (com.emc.storageos.db.client.model.AuditLog)3 Event (com.emc.storageos.db.client.model.Event)3 AuditLogs (com.emc.storageos.api.service.utils.AuditLogs)2 JSONAuditLogMarshaller (com.emc.storageos.api.service.impl.resource.utils.JSONAuditLogMarshaller)1 JSONEventMarshaller (com.emc.storageos.api.service.impl.resource.utils.JSONEventMarshaller)1 XMLAuditLogMarshaller (com.emc.storageos.api.service.impl.resource.utils.XMLAuditLogMarshaller)1 XMLEventMarshaller (com.emc.storageos.api.service.impl.resource.utils.XMLEventMarshaller)1 Constraint (com.emc.storageos.db.client.constraint.Constraint)1 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 Stat (com.emc.storageos.db.client.model.Stat)1