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

Java Specification类代码示例

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

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



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

示例1: ClassModel

import spock.lang.Specification; //导入依赖的package包/类
ClassModel(ASTNodeFactory astNodeFactory, String className, Type superClassType, PackageDeclaration packageDeclaration,
           List<FieldDeclaration> fields, List<MethodModel> methods, List<ImportDeclaration> imports,
           List<TypeModel> innerTypes, List<ASTNode> modifiers) {
    groovism = provide();

    this.className = className;
    this.packageDeclaration = packageDeclaration;
    this.fields = fieldDeclarations(fields);
    this.methods = unmodifiableList(new LinkedList<>(methods));
    this.modifiers = unmodifiableList(new LinkedList<>(modifiers));
    this.imports = imports;
    this.innerTypes = unmodifiableList(new LinkedList<>(innerTypes));
    if (isTestClass(methods)) {
        this.superClassType = Optional.of(astNodeFactory.simpleType(Specification.class.getSimpleName()));
        imports.add(0, astNodeFactory.importDeclaration(Specification.class));
    } else {
        this.superClassType = Optional.ofNullable(superClassType);
    }
}
 
开发者ID:opaluchlukasz,项目名称:junit2spock,代码行数:20,代码来源:ClassModel.java


示例2: beforeTestMethod

import spock.lang.Specification; //导入依赖的package包/类
@Override
public void beforeTestMethod(TestContext testContext) throws Exception {
	final Object testInstance = testContext.getTestInstance();
	if (!(testInstance instanceof Specification)) {
		return;
	}

	final Specification specification = (Specification) testInstance;
	final List<Object> mocks = new LinkedList<>();
	final ApplicationContext applicationContext = testContext.getApplicationContext();
	final DoubleRegistry doubleRegistry = applicationContext.getBean(DoubleRegistry.BEAN_NAME, DoubleRegistry.class);

	for (DoubleDefinition doubleDefinition : doubleRegistry.doublesSearch()) {
		final Optional<Object> doubleBean = tryToGetBean(applicationContext, doubleDefinition);

		doubleBean.ifPresent(bean -> {
			mocks.add(bean);
			mockUtil.attachMock(bean, specification);
		});
	}

	testContext.setAttribute(MOCKED_BEANS_NAMES, mocks);
}
 
开发者ID:pchudzik,项目名称:springmock,代码行数:24,代码来源:MockAttachingTestExecutionListener.java


示例3: setupClasslist

import spock.lang.Specification; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void setupClasslist(){
    classnameCombo.removeAllItems();
    methodName.removeAllItems();
    try
    {
        List<String> classList;
        classList = ClassFinder.findClassesThatExtend(SPATHS, new Class [] {Specification.class});
        ClassFilter filter = new ClassFilter();
        filter.setPackages(JOrphanUtils.split(filterpkg.getText(), ",")); //$NON-NLS-1$
        // change the classname drop down
        Object[] clist = filter.filterArray(classList);
        for (int idx=0; idx < clist.length; idx++) {
            classnameCombo.addItem(clist[idx]);
        }
    }
    catch (IOException e)
    {
        log.error("Exception getting interfaces.", e);
    }
}
 
开发者ID:gabehamilton,项目名称:jmeter-spock-sampler,代码行数:22,代码来源:SpockSamplerGui.java


示例4: create

import spock.lang.Specification; //导入依赖的package包/类
@Override public Object create(IMockConfiguration configuration, Specification specification) {
  for (IMockFactory factory : mockFactories) {
    if (factory.canCreate(configuration)) {
      return factory.create(configuration, specification);
    }
  }

  throw new InternalSpockError("No matching mock factory found");
}
 
开发者ID:AndrewReitz,项目名称:android-spock,代码行数:10,代码来源:AndroidMockFactory.java


示例5: createInternal

import spock.lang.Specification; //导入依赖的package包/类
private Object createInternal(IMockConfiguration configuration, Specification specification, ClassLoader classLoader) {
  if (Modifier.isFinal(configuration.getType().getModifiers())) {
    throw new CannotCreateMockException(configuration.getType(),
        " because Java mocks cannot mock final classes. If the code under test is written in Groovy, use a Groovy mock.");
  }
  if (configuration.isGlobal()) {
    throw new CannotCreateMockException(configuration.getType(),
        " because Java mocks cannot mock globally. If the code under test is written in Groovy, use a Groovy mock.");
  }

  MetaClass mockMetaClass = GroovyRuntimeUtil.getMetaClass(configuration.getType());
  IProxyBasedMockInterceptor interceptor = new JavaMockInterceptor(configuration, specification, mockMetaClass);
  return ProxyBasedMockFactory.INSTANCE.create(configuration.getType(), Collections.<Class<?>>emptyList(),
      configuration.getConstructorArgs(), interceptor, classLoader);
}
 
开发者ID:AndrewReitz,项目名称:android-spock,代码行数:16,代码来源:JavaMockFactory.java


示例6: initializeTestObject

import spock.lang.Specification; //导入依赖的package包/类
/**
 * Initialize test object
 */
private void initializeTestObject() {
    String rlabel = getConstructorString();
    if (rlabel.length()== 0) {
        rlabel = SpockSampler.class.getName();
    }
    this.testCase = (Specification) getClassInstance(className, rlabel);
    if (this.testCase != null){
        initMethodObjects(this.testCase);

    }
}
 
开发者ID:gabehamilton,项目名称:jmeter-spock-sampler,代码行数:15,代码来源:SpockSampler.java


示例7: create

import spock.lang.Specification; //导入依赖的package包/类
@Override public Object create(IMockConfiguration configuration, Specification specification) {
  return createInternal(configuration, specification, specification.getClass().getClassLoader());
}
 
开发者ID:AndrewReitz,项目名称:android-spock,代码行数:4,代码来源:JavaMockFactory.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java Keywords类代码示例发布时间:2022-05-22
下一篇:
Java PatchReporter类代码示例发布时间: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