Giter VIP home page Giter VIP logo

powermock's People

powermock's Issues

Fail to mock class that directly extends java.lang.Object

The new constructor suppression algorithm doesn't work for classes that
directly extend from java.lang.Object since Object doesn't contain a ctor
with with argument IndicateReloadClass. We must change the implementation
in the MainMockTransformers' edit(ConstructorCall c) method to check if the
super class is of type Object before defering the call.


Original issue reported on code.google.com by [email protected] on 24 Oct 2008 at 1:05

We need a better error message when expectNew fails due to too many calls to new.

If we do expectNew(MyClass.class) once but it's called twice we should get
a more descriptive error message than the following: 

java.lang.RuntimeException: java.lang.AssertionError: 
  Unexpected method call createInstance():
    createInstance(): expected: 1, actual: 1 (+1)
    at org.powermock.Whitebox.performMethodInvocation(Whitebox.java:788)
    at org.powermock.Whitebox.invokeMethod(Whitebox.java:268)
    at se.myapp.MyTest.testCreateDomainTarget(MyTest.java:577)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

We could perhaps catch the AssertionError in MockGateway line 117 ( return
newInvocationControl.createInstance()) and throw another AssertionError
with a better description instead.

Original issue reported on code.google.com by [email protected] on 11 Sep 2008 at 8:59

Add support for makeThreadSafe

In EasyMock 2.4 you explicitly need to tell the mock whether it should be
used in multiple threads or not. We need to investigate if we need add a
makeThreadSafe method in our API or if you can use makeThreadSafe from
class extension on our mocks.

Original issue reported on code.google.com by [email protected] on 23 Oct 2008 at 9:27

WhiteBox.getMethod(..) should also return protected and package-private methods.

If we have a class like this: 

public final class SomeHelper {

    private SomeHelper() {

    }

    static class MyPlugin extends MyCorePlugin {
        public MyPlugin() {
            setLogManager(new MockLogManager());
        }  
    }

    ...

}

and load the classes are loaded from our classloader the MockGateway
performs a check, suppressMethod.contains(Whitebox.getMethod(objectType,
methodName, sig)), for the MyPlugin invokation of the setLogManager method.
However if setLogManager is protected the Whitebox.getMethod(..) won't find
the method because it's neither public or private. We need to address this!!

Original issue reported on code.google.com by [email protected] on 28 Oct 2008 at 3:25

Matchers doesn't work for arguments with expectPrivate

This doesn't work:
      expectPrivate(tested, getNewStringBuilderMethodName,
aryEq(message)).andReturn(expected);

It will produce:
java.lang.NullPointerException
    at org.powermock.Whitebox.findMethodOrThrowException(Whitebox.java:364)
    at org.powermock.PowerMock.expectPrivate(PowerMock.java:714)
    at
se.myapp.service.model.LineSplitDataPackageWriterTest.testWrite_singleMessageWit
hNewLine(LineSplitDataPackageWriterTest.java:93)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
    at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
    at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
    at
org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadi
e.java:87)
    at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
    at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
    at
org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.in
vokeTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:162)
    at
org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.ru
nMethods(PowerMockJUnit44RunnerDelegateImpl.java:119)
    at
org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.
run(PowerMockJUnit44RunnerDelegateImpl.java:112)
    at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
    at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
    at
org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.ru
n(PowerMockJUnit44RunnerDelegateImpl.java:110)
    at
org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run
(JUnit4TestSuiteChunkerImpl.java:74)
    at
org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.
run(AbstractCommonPowerMockRunner.java:43)
    at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReferen
ce.java:45)
    at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner
.java:460)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner
.java:673)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java
:386)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.jav
a:196)


Original issue reported on code.google.com by [email protected] on 9 Sep 2008 at 2:58

ExpectNew doesn't work properly when throwing exceptions!

Method looks like:
private Target createDomainTarget(ITarget target, boolean connecting) {
        Target domainTarget = null;
        try {
            domainTarget = new Target(getTargetName(target, connecting),
target.getId());
        } catch (MyException e) {
            log.warn("Failed to get the target data from service");
            domainTarget = new Target("Unknown", -1);
        }
        return domainTarget;
    }

