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


Java Specification类代码示例

本文整理汇总了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;未经允许,请勿转载。