Package org.powermock.core.classloader

Examples of org.powermock.core.classloader.MockClassLoader


    final MainMockTransformer mainMockTransformer = new MainMockTransformer();
    mockTransformerChain.add(mainMockTransformer);

    String[] classesToLoadByMockClassloader = new String[0];
    String[] packagesToIgnore = new String[0];
    mockLoader = new MockClassLoader(classesToLoadByMockClassloader, packagesToIgnore);
    mockLoader.setMockTransformerChain(mockTransformerChain);
    testClassesExtractor = new PrepareForTestExtractorImpl();
    ignorePackagesExtractor = new PowerMockIgnorePackagesExtractorImpl();
                expectedExceptionsExtractor = new PowerMockExpectedExceptionsExtractorImpl();
                staticConstructorSuppressExtractor = new StaticConstructorSuppressExtractorImpl();
View Full Code Here


public class XStreamClassloaderExecutorTest {

  @Test
  public void loadsObjectGraphInSpecifiedClassloaderAndReturnsResultInOriginalClassloader() throws Exception {
    MockClassLoader classloader = createClassloader();
    final MyReturnValue expectedConstructorValue = new MyReturnValue(new MyArgument("first value"));
    final MyClass myClass = new MyClass(expectedConstructorValue);
    final MyArgument expected = new MyArgument("A value");
    MyReturnValue[] actual = new ClassloaderExecutor(classloader).execute(new Callable<MyReturnValue[]>() {
      public MyReturnValue[] call() throws Exception {
View Full Code Here

  }

  @Test
  public void loadsObjectGraphThatIncludesPrimitiveValuesInSpecifiedClassloaderAndReturnsResultInOriginalClassloader()
      throws Exception {
    MockClassLoader classloader = createClassloader();
    final Integer expected = 42;
    final MyIntegerHolder myClass = new MyIntegerHolder(expected);
    Integer actual = new ClassloaderExecutor(classloader).execute(new Callable<Integer>() {
      public Integer call() throws Exception {
        assertEquals(MockClassLoader.class.getName(), this.getClass().getClassLoader().getClass().getName());
View Full Code Here

  }

  @Test
  public void loadsObjectGraphThatIncludesEnumsInSpecifiedClassloaderAndReturnsResultInOriginalClassloader()
      throws Exception {
    MockClassLoader classloader = createClassloader();
    final MyEnum expected = MyEnum.MyEnum1;
    final MyEnumHolder myClass = new MyEnumHolder(expected);
    MyEnum actual = new ClassloaderExecutor(classloader).execute(new Callable<MyEnum>() {
      public MyEnum call() throws Exception {
        assertEquals(MockClassLoader.class.getName(), this.getClass().getClassLoader().getClass().getName());
View Full Code Here

    assertEquals(expected, actual);
  }

  @Test
  public void clonesStaticFinalObjectFields() throws Exception {
    MockClassLoader classloader = createClassloader();
    final MyStaticFinalArgumentHolder expected = new MyStaticFinalArgumentHolder();
    MyStaticFinalArgumentHolder actual = new ClassloaderExecutor(classloader)
        .execute(new Callable<MyStaticFinalArgumentHolder>() {
          public MyStaticFinalArgumentHolder call() throws Exception {
            assertEquals(MockClassLoader.class.getName(), this.getClass().getClassLoader().getClass()
View Full Code Here

    assertEquals(expected.getMyObject(), actual.getMyObject());
  }

  @Test
  public void clonesStaticFinalPrimitiveFields() throws Exception {
    MockClassLoader classloader = createClassloader();
    final MyStaticFinalPrimitiveHolder expected = new MyStaticFinalPrimitiveHolder();
    MyStaticFinalPrimitiveHolder actual = new ClassloaderExecutor(classloader)
        .execute(new Callable<MyStaticFinalPrimitiveHolder>() {
          public MyStaticFinalPrimitiveHolder call() throws Exception {
            assertEquals(MockClassLoader.class.getName(), this.getClass().getClassLoader().getClass()
View Full Code Here

    assertEquals(expected.getMyInt(), actual.getMyInt());
  }

  @Test
  public void clonesStaticFinalNumberFields() throws Exception {
    MockClassLoader classloader = createClassloader();
    final MyStaticFinalNumberHolder expected = new MyStaticFinalNumberHolder();
    MyStaticFinalNumberHolder actual = new ClassloaderExecutor(classloader)
        .execute(new Callable<MyStaticFinalNumberHolder>() {
          public MyStaticFinalNumberHolder call() throws Exception {
            assertEquals(MockClassLoader.class.getName(), this.getClass().getClassLoader().getClass()
View Full Code Here

  }

  @Test
  public void loadsObjectGraphThatIncludesPrimitiveArraysInSpecifiedClassloaderAndReturnsResultInOriginalClassloader()
      throws Exception {
    MockClassLoader classloader = createClassloader();
    final int[] expected = new int[] { 1, 2 };
    final MyPrimitiveArrayHolder myClass = new MyPrimitiveArrayHolder(expected);
    int[] actual = new ClassloaderExecutor(classloader).execute(new Callable<int[]>() {
      public int[] call() throws Exception {
        assertEquals(MockClassLoader.class.getName(), this.getClass().getClassLoader().getClass().getName());
View Full Code Here

  }

  @Test
  public void loadsObjectGraphThatIncludesCollectionInSpecifiedClassloaderAndReturnsResultInOriginalClassloader()
      throws Exception {
    final MockClassLoader classloader = createClassloader();
    final Collection<MyReturnValue> expected = new LinkedList<MyReturnValue>();
    expected.add(new MyReturnValue(new MyArgument("one")));
    expected.add(new MyReturnValue(new MyArgument("two")));
    final MyCollectionHolder myClass = new MyCollectionHolder(expected);
    Collection<?> actual = new ClassloaderExecutor(classloader).execute(new Callable<Collection<?>>() {
View Full Code Here

    }
  }

  @Test
  public void usesReferenceCloningWhenTwoFieldsPointToSameInstance() throws Exception {
    final MockClassLoader classloader = createClassloader();
    final MyReferenceFieldHolder tested = new MyReferenceFieldHolder();
    assertSame(tested.getMyArgument1(), tested.getMyArgument2());
    assertSame(tested.getMyArgument1(), MyReferenceFieldHolder.MY_ARGUMENT);
    new ClassloaderExecutor(classloader).execute(new Runnable() {
      public void run() {
View Full Code Here

TOP

Related Classes of org.powermock.core.classloader.MockClassLoader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.