• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java MockCreationSettings类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.mockito.mock.MockCreationSettings的典型用法代码示例。如果您正苦于以下问题:Java MockCreationSettings类的具体用法?Java MockCreationSettings怎么用?Java MockCreationSettings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MockCreationSettings类属于org.mockito.mock包,在下文中一共展示了MockCreationSettings类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createMock

import org.mockito.mock.MockCreationSettings; //导入依赖的package包/类
@Test
public void createMock() throws Exception {
	MockDefinition definition = new MockDefinition("name", ExampleService.class,
			new Class<?>[] { ExampleExtraInterface.class },
			Answers.RETURNS_SMART_NULLS, true, MockReset.BEFORE, true);
	ExampleService mock = definition.createMock();
	MockCreationSettings<?> settings = new MockUtil().getMockSettings(mock);
	assertThat(mock).isInstanceOf(ExampleService.class);
	assertThat(mock).isInstanceOf(ExampleExtraInterface.class);
	assertThat(settings.getMockName().toString()).isEqualTo("name");
	assertThat(settings.getDefaultAnswer())
			.isEqualTo(Answers.RETURNS_SMART_NULLS.get());
	assertThat(settings.isSerializable()).isTrue();
	assertThat(MockReset.get(mock)).isEqualTo(MockReset.BEFORE);
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:16,代码来源:MockDefinitionTests.java


示例2: createSpy

import org.mockito.mock.MockCreationSettings; //导入依赖的package包/类
@Test
public void createSpy() throws Exception {
	SpyDefinition definition = new SpyDefinition("name", RealExampleService.class,
			MockReset.BEFORE, true);
	RealExampleService spy = definition.createSpy(new RealExampleService("hello"));
	MockCreationSettings<?> settings = new MockUtil().getMockSettings(spy);
	assertThat(spy).isInstanceOf(ExampleService.class);
	assertThat(settings.getMockName().toString()).isEqualTo("name");
	assertThat(settings.getDefaultAnswer())
			.isEqualTo(Answers.CALLS_REAL_METHODS.get());
	assertThat(MockReset.get(spy)).isEqualTo(MockReset.BEFORE);
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:13,代码来源:SpyDefinitionTests.java


示例3: create

import org.mockito.mock.MockCreationSettings; //导入依赖的package包/类
public InternalMockHandler create(MockCreationSettings settings) {
    InternalMockHandler handler = new MockHandlerImpl(settings);
    InternalMockHandler nullResultGuardian = new NullResultGuardian(handler);
    InternalMockHandler notifier = new InvocationNotifierHandler(nullResultGuardian, settings);

    return notifier;
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:8,代码来源:MockHandlerFactory.java


示例4: AcrossJVMMockSerializationProxy

import org.mockito.mock.MockCreationSettings; //导入依赖的package包/类
/**
 * Creates the wrapper that be used in the serialization stream.
 *
 * <p>Immediately serializes the Mockito mock using specifically crafted {@link MockitoMockObjectOutputStream},
 * in a byte array.</p>
 *
 * @param mockitoMock The Mockito mock to serialize.
 * @throws IOException
 */
public AcrossJVMMockSerializationProxy(Object mockitoMock) throws IOException {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    ObjectOutputStream objectOutputStream = new MockitoMockObjectOutputStream(out);

    objectOutputStream.writeObject(mockitoMock);

    objectOutputStream.close();
    out.close();

    MockCreationSettings mockSettings = new MockUtil().getMockSettings(mockitoMock);
    this.serializedMock = out.toByteArray();
    this.typeToMock = mockSettings.getTypeToMock();
    this.extraInterfaces = mockSettings.getExtraInterfaces();
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:24,代码来源:AcrossJVMSerializationFeature.java


示例5: createMock

import org.mockito.mock.MockCreationSettings; //导入依赖的package包/类
public <T> T createMock(MockCreationSettings<T> settings) {
    MockHandler mockHandler = new MockHandlerFactory().create(settings);

    T mock = mockMaker.createMock(settings, mockHandler);

    Object spiedInstance = settings.getSpiedInstance();
    if (spiedInstance != null) {
        new LenientCopyTool().copyToMock(spiedInstance, mock);
    }

    return mock;
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:13,代码来源:MockUtil.java


示例6: resetMock

import org.mockito.mock.MockCreationSettings; //导入依赖的package包/类
public <T> void resetMock(T mock) {
    InternalMockHandler oldHandler = (InternalMockHandler) getMockHandler(mock);
    MockCreationSettings settings = oldHandler.getMockSettings();
    MockHandler newHandler = new MockHandlerFactory().create(settings);

    mockMaker.resetMock(mock, newHandler, settings);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:8,代码来源:MockUtil.java


示例7: handle_result_must_not_be_null_for_primitives

import org.mockito.mock.MockCreationSettings; //导入依赖的package包/类
@Test
//see issue 331
public void handle_result_must_not_be_null_for_primitives() throws Throwable {
    //given:
    MockCreationSettings settings = (MockCreationSettings) new MockSettingsImpl().defaultAnswer(new Returns(null));
    InternalMockHandler handler = new MockHandlerFactory().create(settings);

    mock.intReturningMethod();
    Invocation invocation = super.getLastInvocation();

    //when:
    Object result = handler.handle(invocation);

    //then null value is not a valid result for a primitive
    assertNotNull(result);
    assertEquals(0, result);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:18,代码来源:MockHandlerFactoryTest.java


示例8: valid_handle_result_is_permitted

import org.mockito.mock.MockCreationSettings; //导入依赖的package包/类
@Test
//see issue 331
public void valid_handle_result_is_permitted() throws Throwable {
    //given:
    MockCreationSettings settings = (MockCreationSettings) new MockSettingsImpl().defaultAnswer(new Returns(123));
    InternalMockHandler handler = new MockHandlerFactory().create(settings);

    mock.intReturningMethod();
    Invocation invocation = super.getLastInvocation();

    //when:
    Object result = handler.handle(invocation);

    //then
    assertEquals(123, result);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:17,代码来源:MockHandlerFactoryTest.java


示例9: resetMock

import org.mockito.mock.MockCreationSettings; //导入依赖的package包/类
@Override
public void resetMock(Object mock, MockHandler newHandler, MockCreationSettings settings) {
    InvocationHandlerAdapter adapter = getInvocationHandlerAdapter(mock);
    if (adapter != null) {
        adapter.setHandler(newHandler);
    }
}
 
开发者ID:linkedin,项目名称:dexmaker,代码行数:8,代码来源:InlineDexmakerMockMaker.java


示例10: onMockCreated

import org.mockito.mock.MockCreationSettings; //导入依赖的package包/类
@SuppressWarnings("rawtypes") // The MockCreationListener interface forces this
@Override
public void onMockCreated(Object mock, MockCreationSettings settings) {
    mocks.add(mock);
}
 
开发者ID:theangrydev,项目名称:fluent-bdd,代码行数:6,代码来源:FluentMockito.java


示例11: createMock

import org.mockito.mock.MockCreationSettings; //导入依赖的package包/类
public <T> T createMock(MockCreationSettings<T> settings, MockHandler handler) {
    return cglibMockMaker.createMock(settings, handler);
}
 
开发者ID:awenblue,项目名称:powermock,代码行数:4,代码来源:PowerMockMaker.java


示例12: resetMock

import org.mockito.mock.MockCreationSettings; //导入依赖的package包/类
public void resetMock(Object mock, MockHandler newHandler, MockCreationSettings settings) {
    cglibMockMaker.resetMock(mock, newHandler, settings);
}
 
开发者ID:awenblue,项目名称:powermock,代码行数:4,代码来源:PowerMockMaker.java


示例13: getMockSettings

import org.mockito.mock.MockCreationSettings; //导入依赖的package包/类
public MockCreationSettings getMockSettings() {
    final MockSettingsImpl mockSettings = new MockSettingsImpl();
    mockSettings.setMockName(new MockNameImpl(mock.getName()));
    mockSettings.setTypeToMock(mock);
    return mockSettings;
}
 
开发者ID:awenblue,项目名称:powermock,代码行数:7,代码来源:PowerMockMaker.java


示例14: PowerMockMethodInterceptorFilter

import org.mockito.mock.MockCreationSettings; //导入依赖的package包/类
public PowerMockMethodInterceptorFilter(InternalMockHandler handler,
        MockCreationSettings mockSettings) {
    super(handler, mockSettings);
}
 
开发者ID:awenblue,项目名称:powermock,代码行数:5,代码来源:PowerMockMethodInterceptorFilter.java


示例15: MethodInterceptorFilter

import org.mockito.mock.MockCreationSettings; //导入依赖的package包/类
public MethodInterceptorFilter(InternalMockHandler handler, MockCreationSettings mockSettings) {
    this.handler = handler;
    this.mockSettings = mockSettings;
}
 
开发者ID:mockito,项目名称:mockito-cglib,代码行数:5,代码来源:MethodInterceptorFilter.java


示例16: createMock

import org.mockito.mock.MockCreationSettings; //导入依赖的package包/类
public <T> T createMock(MockCreationSettings<T> settings, MockHandler handler) {
    InternalMockHandler mockitoHandler = cast(handler);
    new AcrossJVMSerializationFeature().enableSerializationAcrossJVM(settings);
    return new ClassImposterizer(new InstantiatorProvider().getInstantiator(settings)).imposterise(
            new MethodInterceptorFilter(mockitoHandler, settings), settings.getTypeToMock(), settings.getExtraInterfaces());
}
 
开发者ID:mockito,项目名称:mockito-cglib,代码行数:7,代码来源:CglibMockMaker.java


示例17: resetMock

import org.mockito.mock.MockCreationSettings; //导入依赖的package包/类
public void resetMock(Object mock, MockHandler newHandler, MockCreationSettings settings) {
    ((Factory) mock).setCallback(0, new MethodInterceptorFilter(cast(newHandler), settings));
}
 
开发者ID:mockito,项目名称:mockito-cglib,代码行数:4,代码来源:CglibMockMaker.java


示例18: AcrossJVMMockSerializationProxy

import org.mockito.mock.MockCreationSettings; //导入依赖的package包/类
/**
 * Creates the wrapper that be used in the serialization stream.
 *
 * <p>Immediately serializes the Mockito mock using specifically crafted
 * {@link AcrossJVMSerializationFeature.MockitoMockObjectOutputStream},
 * in a byte array.</p>
 *
 * @param mockitoMock The Mockito mock to serialize.
 * @throws IOException
 */
public AcrossJVMMockSerializationProxy(Object mockitoMock) throws IOException {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    ObjectOutputStream objectOutputStream = new MockitoMockObjectOutputStream(out);

    objectOutputStream.writeObject(mockitoMock);

    objectOutputStream.close();
    out.close();

    MockCreationSettings mockSettings = new MockUtil().getMockSettings(mockitoMock);
    this.serializedMock = out.toByteArray();
    this.typeToMock = mockSettings.getTypeToMock();
    this.extraInterfaces = mockSettings.getExtraInterfaces();
}
 
开发者ID:mockito,项目名称:mockito-cglib,代码行数:25,代码来源:AcrossJVMSerializationFeature.java


示例19: confirm

import org.mockito.mock.MockCreationSettings; //导入依赖的package包/类
public MockCreationSettings<T> confirm(Class<T> typeToMock) {
    return validatedSettings(typeToMock, this);
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:4,代码来源:MockSettingsImpl.java


示例20: resetMock

import org.mockito.mock.MockCreationSettings; //导入依赖的package包/类
@Override
@SuppressWarnings("rawtypes")
public void resetMock(Object mock, MockHandler newHandler, MockCreationSettings settings) {
  InvocationHandlerAdapter adapter = getInvocationHandlerAdapter(mock);
  adapter.setHandler(newHandler);
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:7,代码来源:IosMockMaker.java



注:本文中的org.mockito.mock.MockCreationSettings类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RENAME3Request类代码示例发布时间:2022-05-22
下一篇:
Java Writeable类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap