Project

General

Profile

Old UAST Testcases

Introduction

This repository of testcases is not publicly available. It may have code that has customer-specific references or even some snippets of code copied from customer applications. It is being documented here because it is the location for a wide range of programs that are referenced in bug and feature tasks. For those with access to this repository, new testcases should only be added under limited conditions.

From the early days in 2004, we have built thousands of "standalone" testcases and small sets of related testcases to explore specific 4GL features. This testcases repository has grown haphazardly. It is not well organized and it is not well managed. Most of these testcases have been written as interactive programs instead of automated non-interactive tests. It is our intention to rework and expand these tests over time to be a comprehensive automated test suite for testing the 4GL compatibility of FWD.

Until that time, we will continue to treat this is a limited testing environment where we sometimes happen to store testcases. Reasons to add a testcase:

  1. There is some customer code or references such that the testcase cannot be shared publicly.
  2. The testcase would need significant cleanup or rework before being suitable for check-in to the Testcases project.

This second reason is the most common case for adding to this repository. It can be a useful location to store some testcases during work on a task. Over time, it is expected that these testcases will be reworked or replaced with clean and properly automated versions that will reside in the new testcases repo.

Organization

Please organize all testcases in sub-directories of testcases/uast/. Name the subdirectory based on the feature/functionality being tested (e.g. testcases exploring buttons in the UI would be in a testcases/uast/button/ directory).

You will have to make some changes to allow things to run from the testcases/uast/ directory. For example, RUN statement and include file pathing will need to have the sub-directory pathing prepended.

For particularly large/complex sets of tests, there may be multiple levels of sub-directories to organize the related tests into groups. The library_calls/ examples in the next section has library_calls/misc/ and library_calls/return/ for example. Common features and the main test runner are in the library_calls/ directory itself and then testcases that are related to library call return value processing are in the library_calls/return/ directory.

Setup

1. Obtain the repo.

bzr co ~/secure/code/p2j_repo/testcases

