FAQ
Hi Olga,

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)
at
org.apache.cayenne.unit.CayenneResources.loadResources(CayenneResources.java:86)
at
org.apache.cayenne.unit.CayenneResources.getResources(CayenneResources.java:104)
at org.apache.cayenne.unit.CayenneCase.(RemoteCayenneCase.java:33)
at org.apache.cayenne.remote.PropertyTest.<init>(PropertyTest.java:27)
... ans so on
Caused by: java.lang.NullPointerException
at
org.apache.cayenne.unit.ConnectionProperties.loadDefaultProperties(ConnectionProperties.java:101)
at
org.apache.cayenne.unit.ConnectionProperties.<clinit>(ConnectionProperties.java:70)
... 19 more

Can we use default values for properties missing?

2009/11/19 <oltka@apache.org>
Author: oltka
Date: Thu Nov 19 09:05:56 2009
New Revision: 882084

URL: http://svn.apache.org/viewvc?rev=882084&view=rev
Log:
move ConnectionProperties class from src/main/java to
/src/test/java/org/apache/cayenne/unit/

Added:

cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/ConnectionProperties.java
- copied, changed from r881884,
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/ConnectionProperties.java
Removed:

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

cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/conf/ConnectionPropertiesTest.java

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

cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/Provider.java

Modified:
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/conf/ConnectionPropertiesTest.java
URL:
http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/conf/ConnectionPropertiesTest.java?rev=882084&r1=882083&r2=882084&view=diff

==============================================================================
---
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/conf/ConnectionPropertiesTest.java
(original)
+++
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/conf/ConnectionPropertiesTest.java
Thu Nov 19 09:05:56 2009
@@ -25,6 +25,7 @@

import org.apache.commons.collections.ExtendedProperties;
import org.apache.cayenne.conn.DataSourceInfo;
+import org.apache.cayenne.unit.ConnectionProperties;

/**
*/

Modified:
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/CayenneResources.java
URL:
http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/CayenneResources.java?rev=882084&r1=882083&r2=882084&view=diff

==============================================================================
---
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/CayenneResources.java
(original)
+++
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/CayenneResources.java
Thu Nov 19 09:05:56 2009
@@ -29,7 +29,6 @@

import org.apache.cayenne.CayenneRuntimeException;
import org.apache.cayenne.access.DataNode;
-import org.apache.cayenne.conf.ConnectionProperties;
import org.apache.cayenne.conn.DataSourceInfo;
import org.apache.cayenne.conn.PoolDataSource;
import org.apache.cayenne.conn.PoolManager;

