Author: cschneider
Date: Wed Feb 4 16:52:17 2015
New Revision: 1657310
URL: http://svn.apache.org/r1657310
Log:
ARIES-1271 added test
Added:
aries/trunk/jpa/jpa-container/src/test/java/org/apache/aries/jpa/container/quiesce/
aries/trunk/jpa/jpa-container/src/test/java/org/apache/aries/jpa/container/quiesce/impl/
aries/trunk/jpa/jpa-container/src/test/java/org/apache/aries/jpa/container/quiesce/impl/QuiesceEMFHandlerTest.java
Modified:
aries/trunk/jpa/jpa-container/pom.xml
Modified: aries/trunk/jpa/jpa-container/pom.xml
URL:
http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/pom.xml?rev=1657310&r1=1657309&r2=1657310&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container/pom.xml (original)
+++ aries/trunk/jpa/jpa-container/pom.xml Wed Feb 4 16:52:17 2015
@@ -135,6 +135,13 @@
<version>1.1.1</version>
<scope>provided</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.8.2</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
Added:
aries/trunk/jpa/jpa-container/src/test/java/org/apache/aries/jpa/container/quiesce/impl/QuiesceEMFHandlerTest.java
URL:
http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/src/test/java/org/apache/aries/jpa/container/quiesce/impl/QuiesceEMFHandlerTest.java?rev=1657310&view=auto
==============================================================================
---
aries/trunk/jpa/jpa-container/src/test/java/org/apache/aries/jpa/container/quiesce/impl/QuiesceEMFHandlerTest.java
(added)
+++
aries/trunk/jpa/jpa-container/src/test/java/org/apache/aries/jpa/container/quiesce/impl/QuiesceEMFHandlerTest.java
Wed Feb 4 16:52:17 2015
@@ -0,0 +1,27 @@
+package org.apache.aries.jpa.container.quiesce.impl;
+
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+
+import java.lang.reflect.Method;
+
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceException;
+
+import org.junit.Test;
+
+public class QuiesceEMFHandlerTest {
+
+ /**
+ * Tests that we get the real exception thrown by the delegate
+ */
+ @Test(expected=PersistenceException.class)
+ public void testPersistenceExceptionNotWrapped() throws
NoSuchMethodException, SecurityException, Throwable {
+ EntityManagerFactory delegate = mock(EntityManagerFactory.class);
+ doThrow(new PersistenceException()).when(delegate).close();
+ QuiesceEMFHandler emfHandler = new QuiesceEMFHandler(delegate, "");
+ Method method = EntityManagerFactory.class.getMethod("close",
(Class<?>[])null);
+ emfHandler.invoke(delegate, method, null);
+ }
+
+}