use of org.apache.qpid.disttest.json.JsonHandler in project qpid-broker-j by apache.
the class JmsMessageAdaptor method messageToCommand.
public static Command messageToCommand(final Message jmsMessage) {
Command command = null;
try {
final CommandType commandType = CommandType.valueOf(jmsMessage.getStringProperty(DistributedTestConstants.MSG_COMMAND_PROPERTY));
final JsonHandler jsonHandler = new JsonHandler();
command = jsonHandler.unmarshall(jmsMessage.getStringProperty(DistributedTestConstants.MSG_JSON_PROPERTY), getCommandClassFromType(commandType));
} catch (final JMSException | IOException e) {
throw new DistributedTestException("Unable to convert JMS message " + jmsMessage + " to command object", e);
}
return command;
}
use of org.apache.qpid.disttest.json.JsonHandler in project qpid-broker-j by apache.
the class JsonHandlerTest method setUp.
@Before
public void setUp() throws Exception {
_jsonHandler = new JsonHandler();
_testCommand = new SendChristmasCards(CommandType.START_TEST, Collections.singletonMap(SendChristmasCards.CardType.FUNNY, 5));
_testCommand._persons = Arrays.asList(new Person("Phil"), new Person("Andrew"));
}
use of org.apache.qpid.disttest.json.JsonHandler in project qpid-broker-j by apache.
the class JmsMessageAdaptor method commandToMessage.
public static Message commandToMessage(final Session session, final Command command) {
Message jmsMessage = null;
try {
jmsMessage = session.createMessage();
jmsMessage.setStringProperty(DistributedTestConstants.MSG_COMMAND_PROPERTY, command.getType().name());
final JsonHandler jsonHandler = new JsonHandler();
jmsMessage.setStringProperty(DistributedTestConstants.MSG_JSON_PROPERTY, jsonHandler.marshall(command));
} catch (final JMSException | IOException e) {
throw new DistributedTestException("Unable to convert command " + command + " to JMS Message", e);
}
return jmsMessage;
}
Aggregations