/** Tests Service.callMethod(). */
public void testCallMethod() throws Exception {
FooRequest fooRequest = FooRequest.newBuilder().build();
BarRequest barRequest = BarRequest.newBuilder().build();
MockCallback<Message> fooCallback = new MockCallback<Message>();
MockCallback<Message> barCallback = new MockCallback<Message>();
TestService mockService = control.createMock(TestService.class);
mockService.foo(EasyMock.same(mockController), EasyMock.same(fooRequest),
this.<FooResponse>wrapsCallback(fooCallback));
mockService.bar(EasyMock.same(mockController), EasyMock.same(barRequest),
this.<BarResponse>wrapsCallback(barCallback));
control.replay();
mockService.callMethod(fooDescriptor, mockController,
fooRequest, fooCallback);
mockService.callMethod(barDescriptor, mockController,
barRequest, barCallback);
control.verify();
}
java类org.easymock.classextension.EasyMock的实例源码
ServiceTest.java 文件源码
项目:sstore-soft
阅读 26
收藏 0
点赞 0
评论 0
ServiceTest.java 文件源码
项目:s-store
阅读 24
收藏 0
点赞 0
评论 0
/** Tests Service.callMethod(). */
public void testCallMethod() throws Exception {
FooRequest fooRequest = FooRequest.newBuilder().build();
BarRequest barRequest = BarRequest.newBuilder().build();
MockCallback<Message> fooCallback = new MockCallback<Message>();
MockCallback<Message> barCallback = new MockCallback<Message>();
TestService mockService = control.createMock(TestService.class);
mockService.foo(EasyMock.same(mockController), EasyMock.same(fooRequest),
this.<FooResponse>wrapsCallback(fooCallback));
mockService.bar(EasyMock.same(mockController), EasyMock.same(barRequest),
this.<BarResponse>wrapsCallback(barCallback));
control.replay();
mockService.callMethod(fooDescriptor, mockController,
fooRequest, fooCallback);
mockService.callMethod(barDescriptor, mockController,
barRequest, barCallback);
control.verify();
}
ServiceTest.java 文件源码
项目:protobuf-java-shaded-261
阅读 25
收藏 0
点赞 0
评论 0
/** Tests Service.callMethod(). */
public void testCallMethod() throws Exception {
FooRequest fooRequest = FooRequest.newBuilder().build();
BarRequest barRequest = BarRequest.newBuilder().build();
MockCallback<Message> fooCallback = new MockCallback<Message>();
MockCallback<Message> barCallback = new MockCallback<Message>();
TestService mockService = control.createMock(TestService.class);
mockService.foo(EasyMock.same(mockController), EasyMock.same(fooRequest),
this.<FooResponse>wrapsCallback(fooCallback));
mockService.bar(EasyMock.same(mockController), EasyMock.same(barRequest),
this.<BarResponse>wrapsCallback(barCallback));
control.replay();
mockService.callMethod(fooDescriptor, mockController,
fooRequest, fooCallback);
mockService.callMethod(barDescriptor, mockController,
barRequest, barCallback);
control.verify();
}
ServiceTest.java 文件源码
项目:protobuf-java-shaded-261
阅读 22
收藏 0
点赞 0
评论 0
public void testNewReflectiveBlockingService() throws ServiceException {
ServiceWithNoOuter.BlockingInterface impl =
control.createMock(ServiceWithNoOuter.BlockingInterface.class);
RpcController controller = control.createMock(RpcController.class);
BlockingService service =
ServiceWithNoOuter.newReflectiveBlockingService(impl);
MethodDescriptor fooMethod =
ServiceWithNoOuter.getDescriptor().findMethodByName("Foo");
MessageWithNoOuter request = MessageWithNoOuter.getDefaultInstance();
TestAllTypes expectedResponse = TestAllTypes.getDefaultInstance();
EasyMock.expect(impl.foo(EasyMock.same(controller), EasyMock.same(request)))
.andReturn(expectedResponse);
control.replay();
Message response =
service.callBlockingMethod(fooMethod, controller, request);
assertEquals(expectedResponse, response);
control.verify();
}
LazyMessageLiteTest.java 文件源码
项目:protobuf-java-shaded-261
阅读 14
收藏 0
点赞 0
评论 0
public void testLaziness() throws InvalidProtocolBufferException {
LazyInnerMessageLite inner = LazyInnerMessageLite.newBuilder()
.setNum(2)
.build();
LazyMessageLite outer = LazyMessageLite.newBuilder()
.setNum(1)
.setInner(inner)
.setOneofInner(inner)
.build();
ByteString bytes = outer.toByteString();
// The parser for inner / oneofInner message shouldn't be used if
// getInner / getOneofInner is not called.
LazyInnerMessageLite.PARSER = EasyMock.createStrictMock(Parser.class);
EasyMock.replay(LazyInnerMessageLite.PARSER);
LazyMessageLite deserialized = LazyMessageLite.parseFrom(bytes);
assertEquals(1, deserialized.getNum());
assertEquals(421, deserialized.getNumWithDefault());
EasyMock.verify(LazyInnerMessageLite.PARSER);
}
HttpServletRequestAdapterTest.java 文件源码
项目:opengse
阅读 13
收藏 0
点赞 0
评论 0
@Test
public void testSetCharacterEncoding_allowsExceptionToPassBack()
throws UnsupportedEncodingException {
final UnsupportedEncodingException expected
= new UnsupportedEncodingException();
mockSubset.setCharacterEncoding(EasyMock.eq(VALUE));
EasyMock.expectLastCall().andThrow(expected);
EasyMock.replay(mockSubset);
try {
adapter.setCharacterEncoding(VALUE);
fail("Should pass exception through");
} catch (UnsupportedEncodingException actual) {
assertThat(actual, sameInstance(expected));
}
EasyMock.verify(mockSubset);
}
QueueExtractorTest.java 文件源码
项目:opengse
阅读 13
收藏 0
点赞 0
评论 0
public void testRunCallsQueuedRunnables() throws Exception {
RunnableQueue q = EasyMock.createMock(RunnableQueue.class);
Runnable task1 = EasyMock.createMock(Runnable.class);
Runnable task2 = EasyMock.createMock(Runnable.class);
EasyMock.expect(q.remove()).andReturn(task1);
task1.run();
EasyMock.expectLastCall();
EasyMock.expect(q.remove()).andReturn(task2);
task2.run();
EasyMock.expectLastCall();
EasyMock.expect(q.remove()).andThrow(new InterruptedException());
EasyMock.replay(q, task1, task2);
QueueExtractor extractor = new QueueExtractor(q);
extractor.run();
EasyMock.verify(q, task1, task2);
}
WorkerThreadTest.java 文件源码
项目:opengse
阅读 15
收藏 0
点赞 0
评论 0
public void testRun() throws Exception {
RunnableQueue q = EasyMock.createMock(RunnableQueue.class);
Runnable task1 = EasyMock.createMock(Runnable.class);
Runnable task2 = EasyMock.createMock(Runnable.class);
EasyMock.expect(q.remove()).andReturn(task1);
task1.run();
EasyMock.expectLastCall();
EasyMock.expect(q.remove()).andReturn(task2);
task2.run();
EasyMock.expectLastCall();
EasyMock.expect(q.remove()).andThrow(new InterruptedException());
EasyMock.replay(q, task1, task2);
WorkerThread worker = new WorkerThread(q, "test thread");
worker.run();
EasyMock.verify(q, task1, task2);
}
TypelessFeedServerClientTest.java 文件源码
项目:google-feedserver
阅读 16
收藏 0
点赞 0
评论 0
public void testGetEntryInvalidUrl() throws Exception {
// Setup
URL badUrl = new URL("http://badUrl");
String errorMsg = "invalid URL";
EasyMock.expect(mockService.getEntry(badUrl, FeedServerEntry.class)).andThrow(
new IOException(errorMsg));
EasyMock.replay(mockService);
// Perform Test
try {
@SuppressWarnings("unused")
Map<String, Object> fetchedMap = feedServerClient.getEntry(badUrl);
} catch (FeedServerClientException e) {
assertTrue(e.getCause().getMessage().equals(errorMsg));
EasyMock.verify(mockService);
return;
}
fail("Did not get FeedServerClientException");
}
ServiceTest.java 文件源码
项目:vsminecraft
阅读 22
收藏 0
点赞 0
评论 0
/** Tests Service.callMethod(). */
public void testCallMethod() throws Exception {
FooRequest fooRequest = FooRequest.newBuilder().build();
BarRequest barRequest = BarRequest.newBuilder().build();
MockCallback<Message> fooCallback = new MockCallback<Message>();
MockCallback<Message> barCallback = new MockCallback<Message>();
TestService mockService = control.createMock(TestService.class);
mockService.foo(EasyMock.same(mockController), EasyMock.same(fooRequest),
this.<FooResponse>wrapsCallback(fooCallback));
mockService.bar(EasyMock.same(mockController), EasyMock.same(barRequest),
this.<BarResponse>wrapsCallback(barCallback));
control.replay();
mockService.callMethod(fooDescriptor, mockController,
fooRequest, fooCallback);
mockService.callMethod(barDescriptor, mockController,
barRequest, barCallback);
control.verify();
}
ServiceTest.java 文件源码
项目:vsminecraft
阅读 28
收藏 0
点赞 0
评论 0
public void testNewReflectiveBlockingService() throws ServiceException {
ServiceWithNoOuter.BlockingInterface impl =
control.createMock(ServiceWithNoOuter.BlockingInterface.class);
RpcController controller = control.createMock(RpcController.class);
BlockingService service =
ServiceWithNoOuter.newReflectiveBlockingService(impl);
MethodDescriptor fooMethod =
ServiceWithNoOuter.getDescriptor().findMethodByName("Foo");
MessageWithNoOuter request = MessageWithNoOuter.getDefaultInstance();
TestAllTypes expectedResponse = TestAllTypes.getDefaultInstance();
EasyMock.expect(impl.foo(EasyMock.same(controller), EasyMock.same(request)))
.andReturn(expectedResponse);
control.replay();
Message response =
service.callBlockingMethod(fooMethod, controller, request);
assertEquals(expectedResponse, response);
control.verify();
}
LazyMessageLiteTest.java 文件源码
项目:vsminecraft
阅读 13
收藏 0
点赞 0
评论 0
public void testLaziness() throws InvalidProtocolBufferException {
LazyInnerMessageLite inner = LazyInnerMessageLite.newBuilder()
.setNum(2)
.build();
LazyMessageLite outer = LazyMessageLite.newBuilder()
.setNum(1)
.setInner(inner)
.setOneofInner(inner)
.build();
ByteString bytes = outer.toByteString();
// The parser for inner / oneofInner message shouldn't be used if
// getInner / getOneofInner is not called.
LazyInnerMessageLite.PARSER = EasyMock.createStrictMock(Parser.class);
EasyMock.replay(LazyInnerMessageLite.PARSER);
LazyMessageLite deserialized = LazyMessageLite.parseFrom(bytes);
assertEquals(1, deserialized.getNum());
assertEquals(421, deserialized.getNumWithDefault());
EasyMock.verify(LazyInnerMessageLite.PARSER);
}
ResourceConnectionInfoWrapperTest.java 文件源码
项目:google-feedserver
阅读 22
收藏 0
点赞 0
评论 0
public void testCheckAccessSuccessOnRetrieveEntry() throws Exception {
String[][] principalx = new String[][] {
new String[]{USER1_EMAIL}, new String[]{USER1_EMAIL, USER2_EMAIL}};
for (String[] principals: principalx) {
prepare(new AdapterCall() {
@Override
public void invoke(AbstractManagedCollectionAdapter adapter)
throws FeedServerAdapterException {
EasyMock.expect(adapter.retrieveEntry(isA(RequestContext.class), isA(Object.class)))
.andReturn(null);
}
});
ResourceConnectionInfoWrapper aclWrapper =
new ResourceConnectionInfoWrapper(targetAdapterMock, getWrapperConfig(
AuthorizedEntity.OPERATION_RETRIEVE, principals));
aclWrapper.retrieveEntry(requestMock, "123");
finish();
}
}
ResourceConnectionInfoWrapperTest.java 文件源码
项目:google-feedserver
阅读 13
收藏 0
点赞 0
评论 0
protected void prepare(AdapterCall adapterCall) throws Exception {
targetAdapterMock = EasyMock.createMock(AbstractManagedCollectionAdapter.class);
requestMock = EasyMock.createMock(RequestContext.class);
userInfoMock = EasyMock.createMock(UserInfo.class);
entryMock = EasyMock.createMock(Entry.class);
EasyMock.expect(targetAdapterMock.getAbdera()).andReturn(null);
EasyMock.expect(targetAdapterMock.getConfiguration()).andReturn(null);
EasyMock.expect(requestMock.getAttribute(
RequestContext.Scope.REQUEST, AbstractManagedCollectionAdapter.USER_INFO))
.andReturn(userInfoMock);
EasyMock.expect(userInfoMock.getEmail()).andReturn(USER1_EMAIL);
adapterCall.invoke(targetAdapterMock);
EasyMock.replay(targetAdapterMock);
EasyMock.replay(requestMock);
EasyMock.replay(userInfoMock);
EasyMock.replay(entryMock);
}
FeedServerClientTest.java 文件源码
项目:google-feedserver
阅读 14
收藏 0
点赞 0
评论 0
public void testGetEntryInvalidUrl() throws Exception {
// Setup
URL badUrl = new URL("http://badUrl");
String errorMsg = "invalid URL";
EasyMock.expect(mockService.getEntry(badUrl, FeedServerEntry.class)).andThrow(
new IOException(errorMsg));
EasyMock.replay(mockService);
// Perform Test
try {
feedServerClient.getEntity(badUrl);
} catch (FeedServerClientException e) {
assertTrue(e.getCause().getMessage().equals(errorMsg));
EasyMock.verify(mockService);
return;
}
fail("Did not get FeedServerClientException");
}
ServiceTest.java 文件源码
项目:sstore-soft
阅读 25
收藏 0
点赞 0
评论 0
/** Tests generated stubs. */
public void testStub() throws Exception {
FooRequest fooRequest = FooRequest.newBuilder().build();
BarRequest barRequest = BarRequest.newBuilder().build();
MockCallback<FooResponse> fooCallback = new MockCallback<FooResponse>();
MockCallback<BarResponse> barCallback = new MockCallback<BarResponse>();
RpcChannel mockChannel = control.createMock(RpcChannel.class);
TestService stub = TestService.newStub(mockChannel);
mockChannel.callMethod(
EasyMock.same(fooDescriptor),
EasyMock.same(mockController),
EasyMock.same(fooRequest),
EasyMock.same(FooResponse.getDefaultInstance()),
this.<Message>wrapsCallback(fooCallback));
mockChannel.callMethod(
EasyMock.same(barDescriptor),
EasyMock.same(mockController),
EasyMock.same(barRequest),
EasyMock.same(BarResponse.getDefaultInstance()),
this.<Message>wrapsCallback(barCallback));
control.replay();
stub.foo(mockController, fooRequest, fooCallback);
stub.bar(mockController, barRequest, barCallback);
control.verify();
}
ServiceTest.java 文件源码
项目:sstore-soft
阅读 24
收藏 0
点赞 0
评论 0
/** Tests generated blocking stubs. */
public void testBlockingStub() throws Exception {
FooRequest fooRequest = FooRequest.newBuilder().build();
BarRequest barRequest = BarRequest.newBuilder().build();
BlockingRpcChannel mockChannel =
control.createMock(BlockingRpcChannel.class);
TestService.BlockingInterface stub =
TestService.newBlockingStub(mockChannel);
FooResponse fooResponse = FooResponse.newBuilder().build();
BarResponse barResponse = BarResponse.newBuilder().build();
EasyMock.expect(mockChannel.callBlockingMethod(
EasyMock.same(fooDescriptor),
EasyMock.same(mockController),
EasyMock.same(fooRequest),
EasyMock.same(FooResponse.getDefaultInstance()))).andReturn(fooResponse);
EasyMock.expect(mockChannel.callBlockingMethod(
EasyMock.same(barDescriptor),
EasyMock.same(mockController),
EasyMock.same(barRequest),
EasyMock.same(BarResponse.getDefaultInstance()))).andReturn(barResponse);
control.replay();
assertSame(fooResponse, stub.foo(mockController, fooRequest));
assertSame(barResponse, stub.bar(mockController, barRequest));
control.verify();
}
ServiceTest.java 文件源码
项目:sstore-soft
阅读 26
收藏 0
点赞 0
评论 0
public void testNewReflectiveService() {
ServiceWithNoOuter.Interface impl =
control.createMock(ServiceWithNoOuter.Interface.class);
RpcController controller = control.createMock(RpcController.class);
Service service = ServiceWithNoOuter.newReflectiveService(impl);
MethodDescriptor fooMethod =
ServiceWithNoOuter.getDescriptor().findMethodByName("Foo");
MessageWithNoOuter request = MessageWithNoOuter.getDefaultInstance();
RpcCallback<Message> callback = new RpcCallback<Message>() {
public void run(Message parameter) {
// No reason this should be run.
fail();
}
};
RpcCallback<TestAllTypes> specializedCallback =
RpcUtil.specializeCallback(callback);
impl.foo(EasyMock.same(controller), EasyMock.same(request),
EasyMock.same(specializedCallback));
EasyMock.expectLastCall();
control.replay();
service.callMethod(fooMethod, controller, request, callback);
control.verify();
}
ServiceTest.java 文件源码
项目:sstore-soft
阅读 21
收藏 0
点赞 0
评论 0
public void testNewReflectiveBlockingService() throws ServiceException {
ServiceWithNoOuter.BlockingInterface impl =
control.createMock(ServiceWithNoOuter.BlockingInterface.class);
RpcController controller = control.createMock(RpcController.class);
BlockingService service =
ServiceWithNoOuter.newReflectiveBlockingService(impl);
MethodDescriptor fooMethod =
ServiceWithNoOuter.getDescriptor().findMethodByName("Foo");
MessageWithNoOuter request = MessageWithNoOuter.getDefaultInstance();
RpcCallback<Message> callback = new RpcCallback<Message>() {
public void run(Message parameter) {
// No reason this should be run.
fail();
}
};
TestAllTypes expectedResponse = TestAllTypes.getDefaultInstance();
EasyMock.expect(impl.foo(EasyMock.same(controller), EasyMock.same(request)))
.andReturn(expectedResponse);
control.replay();
Message response =
service.callBlockingMethod(fooMethod, controller, request);
assertEquals(expectedResponse, response);
control.verify();
}
ServiceTest.java 文件源码
项目:s-store
阅读 28
收藏 0
点赞 0
评论 0
/** Tests generated stubs. */
public void testStub() throws Exception {
FooRequest fooRequest = FooRequest.newBuilder().build();
BarRequest barRequest = BarRequest.newBuilder().build();
MockCallback<FooResponse> fooCallback = new MockCallback<FooResponse>();
MockCallback<BarResponse> barCallback = new MockCallback<BarResponse>();
RpcChannel mockChannel = control.createMock(RpcChannel.class);
TestService stub = TestService.newStub(mockChannel);
mockChannel.callMethod(
EasyMock.same(fooDescriptor),
EasyMock.same(mockController),
EasyMock.same(fooRequest),
EasyMock.same(FooResponse.getDefaultInstance()),
this.<Message>wrapsCallback(fooCallback));
mockChannel.callMethod(
EasyMock.same(barDescriptor),
EasyMock.same(mockController),
EasyMock.same(barRequest),
EasyMock.same(BarResponse.getDefaultInstance()),
this.<Message>wrapsCallback(barCallback));
control.replay();
stub.foo(mockController, fooRequest, fooCallback);
stub.bar(mockController, barRequest, barCallback);
control.verify();
}
ServiceTest.java 文件源码
项目:s-store
阅读 34
收藏 0
点赞 0
评论 0
/** Tests generated blocking stubs. */
public void testBlockingStub() throws Exception {
FooRequest fooRequest = FooRequest.newBuilder().build();
BarRequest barRequest = BarRequest.newBuilder().build();
BlockingRpcChannel mockChannel =
control.createMock(BlockingRpcChannel.class);
TestService.BlockingInterface stub =
TestService.newBlockingStub(mockChannel);
FooResponse fooResponse = FooResponse.newBuilder().build();
BarResponse barResponse = BarResponse.newBuilder().build();
EasyMock.expect(mockChannel.callBlockingMethod(
EasyMock.same(fooDescriptor),
EasyMock.same(mockController),
EasyMock.same(fooRequest),
EasyMock.same(FooResponse.getDefaultInstance()))).andReturn(fooResponse);
EasyMock.expect(mockChannel.callBlockingMethod(
EasyMock.same(barDescriptor),
EasyMock.same(mockController),
EasyMock.same(barRequest),
EasyMock.same(BarResponse.getDefaultInstance()))).andReturn(barResponse);
control.replay();
assertSame(fooResponse, stub.foo(mockController, fooRequest));
assertSame(barResponse, stub.bar(mockController, barRequest));
control.verify();
}
ServiceTest.java 文件源码
项目:s-store
阅读 26
收藏 0
点赞 0
评论 0
public void testNewReflectiveService() {
ServiceWithNoOuter.Interface impl =
control.createMock(ServiceWithNoOuter.Interface.class);
RpcController controller = control.createMock(RpcController.class);
Service service = ServiceWithNoOuter.newReflectiveService(impl);
MethodDescriptor fooMethod =
ServiceWithNoOuter.getDescriptor().findMethodByName("Foo");
MessageWithNoOuter request = MessageWithNoOuter.getDefaultInstance();
RpcCallback<Message> callback = new RpcCallback<Message>() {
public void run(Message parameter) {
// No reason this should be run.
fail();
}
};
RpcCallback<TestAllTypes> specializedCallback =
RpcUtil.specializeCallback(callback);
impl.foo(EasyMock.same(controller), EasyMock.same(request),
EasyMock.same(specializedCallback));
EasyMock.expectLastCall();
control.replay();
service.callMethod(fooMethod, controller, request, callback);
control.verify();
}
ServiceTest.java 文件源码
项目:s-store
阅读 27
收藏 0
点赞 0
评论 0
public void testNewReflectiveBlockingService() throws ServiceException {
ServiceWithNoOuter.BlockingInterface impl =
control.createMock(ServiceWithNoOuter.BlockingInterface.class);
RpcController controller = control.createMock(RpcController.class);
BlockingService service =
ServiceWithNoOuter.newReflectiveBlockingService(impl);
MethodDescriptor fooMethod =
ServiceWithNoOuter.getDescriptor().findMethodByName("Foo");
MessageWithNoOuter request = MessageWithNoOuter.getDefaultInstance();
RpcCallback<Message> callback = new RpcCallback<Message>() {
public void run(Message parameter) {
// No reason this should be run.
fail();
}
};
TestAllTypes expectedResponse = TestAllTypes.getDefaultInstance();
EasyMock.expect(impl.foo(EasyMock.same(controller), EasyMock.same(request)))
.andReturn(expectedResponse);
control.replay();
Message response =
service.callBlockingMethod(fooMethod, controller, request);
assertEquals(expectedResponse, response);
control.verify();
}
EasyMockModuleTest.java 文件源码
项目:unitils
阅读 14
收藏 0
点赞 0
评论 0
@Test
public void testRest() throws Exception {
MockTest mockTest = new MockTest();
easyMockModule.createAndInjectMocksIntoTest(mockTest);
EasyMock.expect(mockTest.testMock.isEmpty()).andReturn(Boolean.TRUE);
easyMockModule.reset(); //without the reset the call would fail.
easyMockModule.verify();
}
BeforeTestMethodStatementTest.java 文件源码
项目:unitils
阅读 14
收藏 0
点赞 0
评论 0
/**
* Test method for {@link org.unitils.core.junit.BeforeTestMethodStatement#evaluate()}.
*/
@Test(expected = NullPointerException.class)
public void testEvaluateExceptionOnListener() throws Throwable {
TestClass2 testObject = new TestClass2();
Method testMethod = TestClass2.class.getMethod("test1");
listener.beforeTestMethod(testObject, testMethod);
EasyMock.expectLastCall().andThrow(new NullPointerException());
EasyMockUnitils.replay();
new BeforeTestMethodStatement(listener, statement, testMethod, testObject).evaluate();
}
BeforeTestMethodStatementTest.java 文件源码
项目:unitils
阅读 15
收藏 0
点赞 0
评论 0
@Test(expected = NullPointerException.class)
public void testEvaluateExceptionOnStatement() throws Throwable {
TestClass2 testObject = new TestClass2();
Method testMethod = TestClass2.class.getMethod("test1");
listener.beforeTestMethod(testObject, testMethod);
statement.evaluate();
EasyMock.expectLastCall().andThrow(new NullPointerException());
EasyMockUnitils.replay();
new BeforeTestMethodStatement(listener, statement, testMethod, testObject).evaluate();
}
BeforeTestSetUpStatementTest.java 文件源码
项目:unitils
阅读 15
收藏 0
点赞 0
评论 0
@Test(expected = NullPointerException.class)
public void testEvaluateExceptionOnListener() throws Throwable {
TestClass2 testObject = new TestClass2();
Method testMethod = TestClass2.class.getMethod("test1");
listener.beforeTestSetUp(testObject, testMethod);
EasyMock.expectLastCall().andThrow(new NullPointerException());
EasyMockUnitils.replay();
new BeforeTestSetUpStatement(testObject, testMethod, listener, statement).evaluate();
}
BeforeTestSetUpStatementTest.java 文件源码
项目:unitils
阅读 14
收藏 0
点赞 0
评论 0
@Test(expected = NullPointerException.class)
public void testEvaluateExceptionOnStatement() throws Throwable {
TestClass2 testObject = new TestClass2();
Method testMethod = TestClass2.class.getMethod("test1");
listener.beforeTestSetUp(testObject, testMethod);
statement.evaluate();
EasyMock.expectLastCall().andThrow(new NullPointerException());
EasyMockUnitils.replay();
new BeforeTestSetUpStatement(testObject, testMethod, listener, statement).evaluate();
}
AfterTestTearDownStatementTest.java 文件源码
项目:unitils
阅读 13
收藏 0
点赞 0
评论 0
/**
* Test method for {@link org.unitils.core.junit.AfterTestTearDownStatement#evaluate()}.
*/
@Test(expected = NullPointerException.class)
public void testEvaluateStatementException() throws Throwable {
TestClass2 testObject = new TestClass2();
Method testMethod = TestClass2.class.getMethod("test1");
statement.evaluate();
EasyMock.expectLastCall().andThrow(new NullPointerException());
listener.afterTestTearDown(testObject, testMethod);
EasyMockUnitils.replay();
new AfterTestTearDownStatement(listener, statement, testObject, testMethod).evaluate();
}
AfterTestTearDownStatementTest.java 文件源码
项目:unitils
阅读 13
收藏 0
点赞 0
评论 0
/**
* Test method for {@link org.unitils.core.junit.AfterTestTearDownStatement#evaluate()}.
*/
@Test(expected = NullPointerException.class)
public void testEvaluateAfterTestTearDowntException() throws Throwable {
TestClass2 testObject = new TestClass2();
Method testMethod = TestClass2.class.getMethod("test1");
statement.evaluate();
listener.afterTestTearDown(testObject, testMethod);
EasyMock.expectLastCall().andThrow(new NullPointerException());
EasyMockUnitils.replay();
new AfterTestTearDownStatement(listener, statement, testObject, testMethod).evaluate();
}