Package org.powermock.tests.utils.impl

Examples of org.powermock.tests.utils.impl.StaticConstructorSuppressExtractorImpl


  public void run(RunNotifier notifier) {
    final List<Method> methods = (List<Method>) Whitebox.getInternalState(this, "fTestMethods");
    if (methods.isEmpty())
      notifier.testAborted(getDescription(), new Exception("No runnable methods"));
    for (Method method : methods) {
      final StaticConstructorSuppressExtractorImpl staticConstructorSuppressExtractorImpl = new StaticConstructorSuppressExtractorImpl();
      Class<?> testType = getTestClass();
      final ClassLoader thisClassLoader = getClass().getClassLoader();
      if (!thisClassLoader.equals(testType.getClassLoader())) {
        /*
         * The test is loaded from another classloader, this means that
         * we cannot get the correct annotations if we don't load the
         * class from the correct class loader
         */
        try {
          testType = thisClassLoader.loadClass(testType.getName());
        } catch (ClassNotFoundException e) {
          // This should never happen
          throw new RuntimeException("Internal error in PowerMock", e);
        }
      }
      if (staticConstructorSuppressExtractorImpl.getTestClasses(method) == null) {
        staticConstructorSuppressExtractorImpl.getTestClasses(testType);
      }

      invokeTestMethod(method, notifier);
    }
  }
View Full Code Here


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

            }
        }).runProtected();
    }

    protected void runMethods(final RunNotifier notifier) {
        final StaticConstructorSuppressExtractorImpl staticConstructorSuppressExtractorImpl = new StaticConstructorSuppressExtractorImpl();
        Class<?> testType = getTestClass();
        final ClassLoader thisClassLoader = getClass().getClassLoader();
        if (!thisClassLoader.equals(testType.getClassLoader())) {
            /*
             * The test is loaded from another classloader, this means that we
             * cannot get the correct annotations if we don't load the class
             * from the correct class loader
             */
            try {
                testType = thisClassLoader.loadClass(testType.getName());
            } catch (ClassNotFoundException e) {
                // This should never happen
                throw new RuntimeException("Internal error in PowerMock", e);
            }
        }
        for (Method method : testMethods) {
            if (staticConstructorSuppressExtractorImpl.getTestClasses(method) == null) {
                staticConstructorSuppressExtractorImpl.getTestClasses(testType);
            }
            invokeTestMethod(method, notifier);
        }
    }
View Full Code Here

     * For extra safety clear the MockitoRepository.
     */
        MockRepository.clear();

        PrepareForTestExtractorImpl testClassesExtractor = new PrepareForTestExtractorImpl();
        StaticConstructorSuppressExtractorImpl suppressExtractor = new StaticConstructorSuppressExtractorImpl();
        PowerMockIgnorePackagesExtractorImpl powerMockIgnorePackagesExtractor = new PowerMockIgnorePackagesExtractorImpl();
        final String[] classesToPrepare = testClassesExtractor.getTestClasses(testClass);
        final String[] classesToSuppress = suppressExtractor.getTestClasses(testClass);
        final String[] packagesToIgnore = powerMockIgnorePackagesExtractor.getPackagesToIgnore(testClass);
        redefine(classesToPrepare, packagesToIgnore);
        redefine(classesToSuppress, packagesToIgnore);
        final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
        registerProxyframework(contextClassLoader);
View Full Code Here

        String[] classesToLoadByMockClassloader = new String[0];
        String[] packagesToIgnore = new String[0];
        MockClassLoader mockLoader = new MockClassLoader(classesToLoadByMockClassloader, packagesToIgnore);
        mockLoader.setMockTransformerChain(mockTransformerChain);
        PrepareForTestExtractorImpl testClassesExtractor = new PrepareForTestExtractorImpl();
        StaticConstructorSuppressExtractorImpl staticInitializationExtractor = new StaticConstructorSuppressExtractorImpl();
        PowerMockIgnorePackagesExtractorImpl ignorePackagesExtractor = new PowerMockIgnorePackagesExtractorImpl();
   
        mockLoader.addIgnorePackage(ignorePackagesExtractor.getPackagesToIgnore(testClass));
        mockLoader.addClassesToModify(testClassesExtractor.getTestClasses(testClass));
        mockLoader.addClassesToModify(staticInitializationExtractor.getTestClasses(testClass));
        registerProxyframework(mockLoader);
        new MockPolicyInitializerImpl(testClass).initialize(mockLoader);
        return new ClassloaderExecutor(mockLoader);
    }
View Full Code Here

TOP

Related Classes of org.powermock.tests.utils.impl.StaticConstructorSuppressExtractorImpl

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.