System.out.println("Done");
}
private static void testREST()
{
RESTInterfaceV1 client = null;
try
{
client = ProxyFactory.create(
RESTInterfaceV1.class,
"http://localhost:8080/TopicIndex/seam/resource/rest");
TopicV1 newTopic = new TopicV1();
newTopic.setTitleExplicit("New Topic");
newTopic.setXmlExplicit("");
// Creating a new topic will work as it initialises all the collections for the REST Entity (via createRESTEntityFromDBEntity()) before committing the transaction.
TopicV1 returnedTopic = client.createJSONTopic("", newTopic);
if (returnedTopic == null) throw new Exception("Unable to create a new topic");
returnedTopic.setTitleExplicit("Updated Topic");
// Updating the topic will fail as it attempts to create the REST entity from un-initialised collections after the transaction has been committed.
TopicV1 updatedTopic = client.updateJSONTopic("", returnedTopic);
if (updatedTopic == null) throw new Exception("Unable to update an existing topic");
}
catch (final Exception ex)
{
System.out.println(ex.toString());