package com.gewb.mavenTest;
import java.util.HashMap;
import java.util.Map;
import org.easymock.EasyMock;
import org.junit.Test;
import com.gewb.mavenTest.entity.Parent;
import com.gewb.mavenTest.entity.Student;
/**
* Unit test for simple App.
*/
public class AppTest {
@Test
public void testApp() throws NoSuchFieldException, SecurityException, NoSuchMethodException {
/*
* Family familyMock = EasyMock.createMock(Family.class);
* EasyMock.expect(familyMock.getAddress()).andReturn("上海");
* EasyMock.replay(familyMock);
*
* Student student = new Student(); student.setFamilyImpl(familyMock); Family
* familyImpl = student.getFamilyImpl(); String address =
* familyImpl.getAddress(); System.out.println(address);
* EasyMock.verify(familyMock);
*/
Parent parentMock = EasyMock.createMock(Parent.class);
Map<String, Object> map = new HashMap<>();
map.put("test1", "hello");
map.put("test2", "world");
//
// EasyMock.expect(parentMock.getSysCode()).andReturn(map);
// EasyMock.replay(parentMock);
Student studentMock = EasyMock.createMock(Student.class);
EasyMock.expect(studentMock.execute(EasyMock.anyString())).andReturn("def");
EasyMock.expect(studentMock.execute(null)).andThrow(new NullPointerException());
EasyMock.replay(studentMock);
String execute = studentMock.execute("");
studentMock.execute(null);
System.out.println(execute);
EasyMock.verify(studentMock);
}
}