{
// doesn't make any sense to run in remote mode, since we'll start our won external VM
return;
}
Server localServer = null;
File serialized = null;
try
{
localServer = new LocalTestServer();
localServer.start("all", true);
localServer.deployQueue("Queue", null, false);
// lookup the connection factory and the queue which we'll send to the client VM via a
// serialized instances saved in file
InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());
ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
Queue queue = (Queue)ic.lookup("/queue/Queue");
serialized = writeToFile(cf, queue);
// spawn a JVM that creates a JMS client, which sends a test message
Process p = spawnVM(serialized);
// read the message from the queue
Connection conn = cf.createConnection();
conn.start();
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer cons = sess.createConsumer(queue);
TextMessage tm = (TextMessage)cons.receive(5000);
assertNotNull(tm);
assertEquals(MESSAGE_TEXT, tm.getText());
// the client VM should exit by itself. If it doesn't, that means we have a problem
// and the test will timeout
log.info("waiting for the client VM to exit ...");
p.waitFor();
assertEquals(0, p.exitValue());
}
finally
{
// TODO delete the file
if (serialized != null)
{
serialized.delete();
}
localServer.undeployDestination(true, "Queue");
localServer.stopServerPeer();
localServer.stop();
}
}