Copied:
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/ConnectionProperties.java
(from r881884,
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/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?p2=cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/ConnectionProperties.java&p1=cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/ConnectionProperties.java&r1=881884&r2=882084&rev=882084&view=diff

==============================================================================
---
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/ConnectionProperties.java
(original)
+++
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/ConnectionProperties.java
Thu Nov 19 09:05:56 2009
@@ -17,7 +17,7 @@
* under the License.
****************************************************************/

-package org.apache.cayenne.conf;
+package org.apache.cayenne.unit;

import java.io.BufferedWriter;
import java.io.File;
@@ -33,8 +33,6 @@
import org.apache.cayenne.conn.DataSourceInfo;
import org.apache.cayenne.project.CayenneUserDir;
import org.apache.commons.collections.ExtendedProperties;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;

/**
* ConnectionProperties handles a set of DataSourceInfo objects using
information stored
@@ -43,7 +41,6 @@
*/
public class ConnectionProperties {

- private static Log logObj =
LogFactory.getLog(ConnectionProperties.class);
public static final String EMBEDDED_DATASOURCE =
"internal_embedded_datasource";
public static final String EMBEDDED_DATASOURCE_DBADAPTER =
"org.apache.cayenne.dba.hsqldb.HSQLDBAdapter";
public static final String EMBEDDED_DATASOURCE_USERNAME = "sa";
@@ -271,7 +268,7 @@
/**
* Creates a DataSourceInfo object from a set of properties.
*/
- protected DataSourceInfo buildDataSourceInfo(ExtendedProperties props)
{
+ public DataSourceInfo buildDataSourceInfo(ExtendedProperties props) {
DataSourceInfo dsi = new DataSourceInfo();

String adapter = props.getString(ADAPTER_KEY);
@@ -293,7 +290,7 @@
/**
* Returns a list of connection names configured in the properties
object.
*/
- protected List<String> extractNames(ExtendedProperties props) {
+ public List<String> extractNames(ExtendedProperties props) {
Iterator it = props.getKeys();
List<String> list = new ArrayList<String>();


Modified:
cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/Provider.java
URL:
http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/Provider.java?rev=882084&r1=882083&r2=882084&view=diff

==============================================================================
---
cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/Provider.java
(original)
+++
cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/Provider.java
Thu Nov 19 09:05:56 2009
@@ -39,7 +39,6 @@
import org.apache.cayenne.access.DbGenerator;
import org.apache.cayenne.access.dbsync.SkipSchemaUpdateStrategy;
import org.apache.cayenne.conf.Configuration;
-import org.apache.cayenne.conf.ConnectionProperties;
import org.apache.cayenne.conf.ResourceFinder;
import org.apache.cayenne.dba.AutoAdapter;
import org.apache.cayenne.dba.DbAdapter;
@@ -82,17 +81,17 @@
public static final String CREATE_SCHEMA_PROPERTY =
"org.apache.cayenne.schema.create";
public static final String DATA_SOURCE_FACTORY_PROPERTY =
"org.apache.cayenne.jpa.jpaDataSourceFactory";

- // ... DataSource
+ // ... DataSource see ConnectionProperties
public static final String ADAPTER_PROPERTY = "org.apache.cayenne."
- + ConnectionProperties.ADAPTER_KEY;
+ + "adapter";
public static final String DATA_SOURCE_DRIVER_PROPERTY =
"org.apache.cayenne.datasource."
- + ConnectionProperties.DRIVER_KEY;
+ + "jdbc.driver";
public static final String DATA_SOURCE_URL_PROPERTY =
"org.apache.cayenne.datasource."
- + ConnectionProperties.URL_KEY;
+ + "jdbc.url";
public static final String DATA_SOURCE_USER_NAME_PROPERTY =
"org.apache.cayenne.datasource."
- + ConnectionProperties.USER_NAME_KEY;
+ + "jdbc.username";
public static final String DATA_SOURCE_PASSWORD_PROPERTY =
"org.apache.cayenne.datasource."
- + ConnectionProperties.PASSWORD_KEY;
+ + "jdbc.password";
public static final String DATA_SOURCE_MIN_CONNECTIONS_PROPERTY =
"org.apache.cayenne.datasource.jdbc.minConnections";
public static final String DATA_SOURCE_MAX_CONNECTIONS_PROPERTY =
"org.apache.cayenne.datasource.jdbc.maxConnections";



--
Andrey

Search Discussions

  • Ольга Ткачева at Nov 19, 2009 at 12:09 pm
    agree, I see it.

    2009/11/19 Andrey Razumovsky <razumovsky.andrey@gmail.com>
    Hi Olga,

    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)
    at

    org.apache.cayenne.unit.CayenneResources.loadResources(CayenneResources.java:86)
    at

    org.apache.cayenne.unit.CayenneResources.getResources(CayenneResources.java:104)
    at org.apache.cayenne.unit.CayenneCase.<init>(CayenneCase.java:66)
    at

    org.apache.cayenne.remote.RemoteCayenneCase.<init>(RemoteCayenneCase.java:33)
    at org.apache.cayenne.remote.PropertyTest.<init>(PropertyTest.java:27)
    ... ans so on
    Caused by: java.lang.NullPointerException
    at

    org.apache.cayenne.unit.ConnectionProperties.loadDefaultProperties(ConnectionProperties.java:101)
    at

    org.apache.cayenne.unit.ConnectionProperties.<clinit>(ConnectionProperties.java:70)
    ... 19 more

    Can we use default values for properties missing?

    2009/11/19 <oltka@apache.org>
    Author: oltka
    Date: Thu Nov 19 09:05:56 2009
    New Revision: 882084

    URL: http://svn.apache.org/viewvc?rev=882084&view=rev
    Log:
    move ConnectionProperties class from src/main/java to
    /src/test/java/org/apache/cayenne/unit/

    Added:

    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/ConnectionProperties.java
    - copied, changed from r881884,
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/ConnectionProperties.java
    Removed:

    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/ConnectionProperties.java
    Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/conf/ConnectionPropertiesTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/CayenneResources.java
    cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/Provider.java
    Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/conf/ConnectionPropertiesTest.java
    URL:
    http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/conf/ConnectionPropertiesTest.java?rev=882084&r1=882083&r2=882084&view=diff
    ==============================================================================
    ---
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/conf/ConnectionPropertiesTest.java
    (original)
    +++
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/conf/ConnectionPropertiesTest.java
    Thu Nov 19 09:05:56 2009
    @@ -25,6 +25,7 @@

    import org.apache.commons.collections.ExtendedProperties;
    import org.apache.cayenne.conn.DataSourceInfo;
    +import org.apache.cayenne.unit.ConnectionProperties;

    /**
    */

    Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/CayenneResources.java
    URL:
    http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/CayenneResources.java?rev=882084&r1=882083&r2=882084&view=diff
    ==============================================================================
    ---
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/CayenneResources.java
    (original)
    +++
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/CayenneResources.java
    Thu Nov 19 09:05:56 2009
    @@ -29,7 +29,6 @@

    import org.apache.cayenne.CayenneRuntimeException;
    import org.apache.cayenne.access.DataNode;
    -import org.apache.cayenne.conf.ConnectionProperties;
    import org.apache.cayenne.conn.DataSourceInfo;
    import org.apache.cayenne.conn.PoolDataSource;
    import org.apache.cayenne.conn.PoolManager;

    Copied:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/ConnectionProperties.java
    (from r881884,
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/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?p2=cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/ConnectionProperties.java&p1=cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/ConnectionProperties.java&r1=881884&r2=882084&rev=882084&view=diff
    ==============================================================================
    ---
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/ConnectionProperties.java
    (original)
    +++
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/ConnectionProperties.java
    Thu Nov 19 09:05:56 2009
    @@ -17,7 +17,7 @@
    * under the License.
    ****************************************************************/

    -package org.apache.cayenne.conf;
    +package org.apache.cayenne.unit;

    import java.io.BufferedWriter;
    import java.io.File;
    @@ -33,8 +33,6 @@
    import org.apache.cayenne.conn.DataSourceInfo;
    import org.apache.cayenne.project.CayenneUserDir;
    import org.apache.commons.collections.ExtendedProperties;
    -import org.apache.commons.logging.Log;
    -import org.apache.commons.logging.LogFactory;

    /**
    * ConnectionProperties handles a set of DataSourceInfo objects using
    information stored
    @@ -43,7 +41,6 @@
    */
    public class ConnectionProperties {

    - private static Log logObj =
    LogFactory.getLog(ConnectionProperties.class);
    public static final String EMBEDDED_DATASOURCE =
    "internal_embedded_datasource";
    public static final String EMBEDDED_DATASOURCE_DBADAPTER =
    "org.apache.cayenne.dba.hsqldb.HSQLDBAdapter";
    public static final String EMBEDDED_DATASOURCE_USERNAME = "sa";
    @@ -271,7 +268,7 @@
    /**
    * Creates a DataSourceInfo object from a set of properties.
    */
    - protected DataSourceInfo buildDataSourceInfo(ExtendedProperties props)
    {
    + public DataSourceInfo buildDataSourceInfo(ExtendedProperties props) {
    DataSourceInfo dsi = new DataSourceInfo();

    String adapter = props.getString(ADAPTER_KEY);
    @@ -293,7 +290,7 @@
    /**
    * Returns a list of connection names configured in the properties
    object.
    */
    - protected List<String> extractNames(ExtendedProperties props) {
    + public List<String> extractNames(ExtendedProperties props) {
    Iterator it = props.getKeys();
    List<String> list = new ArrayList<String>();


    Modified:
    cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/Provider.java
    URL:
    http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/Provider.java?rev=882084&r1=882083&r2=882084&view=diff
    ==============================================================================
    ---
    cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/Provider.java
    (original)
    +++
    cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/Provider.java
    Thu Nov 19 09:05:56 2009
    @@ -39,7 +39,6 @@
    import org.apache.cayenne.access.DbGenerator;
    import org.apache.cayenne.access.dbsync.SkipSchemaUpdateStrategy;
    import org.apache.cayenne.conf.Configuration;
    -import org.apache.cayenne.conf.ConnectionProperties;
    import org.apache.cayenne.conf.ResourceFinder;
    import org.apache.cayenne.dba.AutoAdapter;
    import org.apache.cayenne.dba.DbAdapter;
    @@ -82,17 +81,17 @@
    public static final String CREATE_SCHEMA_PROPERTY =
    "org.apache.cayenne.schema.create";
    public static final String DATA_SOURCE_FACTORY_PROPERTY =
    "org.apache.cayenne.jpa.jpaDataSourceFactory";

    - // ... DataSource
    + // ... DataSource see ConnectionProperties
    public static final String ADAPTER_PROPERTY = "org.apache.cayenne."
    - + ConnectionProperties.ADAPTER_KEY;
    + + "adapter";
    public static final String DATA_SOURCE_DRIVER_PROPERTY =
    "org.apache.cayenne.datasource."
    - + ConnectionProperties.DRIVER_KEY;
    + + "jdbc.driver";
    public static final String DATA_SOURCE_URL_PROPERTY =
    "org.apache.cayenne.datasource."
    - + ConnectionProperties.URL_KEY;
    + + "jdbc.url";
    public static final String DATA_SOURCE_USER_NAME_PROPERTY =
    "org.apache.cayenne.datasource."
    - + ConnectionProperties.USER_NAME_KEY;
    + + "jdbc.username";
    public static final String DATA_SOURCE_PASSWORD_PROPERTY =
    "org.apache.cayenne.datasource."
    - + ConnectionProperties.PASSWORD_KEY;
    + + "jdbc.password";
    public static final String DATA_SOURCE_MIN_CONNECTIONS_PROPERTY =
    "org.apache.cayenne.datasource.jdbc.minConnections";
    public static final String DATA_SOURCE_MAX_CONNECTIONS_PROPERTY =
    "org.apache.cayenne.datasource.jdbc.maxConnections";



    --
    Andrey


    --
    Olga Tkacheva

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdev @
categoriescayenne
postedNov 19, '09 at 11:38a
activeNov 19, '09 at 12:09p
posts2
users2
websitecayenne.apache.org

People

Translate

site design / logo © 2022 Grokbase