test looks like:

    expectNew(Target.class).andThrow(new MyException("error!"));

        final String getTargetNameMethodName = "getTargetName";
        tested =
            mockMethod(ServiceTracker.class, new String[] {
                getTargetNameMethodName}, mServiceMock,
mAutoOpenDataStreamServiceMock,
                mDataProviderAddedOrRemovedNotifierMock,
mTargetAddedOrRemovedNotifierMock);

        final boolean connecting = true;
        final String expectedTargetName = "Unknown";
        final int expectedId = -1;

        expectPrivate(tested, getTargetNameMethodName, mTargetMock1,
connecting).andReturn("A name");
        expect(mTargetMock1.getId()).andReturn(2);

        replayAll();

        Target actual = (Target) Whitebox.invokeMethod(tested,
"createDomainTarget", new Class<?>[] {
            ITarget.class, boolean.class}, mTargetMock1, connecting);

        verifyAll();

        assertEquals(expectedTargetName, actual.getName());
        assertEquals(expectedId, actual.getId());

Causes error stack:
java.lang.NullPointerException
    at
se.ericsson.eab.sdk.logcoordinator.service.DebugMuxServiceTrackerTest.testCreate
DomainTarget_ITarget_fails(DebugMuxServiceTrackerTest.java:545)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
    at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
    at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
    at
org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadi
e.java:87)
    at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
    at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
    at
org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.in
vokeTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:162)
    at
org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.ru
nMethods(PowerMockJUnit44RunnerDelegateImpl.java:119)
    at
org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.
run(PowerMockJUnit44RunnerDelegateImpl.java:112)
    at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
    at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
    at
org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.ru
n(PowerMockJUnit44RunnerDelegateImpl.java:110)
    at
org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run
(JUnit4TestSuiteChunkerImpl.java:74)
    at
org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.
run(AbstractCommonPowerMockRunner.java:43)
    at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReferen
ce.java:45)
    at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner
.java:460)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner
.java:673)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java
:386)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.jav
a:196)

The problem is that when invoking new Target(..) the exception doesn't seem
to be thrown or at least the execution is not reflected in the code, i.e.
log.warn(..) etc is never called. A new target is never created though.

Original issue reported on code.google.com by [email protected] on 8 Sep 2008 at 7:56

Investigate if we should byte-code manipulate an entire hierarchy

Let's say we have a class called A which extends B. Suppose B has a
protected method called "myMethod" and we wish to create a partial mock of
A where only this method is mocked. Now we need to do both
@PrepareForTest({A.class, B.class}) which is non intuitive, perhaps we
should implicitly load B with the MockClassloader when doing
@PrepareForTest(A.class)?

Original issue reported on code.google.com by [email protected] on 29 Oct 2008 at 11:34

Only mock specific calls to new

Let's say you have a method like this:

private Target createTarget(ITarget target) {
        Target domainTarget = null;
        try {
            domainTarget = new Target(getTargetName(target), target.getId());
        } catch (CreationException e) {
            domainTarget = new Target("Unknown", -1);
        }
        return domainTarget;
}

In one case here we'd like to mock the first instance creation of Target
and throw a CreationException but we'd like to make sure that a new Target
has been created with parameters "Unknown" and -1. This is not possible today.

Original issue reported on code.google.com by [email protected] on 11 Sep 2008 at 9:03

SuppressConstructorCode must work for ANY class

Right now suppressConstructorCode doesn't work in this case:

suppressConstructorCode(A.class) when A is instantiated in the test class. 

If A extends from B then it's ok to do suppressConstructorCode(B.class). 


Original issue reported on code.google.com by [email protected] on 11 Sep 2008 at 7:27

verify/replay doesn't work properly when mixing classes and instances

verify calls verifyClass which clears the state! We need to refactor
verifyClass to a new private method that doesn't clear state.
verify(object...) and verifyClass should call this new method (the old
verifyClass _should_ clear state though). 

This happens when you do PowerMock.verify(MyClass.class, myInstance,
myInstance2); Before myInstance has been verified the PowerMock state has
been cleared.


Original issue reported on code.google.com by [email protected] on 9 Sep 2008 at 1:43

Generate binary release

