Skip to content

Commit

Permalink
Fixes #839 Removed deprecated code in PowerMock 2.0.
Browse files Browse the repository at this point in the history
The following was removed:
- Supporting jUnit 3
- Deprecated annotation 'org.powermock.core.classloader.annotations.Mock'
  • Loading branch information
Arthur Zagretdinov committed Sep 10, 2017
1 parent 5af82ba commit 836c53f
Show file tree
Hide file tree
Showing 28 changed files with 8 additions and 1,322 deletions.
15 changes: 0 additions & 15 deletions gradle/modules.gradle
Expand Up @@ -218,21 +218,6 @@ project(":powermock-modules:powermock-module-javaagent") {
}
}

project(":powermock-modules:powermock-module-junit3") {
description = "PowerMock support module for JUnit 3.x."

dependencies {
compile(project(":powermock-core")) {
exclude group: 'junit', module: 'junit'
}
compile("junit:junit:3.8.2") {
exclude group: 'org.hamcrest', module: 'hamcrest-core'
}
testCompile("org.hamcrest:hamcrest-core:${hamcrestVersion}")
testCompile("org.assertj:assertj-core:${assertjVersion}")
}
}

project(":powermock-modules:powermock-module-junit4-common") {
description = "PowerMock support module for all versions of JUnit 4.x."

Expand Down
Expand Up @@ -17,10 +17,9 @@

import org.powermock.api.easymock.annotation.MockNice;
import org.powermock.api.easymock.annotation.MockStrict;
import org.powermock.core.classloader.annotations.Mock;

/**
* Before each test method all fields annotated with {@link Mock},
* Before each test method all fields annotated with {@link org.powermock.api.easymock.annotation.Mock},
* {@link MockNice} or {@link MockStrict} will have mock objects created for
* them and injected to the fields.
*
Expand Down
Expand Up @@ -16,9 +16,9 @@
package org.powermock.api.extension.listener;

import org.powermock.api.easymock.EasyMockConfiguration;
import org.powermock.api.easymock.annotation.Mock;
import org.powermock.api.easymock.annotation.MockNice;
import org.powermock.api.easymock.annotation.MockStrict;
import org.powermock.core.classloader.annotations.Mock;
import org.powermock.core.spi.listener.AnnotationEnablerListener;
import org.powermock.core.spi.support.AbstractPowerMockTestListenerBase;
import org.powermock.reflect.Whitebox;
Expand Down Expand Up @@ -53,7 +53,7 @@ public class AnnotationEnabler extends AbstractPowerMockTestListenerBase impleme

@SuppressWarnings("unchecked")
public Class<? extends Annotation>[] getMockAnnotations() {
return new Class[]{org.powermock.api.easymock.annotation.Mock.class, Mock.class, MockNice.class, MockStrict.class};
return new Class[]{Mock.class, MockNice.class, MockStrict.class};
}

@Override
Expand Down
Expand Up @@ -68,7 +68,6 @@ protected void injectNiceMocks() throws Exception {
@SuppressWarnings("deprecation")
protected void injectDefaultMocks() throws Exception {
inject(testInstance, Mock.class, annotationMockCreatorFactory.createDefaultMockCreator());
inject(testInstance, org.powermock.core.classloader.annotations.Mock.class, annotationMockCreatorFactory.createDefaultMockCreator());
}

@SuppressWarnings("unchecked")
Expand Down
Expand Up @@ -27,7 +27,7 @@

/**
* The class injects mocks created with {@link Mock}, {@link org.powermock.api.easymock.annotation.Mock}
* and {@link org.powermock.core.classloader.annotations.Mock} to fields of objects which is annotated with {@link TestSubject}
* to fields of objects which is annotated with {@link TestSubject}
* @see TestSubject
* @since 1.6.5
*/
Expand Down
Expand Up @@ -76,15 +76,6 @@ private void standardInject(Object testInstance) throws IllegalAccessException {
continue;
}
final Class<?> type = field.getType();
if (field.isAnnotationPresent(org.powermock.core.classloader.annotations.Mock.class)) {
org.powermock.core.classloader.annotations.Mock annotation = field
.getAnnotation(org.powermock.core.classloader.annotations.Mock.class);
final String[] value = annotation.value();
if (value.length != 1 || !"".equals(value[0])) {
System.err
.println("PowerMockito deprecation: Use PowerMockito.spy(..) for partial mocking instead. A standard mock will be created instead.");
}
}

if (field.isAnnotationPresent(org.mockito.Mock.class)) {
org.mockito.Mock mockAnnotation = field.getAnnotation(org.mockito.Mock.class);
Expand Down Expand Up @@ -114,7 +105,7 @@ private void standardInject(Object testInstance) throws IllegalAccessException {
@SuppressWarnings("unchecked")
@Override
public Class<? extends Annotation>[] getMockAnnotations() {
return new Class[]{org.mockito.Mock.class, Mock.class, org.powermock.core.classloader.annotations.Mock.class};
return new Class[]{org.mockito.Mock.class, Mock.class};
}

private Object processAnnotationOn(Captor annotation, Field field) {
Expand Down
Expand Up @@ -17,8 +17,7 @@
package org.powermock.api.mockito.powermocklistener;

/**
* Before each test method all fields annotated with {@link org.mockito.MockitoAnnotations.Mock},
* {@link org.mockito.Mock} or {@link org.powermock.core.classloader.annotations.Mock} have mock objects created for them
* Before each test method all fields annotated with {@link org.mockito.Mock} have mock objects created for them
* and injected to the fields.
*
* @deprecated Test Runners uses an annotation enabling listener per default
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 836c53f

Please sign in to comment.