public static ClassloaderByteArraySource fromContext() { return new ClassloaderByteArraySource(IsolationUtils.getContextClassLoader()); }
public static ClientPluginServices makeForContextLoader() { return new ClientPluginServices(IsolationUtils.getContextClassLoader()); }
public static PluginServices makeForContextLoader() { return new PluginServices(IsolationUtils.getContextClassLoader()); }
public static Function<ClassName, Stream<Class<?>>> nameToClass() { return nameToClass(IsolationUtils.getContextClassLoader()); }
private String loadCss() { try { return FileUtil.readToString(IsolationUtils.getContextClassLoader() .getResourceAsStream("templates/mutation/style.css")); } catch (final IOException e) { Log.getLogger().log(Level.SEVERE, "Error while loading css", e); } return ""; }
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; }
@Override public InputStream getData(String name) throws IOException { final String path = "sampleClasses/" + name.replace(".", "/") + ".class.bin"; return IsolationUtils.getContextClassLoader().getResourceAsStream(path); }
public static Object clone(final Object object) { return cloneForLoader(object, IsolationUtils.getContextClassLoader()); }
private TestUnit descriptionToTest(final Description description) { Class<?> clazz = description.getTestClass(); if (clazz == null) { clazz = IsolationUtils.convertForClassLoader( IsolationUtils.getContextClassLoader(), description.getClassName()); } return new AdaptedJUnitTestUnit(clazz, Optional.ofNullable(createFilterFor(description))); }
public static InputStream openClassfile(final Object classPath, // NO_UCD final String name) { try { if (isInstrumentedClass(name)) { final byte[] bs = getOriginalBytes(classPath, name); return new ByteArrayInputStream( transformBytes(IsolationUtils.getContextClassLoader(), name, bs)); } else { return returnNormalBytes(classPath, name); } } catch (final IOException ex) { throw Unchecked.translateCheckedException(ex); } }
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); final ClientPluginServices plugins = new ClientPluginServices(IsolationUtils.getContextClassLoader()); final 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); } } }
private void setupClassPath(final Class<?> clazz) { this.setupClassPath( new ClassloaderByteArraySource(IsolationUtils.getContextClassLoader()), clazz.getName()); }
private static Configuration createTestPlugin( final CoverageOptions paramsFromParent) { final ClientPluginServices plugins = new ClientPluginServices(IsolationUtils.getContextClassLoader()); final MinionSettings factory = new MinionSettings(plugins); final Configuration testPlugin = factory.getTestFrameworkPlugin(paramsFromParent.getPitConfig(), ClassloaderByteArraySource.fromContext()); return testPlugin; }
@Before public void setUp() { MockitoAnnotations.initMocks(this); this.testee = new Repository(new ClassloaderByteArraySource( IsolationUtils.getContextClassLoader()), this.hashFunction); }
protected void printRaw(final Class<?> clazz) throws IOException { final OtherClassLoaderClassPathRoot r = new OtherClassLoaderClassPathRoot( IsolationUtils.getContextClassLoader()); printClass(StreamUtil.streamToByteArray(r.getData(clazz.getName()))); }
@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").get(); }
@Before public void setUp() { MockitoAnnotations.initMocks(this); this.testee = new Repository(new ClassloaderByteArraySource( IsolationUtils.getContextClassLoader()), this.hashFunction); }
@Before public void setUp() { this.repository = new Repository(new ClassloaderByteArraySource( IsolationUtils.getContextClassLoader())); }
@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.*")); final 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(); } }
public void run() { try { final MinionArguments paramsFromParent = this.dis .read(MinionArguments.class); Log.setVerbose(paramsFromParent.isVerbose()); final ClassLoader loader = IsolationUtils.getContextClassLoader(); final ClassByteArraySource byteSource = new CachingByteArraySource(new ClassloaderByteArraySource( loader), CACHE_SIZE); final F3<ClassName, ClassLoader, byte[], Boolean> hotswap = new HotSwap( byteSource); final MutationEngine engine = createEngine(paramsFromParent.engine, paramsFromParent.engineArgs); final MutationTestWorker worker = new MutationTestWorker(hotswap, engine.createMutator(byteSource), loader, paramsFromParent.fullMutationMatrix); final List<TestUnit> tests = findTestsForTestClasses(loader, paramsFromParent.testClasses, createTestPlugin(paramsFromParent.pitConfig)); worker.run(paramsFromParent.mutations, this.reporter, new TimeOutDecoratedTestSource(paramsFromParent.timeoutStrategy, tests, this.reporter)); this.reporter.done(ExitCode.OK); } catch (final Throwable ex) { ex.printStackTrace(System.out); LOG.log(Level.WARNING, "Error during mutation test", ex); this.reporter.done(ExitCode.UNKNOWN_ERROR); } }