nickylin / powermock

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

Can not run TestSuite when SWT Classes are involved #511

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I have some test for features in an Eclipse RCP project.
No SWT Components are involved directly, but some files needed for the test 
import SWT components. (e.g. org.eclipse.swt.graphics.Image).

When the test are run stand-alone, everything is fine.
But as soon as they are put into a TestSuite, all tests fail with the following 
error:

java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons: 
    no swt-win32-3836 in java.library.path
    no swt-win32 in java.library.path
    Native Library C:\Users\franzm\.swt\lib\win32\x86_64\swt-win32-3836.dll already loaded in another classloader
    Can't load library: C:\Users\franzm\.swt\lib\win32\x86_64\swt-win32.dll

    at org.eclipse.swt.internal.Library.loadLibrary(Library.java:331)
    at org.eclipse.swt.internal.Library.loadLibrary(Library.java:240)
    at org.eclipse.swt.internal.C.<clinit>(C.java:21)
    at org.eclipse.swt.widgets.Widget.<clinit>(Widget.java:103)
    at com.example.app.client.ui.filters.FilterDtoUtil.formatDateFormat(FilterDtoUtil.java:325)
    at com.example.app.client.ui.filters.FilterDtoUtil.getMarketVariantsProductionSitesWithDates(FilterDtoUtil.java:358)
    at com.example.app.client.ui.filters.factories.FilterContributor.getFilterRow(FilterContributor.java:566)
    at com.example.app.client.ui.filters.factories.AbstractBigFilterFactory.getFilterRow(AbstractBigFilterFactory.java:59)
    at com.example.app.client.ui.excelexport.AbstractExcelTest.before(AbstractExcelTest.java:73)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.internal.runners.MethodRoadie.runBefores(MethodRoadie.java:132)
    at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:95)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.executeTest(PowerMockJUnit44RunnerDelegateImpl.java:294)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTestInSuper(PowerMockJUnit47RunnerDelegateImpl.java:127)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTest(PowerMockJUnit47RunnerDelegateImpl.java:82)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runBeforesThenTestThenAfters(PowerMockJUnit44RunnerDelegateImpl.java:282)
    at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:86)
    at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:49)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.invokeTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:207)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.runMethods(PowerMockJUnit44RunnerDelegateImpl.java:146)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.run(PowerMockJUnit44RunnerDelegateImpl.java:120)
    at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:33)
    at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:45)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.run(PowerMockJUnit44RunnerDelegateImpl.java:118)
    at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:104)
    at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:53)
    at org.powermock.modules.junit4.PowerMockRunner.run(PowerMockRunner.java:53)
    at org.junit.runners.Suite.runChild(Suite.java:127)
    at org.junit.runners.Suite.runChild(Suite.java:26)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

From my point of view, PowerMockito tries to load the DLL for every tests and 
blocks itself there.

Original issue reported on code.google.com by mirco.fr...@gmail.com on 7 Aug 2014 at 7:36

GoogleCodeExporter commented 9 years ago
You need to suppress the static initializer that loads the DLL.

Original comment by johan.ha...@gmail.com on 28 Aug 2014 at 11:30

GoogleCodeExporter commented 9 years ago
Can you give me a hint how?

Original comment by mirco.fr...@gmail.com on 2 Sep 2014 at 6:07

GoogleCodeExporter commented 9 years ago
Did you come up with a solution for this?

Original comment by Drew.But...@gmail.com on 12 Sep 2014 at 5:42