当前位置: 首页>>代码示例>>Java>>正文


Java MockCreationSettings类代码示例

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


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


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