For some reason in the testEmployee method I am getting weird error messages saying illegal character.
I've looked at the code but can't find anything syntactically wrong with it.
Any help would be great thanks!
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import ttp.Cache;
import ttp.DataException;
import ttp.EmployeeDAO;
import ttp.Employee;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* @author ericrea
*/
public class Tester {
public Tester() {
}
@BeforeClass
public static void setUpClass() throws Exception {
}
@AfterClass
public static void tearDownClass() throws Exception {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
// TODO add test methods here.
// The methods must be annotated with annotation @Test. For example:
//
// @Test
// public void hello() {}
// /** Test the Skeleton BO/DAO */
// @Test
// public void TestSkeleton() throws Exception {
// Skeleton s = SkeletonDAO.getInstance().create(“skeleton1”);
// s.save();
//
// // since skeleton1 is in the Cache, this tests reading from the cache
// Skeleton s2 = SkeletonDAO.getInstance().read(“skeleton1”);
// assertSame(s, s2);
//
// // now clear the cache (you’d never do this in the real world)
// // then we can test reading from the database
// Cache.getInstance().clear();
// Skeleton s3 = SkeletonDAO.getInstance().read(“skeleton1”);
// assertEquals(s.getId(), s3.getId());
// //assertEquals(s.getSomething(), s3.getSomething());
//
// // keep testing more methods, BOs, and DAOs
// }//TestSkeleton
// //5. Right-click the file and run the file. You’ll see it test. It will obviously have errors
// //because Skeleton isn’t a real BO/DAO.
// //6. Note in the above code the “assertEquals” methods. That is how you test that two things are equals.
@Test
public void TestEmployee() throws DataException {
Employee e = EmployeeDAO.getInstance().create(“Employee1”);
e.save();
// since skeleton1 is in the Cache, this tests reading from the cache
Employee e2 = EmployeeDAO.getInstance().read(“Employee1”);
assertSame(e, e2);
// now clear the cache (you’d never do this in 开发者_JS百科the real world)
// then we can test reading from the database
Cache.getInstance().clear();
Employee e3 = EmployeeDAO.getInstance().read(“Employee1”);
assertEquals(e.getId(), e3.getId());
assertEquals(e.getName1(), s]e3.getName1());
}
You seem to use 'fancy' quotes (“
) instead of normal ones ("
)
PS If Matt is right, please do not use Word to edit your programs. There're lots of IDEs, but even Notepad would be easier.
The fragment
s]e3.getName1()
(last line) doesn't look right: remove the "s]" fragment.
Edit: You are also missing the closing parenthesis for the class at the end of the code.
精彩评论