Automatically generate all binary releases from maven. We want to have
pre-packaged jar files for powermock-junit3, powermock-junit4-legacy and
powermock-junit4. Ie project should only have to include a single powermock
jar file instead of multiple files. This will greatly simplify the use of
PowerMock for projects not using maven.

Original issue reported on code.google.com by [email protected] on 3 Sep 2008 at 3:06

invokeMethod throws NPE when an argument is null when the method cannot be found

java.lang.NullPointerException
at org.powermock.Whitebox.getArgumentsAsString(Whitebox.java:529)
at org.powermock.Whitebox.throwExceptionIfMethodWasNotFound(Whitebox.java:508)
at org.powermock.Whitebox.findMethodOrThrowException(Whitebox.java:425)
at org.powermock.Whitebox.doInvokeMethod(Whitebox.java:341)
at org.powermock.Whitebox.invokeMethod(Whitebox.java:277)

Original issue reported on code.google.com by [email protected] on 27 Oct 2008 at 1:18

Whitebox.invokeMethod must be able to run methods in a super class.

Whitebox.invokeMethod should be able to execute a private method in
somewhere in the class hierarchy. For example if one creates an anonymous
inner class of the class under test to override some public methods you'd
still like to be able to invoke private methods in the "concrete class".

Original issue reported on code.google.com by [email protected] on 28 Oct 2008 at 12:51

Support recursive partial mocking

It would be cool to support "recursive partial mocking". 

Imagine this: 
void addFolderToLogPaths(final File logFolder, final List<LogFile> logFileList,
        final Collection<ITargetPersistenceUnit> persistentUnits) {
        if (!logFolder.isDirectory()) {
            throw new IllegalArgumentException("logPath is not a directory.");
        }

        final File[] allLogFiles = logFolder.listFiles();
        for (File fileOrDirectory : allLogFiles) {
            if (fileOrDirectory.isDirectory()) {
                addFolderToLogPaths(fileOrDirectory, logFileList,
persistentUnits);
            } else {
                logFileList.add(new
LogFile(getRelativeLogPath(fileOrDirectory), fileOrDirectory.lastModified(),
                    isFileReplayable(persistentUnits, fileOrDirectory)));
            }
        }
    }

We could implement so that one call to addFolderToLogPaths (the actual test
invocation) passes the MockGateway but sequential invocations should be
mocked. 

Original issue reported on code.google.com by [email protected] on 1 Oct 2008 at 12:54

Add replay all functionality

Investigate if it's possible to maintain a list of all mock objects created
by powermock. This would enable replayAll() and verifyAll().

Original issue reported on code.google.com by [email protected] on 28 Oct 2008 at 12:27

expectNew(..).andThrow(..) no longer works with checked exceptions.

For some reason it seems like the NewInvocationControl has been reverted
and doesn't support checked exceptions anymore. 

NewInvocationControl should probably contain the method 
public T createInstance() *throws Exception*;

Otherwise we'll run into:
java.lang.IllegalArgumentException: last method called on mock cannot throw
java.io.IOException
    at org.easymock.internal.MocksControl.andThrow(MocksControl.java:110)
    atse.myapp.TargetPersistenceManagerTest.testTargetConnect_failsToCreateFileName(TargetPersistenceManagerTest.java:418)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
    at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
    at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
    at
org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadi
e.java:87)
    at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
    at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
    at
org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.in
vokeTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:162)
    at
org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.ru
nMethods(PowerMockJUnit44RunnerDelegateImpl.java:119)
    at
org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.
run(PowerMockJUnit44RunnerDelegateImpl.java:112)
    at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
    at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
    at
org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.ru
n(PowerMockJUnit44RunnerDelegateImpl.java:110)
    at
org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run
(JUnit4TestSuiteChunkerImpl.java:74)
    at
org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.
run(AbstractCommonPowerMockRunner.java:43)
    at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReferen
ce.java:45)
    at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner
.java:460)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner
.java:673)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java
:386)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.jav
a:196)


It doesn't seem like the ExpectNewDemoTest#testNewWithCheckedException test
case tests for checked exceptions at all!!!

Original issue reported on code.google.com by [email protected] on 1 Oct 2008 at 8:34

