nazymko / powermock

Automatically exported from code.google.com/p/powermock
0 stars 0 forks source link

org.hibernate.ejb.HibernatePersistence cannot be cast to javax.persistence.spi.PersistenceProvider #112

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The following JUnit testcode:

package org.test;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

@RunWith(PowerMockRunner.class)
@PrepareForTest({
    MyTest.class
    })
public class MyTest {

    @Test
    public void testOK() throws Exception {

        EntityManagerFactory emf = Persistence.createEntityManagerFactory("test");
    }
}

Expected output: test should run.
What do you see instead: Exception "org.hibernate.ejb.HibernatePersistence
cannot be cast to javax.persistence.spi.PersistenceProvider"

What version of the product are you using? PowerMock 1.2.5 + EasyMock 2.4
Operating system? : Windows XP SP3

It seems that somehow adding the annotation
"@PrepareForTest({
    MyTest.class
    })"
changes/reorders the classpath.

Any solution for this?

Original issue reported on code.google.com by stef.hey...@gmail.com on 28 May 2009 at 3:41

GoogleCodeExporter commented 8 years ago
Hi, could you please use to mailing list instead (powermock@googlegroups.com) 
so that
more people can see what you're asking?

Original comment by johan.ha...@gmail.com on 29 May 2009 at 8:28

GoogleCodeExporter commented 8 years ago
Done.

Original comment by stef.hey...@gmail.com on 3 Jun 2009 at 11:57

GoogleCodeExporter commented 8 years ago
I haven't seen the post on the mailing-list yet. Are you sure you've sent it?

Original comment by johan.ha...@gmail.com on 4 Jun 2009 at 8:24

GoogleCodeExporter commented 8 years ago
@PowerMockIgnore can be used (this is a known side-effect)

Original comment by johan.ha...@gmail.com on 5 Jun 2009 at 6:56