public TransformingClassLoader(final Transformation transformation, final IsolationStrategy isolationStrategy) { this(new ClassPath(), transformation, isolationStrategy, XStreamCloning .bootClassLoader()); }
@SuppressWarnings("unchecked") private <T> T runInClassLoader(final ClassLoader loader, final Callable<T> callable) throws Exception { final Callable<T> c = (Callable<T>) XStreamCloning.cloneForLoader(callable, loader); return c.call(); }
public static Class<?> convertForClassLoader(final ClassLoader loader, final Class<?> clazz) { if (clazz.getClassLoader() != loader) { return convertForClassLoader(loader, clazz.getName()); } else { return clazz; } }
public static Object cloneForLoader(final Object o, final ClassLoader loader) { try { final String xml = toXml(o); final XStream foreignXstream = getXStreamForLoader(loader); return foreignXstream.fromXML(xml); } catch (final Exception ex) { throw translateCheckedException(ex); } }
@Test public void testFoo() { final ClassLoader cl = new DefaultPITClassloader(new ClassPath(), XStreamCloning.bootClassLoader()); final Testee testee = new Testee(); final Runnable r = (Runnable) XStreamCloning.cloneForLoader(testee, cl); r.run(); }
@Test public void shouldCloneViaXStreamWithoutError() throws Exception { try { this.testee = new Description("foo", IOException.class); final Description actual = (Description) XStreamCloning .clone(this.testee); assertEquals(this.testee, actual); } catch (final Throwable t) { fail(t.getMessage()); } }
@Test public void shouldSerializeAndDeserializeByXStreamWithoutError() throws Exception { try { final NoArgsInstantiateStep testee = new NoArgsInstantiateStep( NoArgsInstantiateStepTest.class); XStreamCloning.clone(testee); } catch (final Throwable t) { fail(); } }
public static Object clone(final Object object) { return cloneForLoader(object, IsolationUtils.getContextClassLoader()); }
@Test public void shouldCloneViaXStreamWithoutError() throws Exception { try { final TestResult testee = new TestResult((Description) null, null, TestUnitState.FINISHED); XStreamCloning.clone(testee); } catch (final Throwable t) { fail(); } }
@Test public void shouldCloneViaXStreamWithoutError() throws Exception { try { final Method m = Reflection.publicMethod(this.getClass(), "shouldCloneViaXStreamWithoutError"); final TestMethod testee = new TestMethod(m, IOException.class); final TestMethod actual = (TestMethod) XStreamCloning.clone(testee); assertEquals(actual.getMethod(), testee.getMethod()); } catch (final Throwable t) { fail(); } }