Inside testcases/uast/ you will find MANY small examples. This is where we store our standalone tests and our test sets (a good example test set is in testcases/uast/library_calls/.

2. Move into the "project home" directory. This is where all the 4GL testcases reside.

cd testcases/uast/

You can see that this is a FWD project. For example, there is a cfg/p2j.cfg.xml and there are some schemata files in data/*.df. This means you can run conversion on files in this directory, but you MUST run the conversion from this directory.

WARNING: This is not a project created using our "standard template" (Hotel projects). It has been created manually over time and is not well managed, nor is it well documented. You may have to make edits to get it working to your requirements or on your system.

3. Link the FWD branch you are testing.

ln -s <path_to_fwd_branch> p2j/

4. Create an explicit list of files to convert. You will be editing this often as you add/remove tests during your task work.

This is just a simple list of relative file names, like this file-cvt-list.txt (you can name it anything, but by convention we use this name):

./primes.p
./hello.p

You can have any number of files in here. It is usually stored in the project home dir.

5. Run conversion and compile/jar the result.

ant convert-all jar -D4gl.file.list=file-cvt-list.txt 2>&1 | tee "cvt_$(date '+%Y%m%d_%H%M%S').log"

6. Start the simple FWD server.

The testcases repo contains a simple FWD server setup. You may have to edit the directory to get any permanent database cfg right. For testcases that only rely on temp-tables, it will probably work without edits.

cd <path_to_checkout>/testcases/simple/server/ && P2J_HOME=/<path_to_fwd_branch>/p2j/ ./server.sh -a ../../uast/build/lib/testcases.jar

You can add debugging support with a -d on the server.sh command line. Look inside that script for more details.

7. Start a simple FWD client.

The testcases repo contains a simple FWD client setup. On the client.sh you can add -d2081 to enable debugging on port 2081. Look inside that script for more options.

In the following, <4gl_program_name_to_execute> is the same 4GL program name that you placed in the conversion list (step 4 above). For example, you might use ./primes.p.

Swing ChUI

cd <path_to_checkout>/testcases/uast && ../simple/client/client.sh -z/<path_to_fwd_branch>/p2j/build/lib client:cmd-line-option:startup-procedure=./<4gl_program_name_to_execute>

Swing GUI

cd <path_to_checkout>/testcases/uast && ../simple/client/client.sh -g -z/<path_to_fwd_branch>/p2j/build/lib client:cmd-line-option:startup-procedure=./<4gl_program_name_to_execute>

Adding "Permanent" Database Support Using H2

Below is described a sample setup for running a converted test program which uses a database (with name fwd) using H2. One have to do the following:

1. Download and unpack h2-1.4.197 distribution, replace h2-1.4.197.jar with fwd-h2-1.4.197.jar from $P2J_HOME/build/lib or modify bin/h2.sh to use it instead of h2-1.4.197.jar.

2. Define the environment variable export H2DRIVERS=$P2J_HOME/build/lib/p2jpl.jar

3. Copy $P2J_HOME/build/lib/p2jspi.jar to $JAVA_HOME/jre/lib/ext directory. Most likely you will have to do it as a root, enable read access for all: sudo chmod a+x $JAVA_HOME/jre/lib/ext/p2jspi.jar

4. Modify testcases/uast/cfg/p2j.cfg.xml adding a namespace for your database:

      <namespace
         name="fwd" 
         importFile="data/fwd.df" 
         xmlFile="data/namespace/fwd.dict" 
         default="true">
         <parameter name="ddl-dialects" value="h2" />
         <dialect-specific name="h2">
            <parameter name="collation" value="en_US_P2J" />
         </dialect-specific>
      </namespace>

The metadata node should look like this:

      <metadata name="standard">
         <table name="_db" />
         <table name="_file" />
         <table name="_field" />
         <table name="_index" />
         <table name="_index-field" />
         <table name="_lock" />
         <table name="_user" />
      </metadata>

5. Create data/fwd.df file. You can use data/p2j_test.df as a template and modify it if required.

6. Compile your test using ant jar.

7. Start h2 console, create an embedded database using URL like this: jdbc:h2:file:~/.h2/fwd.h2;MV_STORE=FALSE;LOG=0;CACHE_SIZE=65536;LOCK_MODE=0;UNDO_LOG=0. After that execute generated SQL scripts testcases/uast/ddl/schema_table_fwd_h2.sql and testcases/uast/ddl/schema_index_fwd_h2.sql. Disconnect console from the db.

8. If you need to populate some tables tables in the database, put <tablename>.d files into testcases/uast/data/fwd and execute the following command:

java -server -Xmx2g -XX:+HeapDumpOnOutOfMemoryError -classpath p2j/build/lib/p2j.jar:build/lib/testcases.jar:cfg: -Djava.util.logging.config.file=cfg/logging.properties -DP2J_HOME=.  com.goldencode.p2j.pattern.PatternEngine -d 2\
     "dbName=\"fwd\"" \
     "targetDb=\"h2\"" \
     "url=\"jdbc:h2:file:~/.h2/fwd.h2;MV_STORE=FALSE;LOG=0;CACHE_SIZE=65536;LOCK_MODE=0;UNDO_LOG=0\"" \
     "uid=\"admin\"" \
     "pw=\"secret\"" \
     "maxThreads=2" \
     schema/import data/namespace fwd.p2o 2>&1 | tee data_import_$(date '+%Y%m%d_%H%M%S').log

9. Modify testcases/simple/server/directory.xml file:

  • Add the following subnode to the <node class="container" name="database"> (alongside with <node class="container" name="_temp">):
              <node class="container" name="fwd">
                <node class="container" name="p2j">
                  <node class="string" name="schema">
                    <node-attribute name="value" value="fwd" />
                  </node>
                  <node class="boolean" name="load_at_startup">
                    <node-attribute name="value" value="true" />
                  </node>
                  <node class="string" name="embedded-collation">
                    <node-attribute name="value" value="en_US_P2J" />
                  </node>
                </node>
                <node class="container" name="hibernate">
                  <node class="string" name="dialect">
                    <node-attribute name="value" value="com.goldencode.p2j.persist.dialect.P2JH2Dialect"/>
                  </node>
                  <node class="container" name="connection">
                    <node class="string" name="driver_class">
                      <node-attribute name="value" value="org.h2.Driver"/>
                    </node>
                    <node class="string" name="url">
                      <node-attribute name="value" value="jdbc:h2:file:~/.h2/fwd.h2;MV_STORE=FALSE;LOG=0;CACHE_SIZE=65536;LOCK_MODE=0;UNDO_LOG=0"/>
                    </node>
                    <node class="string" name="username">
                      <node-attribute name="value" value="admin" />
                    </node>
                    <node class="string" name="password">
                      <node-attribute name="value" value="secret" />
                    </node>
                    <node class="integer" name="prepareThreshold">
                      <node-attribute name="value" value="1" />
                    </node>
                  </node>
                  <node class="boolean" name="show_sql">
                    <node-attribute name="value" value="false" />
                  </node>
                  <node class="container" name="c3p0">
                    <node class="integer" name="max_size">
                      <node-attribute name="value" value="6" />
                    </node>
                    <node class="integer" name="min_size">
                      <node-attribute name="value" value="1" />
                    </node>
                    <node class="integer" name="timeout">
                      <node-attribute name="value" value="120" />
                    </node>
                    <node class="integer" name="max_statements">
                      <node-attribute name="value" value="100" />
                    </node>
                    <node class="integer" name="idle_test_period">
                      <node-attribute name="value" value="60" />
                    </node>
                    <node class="integer" name="acquire_increment">
                      <node-attribute name="value" value="2" />
                    </node>
                    <node class="boolean" name="validate">
                      <node-attribute name="value" value="false" />
                    </node>
                  </node>
                  <node class="container" name="cache">
                    <node class="boolean" name="use_second_level_cache">
                      <node-attribute name="value" value="false" />
                    </node>
                    <node name="use_query_cache" class="boolean">
                      <node-attribute name="value" value="false"/>
                    </node>
                  </node>
                  <node class="container" name="jdbc">
                    <node class="integer" name="fetch_size">
                      <node-attribute name="value" value="1024"/>
                    </node>
                  </node>
                </node>
              </node>
    
    
  • Enable persistence by setting
              <node class="boolean" name="active">
                <node-attribute name="value" value="TRUE"/>
              </node>
    
    

    under the <node class="container" name="persistence">

If you need multiple db's repeat all the above for all of them.


© 2004-2022 Golden Code Development Corporation. ALL RIGHTS RESERVED.