package org.nthx.pat.demo;
import org.nthx.pat.Persisteble;
import org.apache.log4j.Logger;
public class Driver
{
private static Forum staticForum;
public static void main(String[] args)
{
Forum forum = new Forum();
log.debug("-= Finished creating Forum object =-");
if (null == staticForum)
throw new IllegalStateException("PAT.root_injected not injected");
String nthxId = "nthx" + getRandomId(forum);
String andrzejkId = "andrzejk" + getRandomId(forum);
forum.newUser("Tomasz", "Nazar", nthxId, "http://www.ii.uni.wroc.pl/~nthx/");
forum.newUser("Andrzej", "Krzywda", andrzejkId, "szachy.pl/andrzej");
User nthx = forum.getUserByLogin(nthxId);
User andrzejk = forum.getUserByLogin(andrzejkId);
String subject = "PAT: " + getRandomTopic(forum);
if (System.getProperty("take.snapshot", "true").equals("true"))
((Persisteble)forum).takeSnapshot();
forum.newTopic(subject, nthx, "Already done...");
Topic pat = forum.getTopic(subject);
forum.newMessage(andrzejk, pat, "Hmm, But PAT is list chess' state, isn't it?");
forum.newMessage(nthx, pat, "And yes, and no :)");
log.debug("Users: " + forum.getUsers().size());
log.debug("Topic mesgs: " + pat.getMessages().size()
+ " out of: " + forum.getAllMessagesNumber());
}
private static int getRandomTopic(Forum forum)
{
return forum.getTopics().size();
}
private static int getRandomId(Forum forum)
{
return forum.getUsers().size();
}
private static Logger log = Logger.getLogger("pat");
}