You shouldn't need to add all classes in a heirarchy when suppression constructors

When using suppressConstructorHeirachy you should be able to do:


@PrepareForTest( SuppressConstructorHierarchyChild.class )
@RunWith(PowerMockRunner.class)
public class SuppressConstructorHierarchyDemoTest {
    @Test
    public void testSuppressConstructor() throws Exception {

suppressConstructorCodeHierarchy(SuppressConstructorHierarchyChild.class);
}
..
}

instead of 
@PrepareForTest( { SuppressConstructorHierarchyChild.class,
SuppressConstructorHierarchyParent.class,
        SuppressConstructorHeirarchyEvilGrandParent.class })
@RunWith(PowerMockRunner.class)
public class SuppressConstructorHierarchyDemoTest {
..
}

Original issue reported on code.google.com by [email protected] on 12 Oct 2008 at 7:38

PowerMock doesn't work correctly when using cobertura and Maven

There seems to be a problem with cobertura, Maven and PowerMock.

For example adding cobertura to the DocumentationExamples project results
in the following error message (on Linux as well after configuring surefire
with cobertura.use.java.nio to false): 

Cobertura: Loaded information on 5 classes.
Cobertura: Coverage data file
/home/johan/devtools/java/projects/powermock/examples/DocumentationExamples/targ
et/cobertura/cobertura.ser
either does not exist or is not readable.  Creating a new data file.
Cobertura: Error reading file
/home/johan/devtools/java/projects/powermock/examples/DocumentationExamples/targ
et/cobertura/cobertura.ser:
null
Cobertura: Saved information on 1 classes.
Cobertura: Error reading file
/home/johan/devtools/java/projects/powermock/examples/DocumentationExamples/targ
et/cobertura/cobertura.ser:
null
Cobertura: Coverage data file
/home/johan/devtools/java/projects/powermock/examples/DocumentationExamples/targ
et/cobertura/cobertura.ser
either does not exist or is not readable.  Creating a new data file.
Cobertura: Saved information on 5 classes.
Cobertura: Saved information on 1 classes.
[INFO] [cobertura:cobertura]
[INFO] Cobertura 1.9 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
Cobertura: Loaded information on 1 classes.
[cobertura] INFO  [main]
net.sourceforge.cobertura.reporting.html.HTMLReport - Data file does not
contain instrumentation information for the file
powermock/examples/staticmocking/ServiceRegistrator.java.  Ensure this
class was instrumented, and this data file contains the instrumentation
information.
Report time: 119ms

We need to address this if possible.

Original issue reported on code.google.com by [email protected] on 1 Oct 2008 at 7:13

doInvokeMethod method in PowerMock should treat the InvokationTargetException separately

Right now the doInvokeMethod catches all exceptions and wrap them in a RTE.
This is wrong. The InvokationTargetException should be caught explicitly
and the cause of this exceptions should be thrown instead. This to avoid
error stacks like this:

java.lang.RuntimeException: Failed to invoke method 'assertLogFileSet'.
Reason was: 'null'.
    at org.powermock.PowerMock.doInvokeMethod(PowerMock.java:1123)
    at org.powermock.PowerMock.expectVoid(PowerMock.java:723)
    at
se.mayapp.TargetPersistenceManagerTest.testGetLogFileList(TargetPersistenceManag
erTest.java:454)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
    at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
    at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
    at
org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadi
e.java:87)
    at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
    at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
    at
org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.in
vokeTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:162)
    at
org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.ru
nMethods(PowerMockJUnit44RunnerDelegateImpl.java:119)
    at
org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.
run(PowerMockJUnit44RunnerDelegateImpl.java:112)
    at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
    at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
    at
org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.ru
n(PowerMockJUnit44RunnerDelegateImpl.java:110)
    at
org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run
(JUnit4TestSuiteChunkerImpl.java:74)
    at
org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.
run(AbstractCommonPowerMockRunner.java:43)
    at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReferen
ce.java:45)
    at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner
.java:460)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner
.java:673)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java
:386)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.jav
a:196)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.powermock.PowerMock.doInvokeMethod(PowerMock.java:1121)
    ... 26 more
