• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java CtClass类的典型用法和代码示例

java 16次浏览

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

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

示例1: runJBSE

点赞 3

import spoon.reflect.declaration.CtClass; //导入依赖的package包/类
public static List<Map<String, List<String>>> runJBSE(String classpath, CtMethod<?> testMethod) {
    final RunParameters p = new RunParameters();
    p.addClasspath(addRequiredJARsToClasspath(classpath).split(":"));
    p.setMethodSignature(
            testMethod.getParent(CtClass.class).getQualifiedName().replaceAll("\\.", "/"),
            methodToDescriptor.apply(testMethod),
            testMethod.getSimpleName()
    );
    p.setDecisionProcedureType(RunParameters.DecisionProcedureType.Z3);
    p.setExternalDecisionProcedurePath("lib/z3/build/bin/z3");
    p.setOutputFileName("out/runIf_z3.txt");
    p.setStepShowMode(RunParameters.StepShowMode.LEAVES);
    p.setStateFormatMode(RunParameters.StateFormatMode.FULLTEXTHISTORY);
    p.setShowOnConsole(Main.verbose);
    final Run r = new Run(p);
    r.run();

    return filterDistinctLeaves(StateFormatterTextWithHistory.getStates())
            .stream()
            .map(JBSERunner::buildConditionsOnArguments)
            .collect(Collectors.toList());
}
 

开发者ID:STAMP-project,
项目名称:Ex2Amplifier,
代码行数:23,
代码来源:JBSERunner.java

示例2: test

点赞 3

import spoon.reflect.declaration.CtClass; //导入依赖的package包/类
@Test
public void test() throws Exception {
    this.configuration.getInputProgram().setFactory(this.launcher.getFactory());
    final Ex2Amplifier amplifier = new Ex2Amplifier(this.configuration);
    final CtClass<?> testClass = this.launcher.getFactory().Class().get("fr.inria.calculator.CalculatorTest");
    amplifier.reset(testClass);
    final List<CtMethod> amplifiedTestAccumulate = amplifier.apply(testClass.getMethodsByName("testAccumulate").get(0));
    assertEquals(2, amplifiedTestAccumulate.size());
    final String expectedAmplifiedTestMethod = "{" + AmplificationHelper.LINE_SEPARATOR +
            "    final Calculator calculator1 = new Calculator(0);" + AmplificationHelper.LINE_SEPARATOR +
            "    Assert.assertEquals((-5), calculator1.getCurrentValue());" + AmplificationHelper.LINE_SEPARATOR +
            "    calculator1.accumulate((-5));" + AmplificationHelper.LINE_SEPARATOR +
            "    Assert.assertEquals((-15), calculator1.getCurrentValue());" + AmplificationHelper.LINE_SEPARATOR +
            "}";
    assertEquals(expectedAmplifiedTestMethod, amplifiedTestAccumulate.get(0).getBody().toString());

}
 

开发者ID:STAMP-project,
项目名称:Ex2Amplifier,
代码行数:18,
代码来源:Ex2AmplifierTest.java

示例3: testLauncherOnTestThatUseSystemProperties

点赞 3

import spoon.reflect.declaration.CtClass; //导入依赖的package包/类
@Test
public void testLauncherOnTestThatUseSystemProperties() throws Exception {

	/*
		Contract: DSpot is able to run a test that use System Properties.
			System Properties must be described in the properties file given as input.
			System Properties must be described with the key systemProperties (i.e. systemProperties=...)
			System Properties must be a couple of key and value, separated by an equals '=' (e.g. key=value)
			System Properties must be separated by a comma ',' (e.g. key1=value1,key2=value2)

	 */

	Utils.init("src/test/resources/sample/sample.properties");
	final CtClass aClass = Utils.findClass("fr.inria.systemproperties.SystemPropertiesTest");
	final String classPath = AmplificationHelper.getClassPath(Utils.getCompiler(), Utils.getInputProgram());
	final TestListener run = TestLauncher.run(Utils.getInputConfiguration(), classPath, aClass);
	assertEquals(1, run.getPassingTests().size());
	assertEquals(1, run.getRunningTests().size());
	assertEquals(0, run.getFailingTests().size());
	assertTrue(run.getFailingTests().isEmpty());
}
 

开发者ID:STAMP-project,
项目名称:dspot,
代码行数:22,
代码来源:TestLauncherTest.java

示例4: testLauncherOnTestUsingReflectiveTestRunnerOnTestThatUseSystemProperty

点赞 3

import spoon.reflect.declaration.CtClass; //导入依赖的package包/类
@Test
public void testLauncherOnTestUsingReflectiveTestRunnerOnTestThatUseSystemProperty() throws Exception {

	/*
		Using the ReflectiveTestRunner
	 */
	TestRunnerFactory.useReflectiveTestRunner = true;
	Utils.init("src/test/resources/sample/sample.properties");
	final CtClass aClass = Utils.findClass("fr.inria.systemproperties.SystemPropertiesTest");
	final String classPath = AmplificationHelper.getClassPath(Utils.getCompiler(), Utils.getInputProgram());
	final TestListener run = TestLauncher.run(Utils.getInputConfiguration(), classPath, aClass);
	assertEquals(1, run.getPassingTests().size());
	assertEquals(1, run.getRunningTests().size());
	assertEquals(0, run.getFailingTests().size());
	assertTrue(run.getFailingTests().isEmpty());
	TestRunnerFactory.useReflectiveTestRunner = false;
}
 

开发者ID:STAMP-project,
项目名称:dspot,
代码行数:18,
代码来源:TestLauncherTest.java

示例5: testPitDescartesMode

点赞 3

import spoon.reflect.declaration.CtClass; //导入依赖的package包/类
@Test
    public void testPitDescartesMode() throws Exception {
        assertFalse(MavenPitCommandAndOptions.descartesMode);
        MavenPitCommandAndOptions.descartesMode = true;
        InputConfiguration configuration = new InputConfiguration("src/test/resources/descartes/descartes.properties");
        DSpot dspot = new DSpot(configuration, 1,
                new PitMutantScoreSelector("src/test/resources/descartes/mutations.csv"));
        final CtClass<Object> originalTestClass = dspot.getInputProgram().getFactory().Class().get("fr.inria.stamp.mutationtest.test.TestCalculator");
        assertEquals(2, originalTestClass.getMethods().size());
        final CtType ctType = dspot.amplifyTest(
                "fr.inria.stamp.mutationtest.test.TestCalculator",
                Collections.singletonList("Integraltypestest")
        );
//        assertTrue(originalTestClass.getMethods().size() < ctType.getMethods().size()); // TODO
        FileUtils.cleanDirectory(new File(configuration.getOutputDirectory()));
        assertTrue(MavenPitCommandAndOptions.descartesMode);
    }
 

开发者ID:STAMP-project,
项目名称:dspot,
代码行数:18,
代码来源:PitDescartesTest.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)