Search in sources :

Example 26 with AdminCommandContextImpl

use of org.glassfish.api.admin.AdminCommandContextImpl in project Payara by payara.

the class AdminCommandContextTest method testSerialization.

@Test
public void testSerialization() throws IOException, ClassNotFoundException {
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(os);
    ActionReport report = new PlainTextActionReporter();
    AdminCommandContext context = new AdminCommandContextImpl(null, /* logger */
    report);
    report.setFailureCause(new RuntimeException("Test"));
    oos.writeObject(context);
    ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
    ObjectInputStream ois = new ObjectInputStream(is);
    AdminCommandContext restored = (AdminCommandContextImpl) ois.readObject();
    assertEquals("failureCause", "Test", restored.getActionReport().getFailureCause().getMessage());
// context.setPayload
}
Also used : AdminCommandContextImpl(org.glassfish.api.admin.AdminCommandContextImpl) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) ActionReport(org.glassfish.api.ActionReport) PlainTextActionReporter(com.sun.enterprise.v3.common.PlainTextActionReporter) AdminCommandContext(org.glassfish.api.admin.AdminCommandContext) ObjectInputStream(java.io.ObjectInputStream) Test(org.junit.Test)

Aggregations

AdminCommandContextImpl (org.glassfish.api.admin.AdminCommandContextImpl)26 PropsFileActionReporter (com.sun.enterprise.v3.common.PropsFileActionReporter)23 ParameterMap (org.glassfish.api.admin.ParameterMap)18 Before (org.junit.Before)15 CommandRunner (org.glassfish.api.admin.CommandRunner)13 Test (org.junit.Test)10 ConfigApiTest (org.glassfish.tests.utils.ConfigApiTest)9 MessagePart (org.glassfish.api.ActionReport.MessagePart)7 Domain (com.sun.enterprise.config.serverbeans.Domain)4 Resource (com.sun.enterprise.config.serverbeans.Resource)4 Resources (com.sun.enterprise.config.serverbeans.Resources)3 ActionReport (org.glassfish.api.ActionReport)3 AdminCommandContext (org.glassfish.api.admin.AdminCommandContext)3 IiopService (org.glassfish.orb.admin.config.IiopService)3 PlainTextActionReporter (com.sun.enterprise.v3.common.PlainTextActionReporter)2 ArrayList (java.util.ArrayList)2 Ignore (org.junit.Ignore)2 ModulesRegistry (com.sun.enterprise.module.ModulesRegistry)1 RestartDomainCommand (com.sun.enterprise.v3.admin.RestartDomainCommand)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1