Willam2004 / powermock

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

Problem with try without sentences #549

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

mockStatic of class with a try (style Java7) without sentences. For exemple:
PowerMockito.mockStatic(ServiceLocator.class);

and ServiceLocator.java contains:
try (Connection c = ServiceLocator.ds.getConnection()) {
} catch (Exception e) {
throw new ServiceLocatorInitException(msg, e);
}

I obtain the exception in the attach.

What version of the product are you using? On what operating system?
<dependency>
  <groupId>org.powermock</groupId>
  <artifactId>powermock-module-junit4</artifactId>
  <version>1.6.0</version>
  <scope>test</scope>
</dependency>

<dependency>
  <groupId>org.powermock</groupId>
  <artifactId>powermock-api-mockito</artifactId>
  <version>1.6.0</version>
  <scope>test</scope>
</dependency>

I test with 1.6.2 and same problem. Windows and Lynux.

Original issue reported on code.google.com by voyadomi...@gmail.com on 11 Jun 2015 at 11:41

Attachments:

GoogleCodeExporter commented 9 years ago
And this runs fine:
                try (Connection c = ServiceLocator.ds.getConnection()) {
                    int i=0;
                } catch (Exception e) {
                    String msg = "Error al inicializar la conexion a la BBDD.";
                }

Original comment by voyadomi...@gmail.com on 11 Jun 2015 at 11:43