db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From an...@apache.org
Subject svn commit: r1245718 - /db/jdo/trunk/tck/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/ThrowOnUnknownStandardProperties.java
Date Fri, 17 Feb 2012 19:29:12 GMT
Author: andyj
Date: Fri Feb 17 19:29:12 2012
New Revision: 1245718

URL: http://svn.apache.org/viewvc?rev=1245718&view=rev
Log:
JDO-696 Added fix to use of reflection call of method when expecting an exception to be thrown
- will be the cause of an InvocationTargetException

Modified:
    db/jdo/trunk/tck/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/ThrowOnUnknownStandardProperties.java

Modified: db/jdo/trunk/tck/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/ThrowOnUnknownStandardProperties.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/ThrowOnUnknownStandardProperties.java?rev=1245718&r1=1245717&r2=1245718&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/ThrowOnUnknownStandardProperties.java
(original)
+++ db/jdo/trunk/tck/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/ThrowOnUnknownStandardProperties.java
Fri Feb 17 19:29:12 2012
@@ -1,5 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
 package org.apache.jdo.tck.api.persistencemanagerfactory.config;
 
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.util.Map;
@@ -67,8 +84,13 @@ public class ThrowOnUnknownStandardPrope
             invokeGetPMF(p);
             fail("testUnknownStandardProperty should result in JDOUserException. "
                     + "No exception was thrown.");
-        } catch (JDOUserException x) {
-            // :)
+        } catch (InvocationTargetException ite) {
+            Throwable cause = ite.getCause();
+            if (cause != null && cause instanceof JDOUserException) {
+            	// :)
+            } else {
+                throw new JDOException("PMF threw " + cause + " instead of JDOException");
+            }
         } catch (Exception e) {
             throw new JDOException(
                     "failed to invoke static getPersistenceManagerFactory(Map) method on
PMF class",
@@ -87,8 +109,13 @@ public class ThrowOnUnknownStandardPrope
             invokeGetPMF(p);
             fail("testUnknownStandardProperties should result in JDOUserException. "
                     + "No exception was thrown.");
-        } catch (JDOUserException thrown) {
-            x = thrown;
+        } catch (InvocationTargetException ite) {
+            Throwable cause = ite.getCause();
+            if (cause != null && cause instanceof JDOUserException) {
+                x = (JDOUserException) cause;
+            } else {
+                throw new JDOException("PMF threw " + cause + " instead of JDOException");
+            }
         } catch (Exception e) {
             throw new JDOException(
                     "failed to invoke static getPersistenceManagerFactory(Map) method on
PMF class",



Mime
View raw message