不知道为什么我收到非法字符错误

时间:2011-02-06 21:36:30

标签: java

由于某些原因,在testEmployee方法中,我收到了一些非法的错误消息。

我查看了代码,但找不到任何语法上的错误。

任何帮助都会非常感谢!

/*
 * 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 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());

    }

2 个答案:

答案 0 :(得分:4)

您似乎使用'花哨'引号()而非正常引号("

PS如果 Matt 是正确的,请不要使用Word编辑您的程序。有很多IDE,但即使是Notepad也会更容易。

答案 1 :(得分:3)

片段

s]e3.getName1()

(最后一行)看起来不对:删除“s]”片段。

编辑:您还缺少代码末尾的类的右括号。