Difference between revisions of "Run Junit Tests For Non Default SQL Adapter"

From CDOT Wiki
Jump to: navigation, search
(Debugging a Non-Default SQL Adapter)
(Environment/Connection Files)
Line 27: Line 27:
 
==== Environment/Connection Files ====
 
==== Environment/Connection Files ====
 
These files are located in the ''test'' source folder in the package <code>nexj</code>
 
These files are located in the ''test'' source folder in the package <code>nexj</code>
#Edit the files: '''default.config, filestorage.connections, filestoragefragment.connections'''
+
*Edit the files: '''default.config, filestorage.connections, filestoragefragment.connections'''
 
##In the <code>DataSourceConnections</code> elemement
 
##In the <code>DataSourceConnections</code> elemement
 
##Change all occurrences of <code>adapter="MySQL"</code> to <code>adapter="DbName"</code>
 
##Change all occurrences of <code>adapter="MySQL"</code> to <code>adapter="DbName"</code>
 
##Change all occurrences of <code>port="3306"</code> to the port on which the new DbName is configured to accept connections
 
##Change all occurrences of <code>port="3306"</code> to the port on which the new DbName is configured to accept connections
:::For the PostgreSQL Adapter, the following configuration is used
+
::::For the PostgreSQL Adapter, the following configuration is used
 
<source lang="xml">
 
<source lang="xml">
 
<DataSourceConnections>
 
<DataSourceConnections>
Line 41: Line 41:
 
  </DataSourceConnections>
 
  </DataSourceConnections>
 
</source>
 
</source>
#<li value="2">Create a connections file for the new adapter
+
*Create a connections file for the new adapter
 
##Create the file '''[DbName].connections''' in the <code>nexj<code> package in the ''test'' source folder
 
##Create the file '''[DbName].connections''' in the <code>nexj<code> package in the ''test'' source folder
 
##Copy and paste the contents of '''mysql.connections''' into the new connections file
 
##Copy and paste the contents of '''mysql.connections''' into the new connections file
Line 47: Line 47:
 
##Change all occurrences of <code>adapter="MySQL"</code> to <code>adapter="DbName"</code>
 
##Change all occurrences of <code>adapter="MySQL"</code> to <code>adapter="DbName"</code>
 
##Change all occurrences of <code>port="3306"</code> to the port on which the new DbName is configured to accept connections
 
##Change all occurrences of <code>port="3306"</code> to the port on which the new DbName is configured to accept connections
<br>For the PostgreSQL Adapter, the following configuration is used
+
::::For the PostgreSQL Adapter, the following configuration is used
 
<source lang="xml">
 
<source lang="xml">
 
<DataSourceConnections>
 
<DataSourceConnections>
Line 56: Line 56:
 
  </DataSourceConnections>
 
  </DataSourceConnections>
 
</source>
 
</source>
 +
 
==== SQL Scripts ====
 
==== SQL Scripts ====
 
==== Unit Test Files ====
 
==== Unit Test Files ====

Revision as of 13:28, 26 February 2011

Debugging a Non-Default SQL Adapter

Summary

By default, NexJ Express Unit tests are configured to test the MySQL Adapter.
The instructions that follow outline instructions for configuring Unit tests to be run for other SQL Adapters.
For this manual, reference will be made to the PostgreSQL Adapter but it will work the same for other adapters

Prerequisites

The following files must exist for the new SQL Adapter:
src
nexj.core.persistence.sql.[DbName]SQLAdapter.java extending nexj.core.persistence.sql.SQLAdapter
nexj.core.persistence.sql.[DbName]SQLSchemaManager.java extending nexj.core.persistence.sql.SQLSchemaManager
test
nexj.core.persistence.sql.[DbName]SQLAdapterTest.java extending nexj.core.persistence.sql.SQLAdapterTest
nexj.core.persistence.sql.[DbName]SQLSchemaManagerTest.java extending nexj.core.persistence.sql.SQLSchemaManagerTest

The following files should be edited and entries for the new SQL Adapter added:
nexj.core.meta.persistence.sql.RelationalDatabase.java
nexj.core.meta.peristence.sql.RelationalDatabaseFragment.java
nexj.core.meta.sys.system.dstypes
nexj.core.persistence.sql.SQLSchemaManagerFactory.java
nexj.core.util.JDBCInfo.java

Configurations

The following will configure the unit tests to run for [DbName]SQLAdapter and [DbName]SQLSchemaManager

Environment/Connection Files

These files are located in the test source folder in the package nexj

  • Edit the files: default.config, filestorage.connections, filestoragefragment.connections
    1. In the DataSourceConnections elemement
    2. Change all occurrences of adapter="MySQL" to adapter="DbName"
    3. Change all occurrences of port="3306" to the port on which the new DbName is configured to accept connections
For the PostgreSQL Adapter, the following configuration is used
<DataSourceConnections>
  <RelationalDatabaseConnection adapter="PostgreSQL" dataSource="DefaultRelationalDatabase" database="test"
      host="localhost" password="test" port="5432" unicode="true" user="test"/>
  <RelationalDatabaseConnection adapter="PostgreSQL" dataSource="ExternalRelationalDatabase" database="test"
      host="localhost" password="test" port="5432" unicode="true" user="test"/>
  ...
 </DataSourceConnections>
  • Create a connections file for the new adapter
    1. Create the file [DbName].connections in the nexj<code> package in the test source folder
    2. Copy and paste the contents of mysql.connections into the new connections file
    3. In the <code>DataSourceConnections elemement
    4. Change all occurrences of adapter="MySQL" to adapter="DbName"
    5. Change all occurrences of port="3306" to the port on which the new DbName is configured to accept connections
For the PostgreSQL Adapter, the following configuration is used
<DataSourceConnections>
  <RelationalDatabaseConnection adapter="PostgreSQL" dataSource="DefaultRelationalDatabase" database="test"
      host="localhost" password="test" port="5432" unicode="true" user="test"/>
  <RelationalDatabaseConnection adapter="PostgreSQL" dataSource="ExternalRelationalDatabase" database="test"
      host="localhost" password="test" port="5432" unicode="true" user="test"/>
 </DataSourceConnections>

SQL Scripts

Unit Test Files