Caused by: java.lang.IllegalStateException: You need to set the log path
before using the target persistence manager.
    at
se.mayapp.TargetPersistenceManager.assertLogFileSet(TargetPersistenceManager.jav
a:123)
    ... 31 more

I.e. the actual exception should be "java.lang.IllegalStateException: You
need to set the log path before using the target persistence manager."


Original issue reported on code.google.com by [email protected] on 1 Oct 2008 at 11:46

Create a compatibility junit runner

We should create a "compatibility" runner for JUnit 4 and perhaps JUnit 3.
This means a Junit runner without any chunking. The chunking is tightly
coupled to internal Junit4 functionality and for custom versions of JUnit
our chunking mechanism will fail (for example in the Eclipse JUnit
version). Using a compatibility runner it would be possible to launch
PowerMock (without chunking support) with custom JUnit versions.

Original issue reported on code.google.com by [email protected] on 23 Sep 2008 at 11:05

Remove final from static fields

In some cases you want to be able to change a static final field. For
example is you need to suppress the static initializer for a class but
later need to set a final static field. We should thus remove the final
modifier from all static fields.

Original issue reported on code.google.com by [email protected] on 24 Oct 2008 at 12:51

Remove final from static fields

In some cases you want to be able to change a static final field. For
example is you need to suppress the static initializer for a class but
later need to set a final static field. We should thus remove the final
modifier from all static fields.

Original issue reported on code.google.com by [email protected] on 24 Oct 2008 at 12:50

Test should be sorted

Our test runner runs the tests in a different order than the default junit
runner. This should be fixed.

Original issue reported on code.google.com by [email protected] on 26 Oct 2008 at 7:41

createPartialMock should support private constructors with no arguments

E.g. MyClass myClassMock = PowerMock.createPartialMock(MyClass.class, new
String[]{"loadMyClassDLL"}, null); 

For ctor:
    private MyClass() {
        this.initialized = false;
        this.connectedDUTs = new HashSet<Byte>();
    }

Generates the following error: 
java.lang.NullPointerException
        at org.powermock.Whitebox.getArgumentsAsString(Whitebox.java:526)
        at
org.powermock.Whitebox.throwExceptionIfConstructorWasNotFound(Whitebox.java:512)
        at
org.powermock.Whitebox.findConstructorOrThrowException(Whitebox.java:499)
        at org.powermock.PowerMock.createPartialMock(PowerMock.java:636)
        at
se.ericsson.eab.sdk.jMyClasswrapper.MyClassTest.connectToDUTFail(MyClassTest.jav
a:358)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at

Original issue reported on code.google.com by [email protected] on 24 Oct 2008 at 12:56

findConstructorOrThrowException and findMethodOrThrowException have critical bugs

findConstructorOrThrowException in Whitebox have two critical bugs which
effects other parts of PowerMock (for example createPartialMock). 
1:
if (!paramTypes[i].equals(arguments[i].getClass())) {
    wrappedConstructorFound = false;
    break;
}
Solution: arguments[i].getClass() must be changed to
getUnmockedType(arguments[i].getClass())

2: 
The findPrimitiveMethodOrConstructor should be renamed to
hasWrapperArguments(return value must change from true to false)
If a primitive constructor is found parameter checking must take place!!!
This doesn't happen today!!

Original issue reported on code.google.com by [email protected] on 24 Oct 2008 at 9:36

createPartialMock no longer works as expected.

Because we're adding a defer constructor in each class this will have
implications when creating partial mocks if there's only one constructor in
the class. I.e.

   tested = createPartialMock(LineSplitDataPackageWriter.class, new String[] {
            ""}, mDataWriterMock);

java.lang.RuntimeException: Several matching constructors found, please
specify the argument parameter types so that PowerMock can determine which
method you're refering to.
Matching constructors in class se.myapp.LineSplitDataPackageWriter were:
se.myapp.service.model.LineSplitDataPackageWriter(
org.powermock.core.classloader.annotations.internal.IndicateReloadClass.class )
se.myapp.service.model.LineSplitDataPackageWriter(
se.myapp.IDataPackageWriter.class )

Original issue reported on code.google.com by [email protected] on 24 Oct 2008 at 7:26

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.