本文整理匯總了Java中org.pitest.util.IsolationUtils類的典型用法代碼示例。如果您正苦於以下問題:Java IsolationUtils類的具體用法?Java IsolationUtils怎麽用?Java IsolationUtils使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
IsolationUtils類屬於org.pitest.util包,在下文中一共展示了IsolationUtils類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: executeInDifferentClassLoader
import org.pitest.util.IsolationUtils; //導入依賴的package包/類
private void executeInDifferentClassLoader(ClassLoader loader, ResultCollector rc, Launcher launcher, TestDiscoveryRequest discoveryRequest) {
// must jump through hoops to run in different class loader
// when even our framework classes may be duplicated
// translate everything via strings
final ForeignClassLoaderCustomLauncherExecutor ce = new ForeignClassLoaderCustomLauncherExecutor(
launcher, discoveryRequest);
@SuppressWarnings("unchecked")
Callable<List<String>> foreignCe = (Callable<List<String>>) IsolationUtils
.cloneForLoader(ce, loader);
try {
final List<String> q = foreignCe.call();
convertStringsToResults(rc, q);
} catch (Exception ex) {
throw Unchecked.translateCheckedException(ex);
}
}
示例2: openClassfile
import org.pitest.util.IsolationUtils; //導入依賴的package包/類
public static InputStream openClassfile(final Object classPath, // NO_UCD
final String name) {
try {
if (isInstrumentedClass(name)) {
byte[] bs = getOriginalBytes(classPath, name);
return new ByteArrayInputStream(
transformBytes(IsolationUtils.getContextClassLoader(), name, bs));
} else {
return returnNormalBytes(classPath, name);
}
} catch (IOException ex) {
throw Unchecked.translateCheckedException(ex);
}
}
示例3: testTestClassWithTestAnnotation
import org.pitest.util.IsolationUtils; //導入依賴的package包/類
@Test
public void testTestClassWithTestAnnotation() {
TestResultCollector resultCollector = new TestResultCollector();
new JUnit5TestUnitFinder().findTestUnits(TestClassWithTestAnnotation.class).stream().forEach(testUnit -> testUnit.execute(IsolationUtils.getContextClassLoader(), resultCollector));
assertThat(resultCollector.getSkipped()).isEmpty();
assertThat(resultCollector.getStarted()).hasSize(1);
assertThat(resultCollector.getEnded()).hasSize(1);
}
示例4: test3TestClassWithTestFactoryAnnotation
import org.pitest.util.IsolationUtils; //導入依賴的package包/類
@Test
public void test3TestClassWithTestFactoryAnnotation() {
TestResultCollector resultCollector = new TestResultCollector();
new JUnit5TestUnitFinder().findTestUnits(TestClassWithTestFactoryAnnotation.class).stream().forEach(testUnit -> testUnit.execute(IsolationUtils.getContextClassLoader(), resultCollector));
assertThat(resultCollector.getSkipped()).isEmpty();
assertThat(resultCollector.getStarted()).hasSize(1);
assertThat(resultCollector.getEnded()).hasSize(1);
}
示例5: testTestClassWithNestedAnnotationAndNestedTestAnnotation
import org.pitest.util.IsolationUtils; //導入依賴的package包/類
@Test
public void testTestClassWithNestedAnnotationAndNestedTestAnnotation() {
TestResultCollector resultCollector = new TestResultCollector();
new JUnit5TestUnitFinder().findTestUnits(TestClassWithNestedAnnotationAndNestedTestAnnotation.NestedClass.class).stream().forEach(testUnit -> testUnit.execute(IsolationUtils.getContextClassLoader(), resultCollector));
assertThat(resultCollector.getSkipped()).isEmpty();
assertThat(resultCollector.getStarted()).hasSize(1);
assertThat(resultCollector.getEnded()).hasSize(1);
}
示例6: testTestClassWithNestedAnnotationAndNestedTestFactoryAnnotation
import org.pitest.util.IsolationUtils; //導入依賴的package包/類
@Test
public void testTestClassWithNestedAnnotationAndNestedTestFactoryAnnotation() {
TestResultCollector resultCollector = new TestResultCollector();
new JUnit5TestUnitFinder().findTestUnits(TestClassWithNestedAnnotationAndNestedTestFactoryAnnotation.NestedClass.class).stream().forEach(testUnit -> testUnit.execute(IsolationUtils.getContextClassLoader(), resultCollector));
assertThat(resultCollector.getSkipped()).isEmpty();
assertThat(resultCollector.getStarted()).hasSize(1);
assertThat(resultCollector.getEnded()).hasSize(1);
}
示例7: testTestClassWithNestedAnnotationWithNestedAnnotationAndNestedTestAnnotation
import org.pitest.util.IsolationUtils; //導入依賴的package包/類
@Test
public void testTestClassWithNestedAnnotationWithNestedAnnotationAndNestedTestAnnotation() {
TestResultCollector resultCollector = new TestResultCollector();
new JUnit5TestUnitFinder().findTestUnits(TestClassWithNestedAnnotationWithNestedAnnotationAndNestedTestAnnotation.NestedClass.NestedNestedClass.class).stream().forEach(testUnit -> testUnit.execute(IsolationUtils.getContextClassLoader(), resultCollector));
assertThat(resultCollector.getSkipped()).isEmpty();
assertThat(resultCollector.getStarted()).hasSize(1);
assertThat(resultCollector.getEnded()).hasSize(1);
}
示例8: testTestClassWithNestedAnnotationWithNestedAnnotationAndNestedTestFactoryAnnotation
import org.pitest.util.IsolationUtils; //導入依賴的package包/類
@Test
public void testTestClassWithNestedAnnotationWithNestedAnnotationAndNestedTestFactoryAnnotation() {
TestResultCollector resultCollector = new TestResultCollector();
new JUnit5TestUnitFinder().findTestUnits(TestClassWithNestedAnnotationWithNestedAnnotationAndNestedTestFactoryAnnotation.NestedClass.NestedNestedClass.class).stream().forEach(testUnit -> testUnit.execute(IsolationUtils.getContextClassLoader(), resultCollector));
assertThat(resultCollector.getSkipped()).isEmpty();
assertThat(resultCollector.getStarted()).hasSize(1);
assertThat(resultCollector.getEnded()).hasSize(1);
}
示例9: setUp
import org.pitest.util.IsolationUtils; //導入依賴的package包/類
@BeforeEach
public void setUp() {
MockitoAnnotations.initMocks(this);
this.realSource = new ClassloaderByteArraySource(
IsolationUtils.getContextClassLoader());
this.factory = new JUnit5TestPluginFactory();
when(this.source.getBytes("org.junit.Test")).thenReturn(
Option.none());
when(this.source.getBytes("org.junit.gen5.api.Test")).thenReturn(
Option.none());
}
示例10: shouldMutateClassesSuppliedToAlternateClassPath
import org.pitest.util.IsolationUtils; //導入依賴的package包/類
@Test
public void shouldMutateClassesSuppliedToAlternateClassPath()
throws IOException {
// yes, this is horrid
final String location = FileUtil.randomFilename() + ".jar";
try {
try (FileOutputStream fos = new FileOutputStream(location)) {
final InputStream stream = IsolationUtils.getContextClassLoader()
.getResourceAsStream("outofcp.jar");
copy(stream, fos);
}
this.data.setTargetClasses(asList("com.outofclasspath.*Mutee*"));
this.data.setTargetTests(predicateFor("com.outofclasspath.*"));
List<String> cp = new ArrayList<>();
cp.addAll(ClassPath.getClassPathElementsAsPaths());
cp.add(location);
this.data.setClassPathElements(cp);
this.data.setDependencyAnalysisMaxDistance(-1);
this.data.setExcludedClasses(asList("*Power*", "*JMockit*"));
createAndRun();
verifyResults(KILLED);
} finally {
new File(location).delete();
}
}
示例11: descriptionToTest
import org.pitest.util.IsolationUtils; //導入依賴的package包/類
private TestUnit descriptionToTest(final Description description) {
Class<?> clazz = description.getTestClass();
if (clazz == null) {
clazz = IsolationUtils.convertForClassLoader(
IsolationUtils.getContextClassLoader(), description.getClassName());
}
return new AdaptedJUnitTestUnit(clazz,
Option.some(createFilterFor(description)));
}
示例12: main
import org.pitest.util.IsolationUtils; //導入依賴的package包/類
public static void main(final String[] args) {
LOG.log(Level.FINE, "minion started");
enablePowerMockSupport();
final int port = Integer.valueOf(args[0]);
Socket s = null;
try {
s = new Socket("localhost", port);
final SafeDataInputStream dis = new SafeDataInputStream(
s.getInputStream());
final Reporter reporter = new DefaultReporter(s.getOutputStream());
addMemoryWatchDog(reporter);
ClientPluginServices plugins = new ClientPluginServices(IsolationUtils.getContextClassLoader());
MinionSettings factory = new MinionSettings(plugins);
final MutationTestMinion instance = new MutationTestMinion(factory, dis, reporter);
instance.run();
} catch (final Throwable ex) {
ex.printStackTrace(System.out);
LOG.log(Level.WARNING, "Error during mutation test", ex);
} finally {
if (s != null) {
safelyCloseSocket(s);
}
}
}
示例13: createTestPlugin
import org.pitest.util.IsolationUtils; //導入依賴的package包/類
private static Configuration createTestPlugin(
final CoverageOptions paramsFromParent) {
ClientPluginServices plugins = new ClientPluginServices(IsolationUtils.getContextClassLoader());
MinionSettings factory = new MinionSettings(plugins);
Configuration testPlugin = factory.getTestFrameworkPlugin(paramsFromParent.getPitConfig(), ClassloaderByteArraySource.fromContext());
return testPlugin;
}
示例14: setUp
import org.pitest.util.IsolationUtils; //導入依賴的package包/類
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
this.testee = new BendJavassistToMyWillTransformer(this.filter, JavassistInputStreamInterceptorAdapater.inputStreamAdapterSupplier(JavassistInterceptor.class));
final ClassloaderByteArraySource source = new ClassloaderByteArraySource(
IsolationUtils.getContextClassLoader());
this.bytes = source.getBytes("java.lang.String").value();
}
示例15: loadResource
import org.pitest.util.IsolationUtils; //導入依賴的package包/類
public static boolean loadResource() {
final InputStream stream = IsolationUtils.getContextClassLoader()
.getResourceAsStream(
"resource folder with spaces/text in folder with spaces.txt");
final boolean result = stream != null; // store result to nudge compiler
// towards single IRETURN
return result;
}