package src.hibernatebb.unittests;

import junit.framework.TestCase;
import junit.framework.Assert;

import src.hibernatebb.discussion.Post;
import src.hibernatebb.discussion.Topic;
import src.hibernatebb.discussion.User;
import src.hibernatebb.discussion.BoardManager;

import java.util.Date;

public class PostTest extends TestCase {
	Topic t = new Topic();
	Post p1,p2,p3;
	User u1 = new User("p$Money","JOOKY");
	BoardManager bm = new BoardManager();
	
	protected void setUp() throws Exception {
		super.setUp();
		bm.saveUser(u1);
	}

	protected void tearDown() throws Exception {
		super.tearDown();
	}

	public void testPostLoad() throws Exception {
		p1 = new Post();
		p1.setSubject("The State of the Jooky");
		p1.setBody("My fellows, how have we let the Jooky come to this.  Why have we let it sink so low?");
		p1.setPoster(u1);
		p1.setTimestamp(new Date());
		
		bm.savePost(p1);
		
		p2 = bm.loadPost(p1.getID());
		
		Assert.assertEquals(p1.getID(),p2.getID());
		Assert.assertEquals(p1.getSubject(),p2.getSubject());
		Assert.assertEquals(p1.getBody(),p2.getBody());
		
	}

	
}
