// Path: powermock-modules/powermock-module-junit4/src/main/java/org/powermock/modules/junit4/PowerMockRunner.java
// public class PowerMockRunner extends AbstractCommonPowerMockRunner {
// 
//     public PowerMockRunner(Class<?> klass) throws Exception {
//         super(klass, getRunnerDelegateImplClass(klass));
//     }
//     
//     private static Class<? extends PowerMockJUnitRunnerDelegate> getRunnerDelegateImplClass(Class<?> klass) {
//         if (klass.isAnnotationPresent(PowerMockRunnerDelegate.class)
//                 || Boolean.getBoolean("powermock.implicitDelegateAnnotation")) {
//             return DelegatingPowerMockRunner.class;
//         }
// 
//         Class<? extends PowerMockJUnitRunnerDelegate> concreteClass = PowerMockJUnit44RunnerDelegateImpl.class;
//         if(JUnitVersion.isGreaterThanOrEqualTo("4.9")) {
//                    concreteClass = PowerMockJUnit49RunnerDelegateImpl.class;
//         } else if( JUnitVersion.isGreaterThanOrEqualTo("4.7") ) {
//             concreteClass = PowerMockJUnit47RunnerDelegateImpl.class;
//         }
//         return concreteClass;
//     }
// 
//     /**
//      * Clean up some state to avoid OOM issues
//      */
//     @Override
//     public void run(RunNotifier notifier) {
//         Description description = getDescription();
//         try {
//             super.run(notifier);
//         } finally {
//             Whitebox.setInternalState(description, "fAnnotations", new Annotation[]{});
//         }
//     }
// }


import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import samples.expectnew.PrimitiveAndWrapperDemo;
import samples.expectnew.PrimitiveAndWrapperUser;
import static org.easymock.EasyMock.expect;
import static org.junit.Assert.assertEquals;
import static org.powermock.api.easymock.PowerMock.*;
package samples.junit4.expectnew;



/**
 * Unit test for the {@link PrimitiveAndWrapperUser} class.
 */
@RunWith(PowerMockRunner.class)
@PrepareForTest(PrimitiveAndWrapperUser.class)
public class PrimitiveAndWrapperUserTest {

	@Test
	public void testNewWithStrictMocking_ok() throws Exception {
		PrimitiveAndWrapperDemo mock1 = createStrictMockAndExpectNew(PrimitiveAndWrapperDemo.class, new Class<?>[] { Integer.class }, 42);
		PrimitiveAndWrapperDemo mock2 = createStrictMockAndExpectNew(PrimitiveAndWrapperDemo.class, new Class<?>[] { int.class }, 21);

		expect(mock1.getMyInt()).andReturn(10);
		expect(mock2.getMyInt()).andReturn(21);

		replayAll();

		assertEquals(31, new PrimitiveAndWrapperUser().useThem());

		verifyAll();
	}

	@Test(expected = AssertionError.class)
	public void testNewWithStrictMocking_notOk() throws Exception {
		PrimitiveAndWrapperDemo mock2 = createStrictMockAndExpectNew(PrimitiveAndWrapperDemo.class, new Class<?>[] { int.class }, 21);
		PrimitiveAndWrapperDemo mock1 = createStrictMockAndExpectNew(PrimitiveAndWrapperDemo.class, new Class<?>[] { Integer.class }, 42);

		expect(mock1.getMyInt()).andReturn(10);
		expect(mock2.getMyInt()).andReturn(21);

		replayAll();

		assertEquals(31, new PrimitiveAndWrapperUser().useThem());

		verifyAll();
	}

// Path: powermock-modules/powermock-module-junit4/src/main/java/org/powermock/modules/junit4/PowerMockRunner.java
// public class PowerMockRunner extends AbstractCommonPowerMockRunner {
// 
//     public PowerMockRunner(Class<?> klass) throws Exception {
//         super(klass, getRunnerDelegateImplClass(klass));
//     }
//     
//     private static Class<? extends PowerMockJUnitRunnerDelegate> getRunnerDelegateImplClass(Class<?> klass) {
//         if (klass.isAnnotationPresent(PowerMockRunnerDelegate.class)
//                 || Boolean.getBoolean("powermock.implicitDelegateAnnotation")) {
//             return DelegatingPowerMockRunner.class;
//         }
// 
//         Class<? extends PowerMockJUnitRunnerDelegate> concreteClass = PowerMockJUnit44RunnerDelegateImpl.class;
//         if(JUnitVersion.isGreaterThanOrEqualTo("4.9")) {
//                    concreteClass = PowerMockJUnit49RunnerDelegateImpl.class;
//         } else if( JUnitVersion.isGreaterThanOrEqualTo("4.7") ) {
//             concreteClass = PowerMockJUnit47RunnerDelegateImpl.class;
//         }
//         return concreteClass;
//     }
// 
//     /**
//      * Clean up some state to avoid OOM issues
//      */
//     @Override
//     public void run(RunNotifier notifier) {
//         Description description = getDescription();
//         try {
//             super.run(notifier);
//         } finally {
//             Whitebox.setInternalState(description, "fAnnotations", new Annotation[]{});
//         }
//     }
// }


// Path: tests/easymock/junit4/src/test/java/samples/junit4/expectnew/PrimitiveAndWrapperUserTest.java
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import samples.expectnew.PrimitiveAndWrapperDemo;
import samples.expectnew.PrimitiveAndWrapperUser;
import static org.easymock.EasyMock.expect;
import static org.junit.Assert.assertEquals;
import static org.powermock.api.easymock.PowerMock.*;

package samples.junit4.expectnew;



/**
 * Unit test for the {@link PrimitiveAndWrapperUser} class.
 */
@RunWith(PowerMockRunner.class)
@PrepareForTest(PrimitiveAndWrapperUser.class)
public class PrimitiveAndWrapperUserTest {

	@Test
	public void testNewWithStrictMocking_ok() throws Exception {
		PrimitiveAndWrapperDemo mock1 = createStrictMockAndExpectNew(PrimitiveAndWrapperDemo.class, new Class<?>[] { Integer.class }, 42);
		PrimitiveAndWrapperDemo mock2 = createStrictMockAndExpectNew(PrimitiveAndWrapperDemo.class, new Class<?>[] { int.class }, 21);

		expect(mock1.getMyInt()).andReturn(10);
		expect(mock2.getMyInt()).andReturn(21);

		replayAll();

		assertEquals(31, new PrimitiveAndWrapperUser().useThem());

		verifyAll();
	}

	@Test(expected = AssertionError.class)
	public void testNewWithStrictMocking_notOk() throws Exception {
		PrimitiveAndWrapperDemo mock2 = createStrictMockAndExpectNew(PrimitiveAndWrapperDemo.class, new Class<?>[] { int.class }, 21);
		PrimitiveAndWrapperDemo mock1 = createStrictMockAndExpectNew(PrimitiveAndWrapperDemo.class, new Class<?>[] { Integer.class }, 42);

		expect(mock1.getMyInt()).andReturn(10);
		expect(mock2.getMyInt()).andReturn(21);

		replayAll();

		assertEquals(31, new PrimitiveAndWrapperUser().useThem());

		verifyAll();
	}

	@Test