Author: oltka
Date: Thu Nov 19 14:37:28 2009
New Revision: 882161

URL: http://svn.apache.org/viewvc?rev=882161&view=rev
Log:
 fix:
 Now single JUnit test cannot be launched separately from Eclipse:
          junit.framework.AssertionFailedError: Exception in constructor: test
            (java.lang.ExceptionInInitializerError
            at
            
org.apache.cayenne.unit.CayenneResources.setConnectionKey(CayenneResources.java:200)

Modified:
    
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/ConnectionProperties.java

Modified: 
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/ConnectionProperties.java
URL: 
http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/ConnectionProperties.java?rev=882161&r1=882160&r2=882161&view=diff
==============================================================================
--- 
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/ConnectionProperties.java
 (original)
+++ 
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/ConnectionProperties.java
 Thu Nov 19 14:37:28 2009
@@ -98,11 +98,14 @@
                 ConnectionProperties cp = new ConnectionProperties(
                         new ExtendedProperties(f.getAbsolutePath()));
 
-                if ((!adapter.startsWith("$")
-                        || !usr.startsWith("$")
-                        || !pass.startsWith("$")
-                        || !url.startsWith("$") || !driver.startsWith("$"))
-                        && 
!System.getProperty("cayenneTestConnection").equals("null")) {
+                if (((adapter != null && !adapter.startsWith("$"))
+                        || (usr != null && !usr.startsWith("$"))
+                        || (pass != null && !pass.startsWith("$"))
+                        || (url != null && !url.startsWith("$")) || (driver != 
null && !driver
+                        .startsWith("$")))
+                        && (System.getProperty("cayenneTestConnection") != 
null && !System
+                                .getProperty("cayenneTestConnection")
+                                .equals("null"))) {
 
                     DataSourceInfo dsiOld = null;
                     if 
(connectionInfos.get(System.getProperty("cayenneTestConnection")) != null) {
@@ -112,31 +115,31 @@
                                 .getProperty("cayenneTestConnection"));
                     }
 
-                    if (!adapter.startsWith("$")) {
+                    if (adapter != null && !adapter.startsWith("$")) {
                         dsi.setAdapterClassName(adapter);
                     }
                     else if (dsiOld != null) {
                         dsi.setAdapterClassName(dsiOld.getAdapterClassName());
                     }
-                    if (!usr.startsWith("$")) {
+                    if (usr != null && !usr.startsWith("$")) {
                         dsi.setUserName(usr);
                     }
                     else if (dsiOld != null) {
                         dsi.setUserName(dsiOld.getUserName());
                     }
-                    if (!pass.startsWith("$")) {
+                    if (pass != null && !pass.startsWith("$")) {
                         dsi.setPassword(pass);
                     }
                     else if (dsiOld != null) {
                         dsi.setPassword(dsiOld.getPassword());
                     }
-                    if (!url.startsWith("$")) {
+                    if (url != null && !url.startsWith("$")) {
                         dsi.setDataSourceUrl(url);
                     }
                     else if (dsiOld != null) {
                         dsi.setDataSourceUrl(dsiOld.getDataSourceUrl());
                     }
-                    if (!driver.startsWith("$")) {
+                    if (driver != null && !driver.startsWith("$")) {
                         dsi.setJdbcDriver(driver);
                     }
                     else if (dsiOld != null) {
@@ -149,25 +152,28 @@
                 }
             }
             else {
-                if ((!adapter.startsWith("$")
-                        || !usr.startsWith("$")
-                        || !pass.startsWith("$")
-                        || !url.startsWith("$") || !driver.startsWith("$"))
-                        && 
!System.getProperty("cayenneTestConnection").equals("null")) {
+                if (((adapter != null && !adapter.startsWith("$"))
+                        || (usr != null && !usr.startsWith("$"))
+                        || (pass != null && !pass.startsWith("$"))
+                        || (url != null && !url.startsWith("$")) || (driver != 
null && !driver
+                        .startsWith("$")))
+                        && (System.getProperty("cayenneTestConnection") != 
null && !System
+                                .getProperty("cayenneTestConnection")
+                                .equals("null"))) {
 
-                    if (!adapter.startsWith("$")) {
+                    if (adapter != null && !adapter.startsWith("$") ) {
                         dsi.setAdapterClassName(adapter);
                     }
-                    if (!usr.startsWith("$")) {
+                    if (usr != null && !usr.startsWith("$")) {
                         dsi.setUserName(usr);
                     }
-                    if (!pass.startsWith("$")) {
+                    if (pass != null && !pass.startsWith("$")) {
                         dsi.setPassword(pass);
                     }
-                    if (!url.startsWith("$")) {
+                    if (url != null && !url.startsWith("$")) {
                         dsi.setDataSourceUrl(url);
                     }
-                    if (!driver.startsWith("$")) {
+                    if (driver != null && !driver.startsWith("$")) {
                         dsi.setJdbcDriver(driver);
                     }
                     
connectionInfos.put(System.getProperty("cayenneTestConnection"), dsi);


Reply via email to