Manual Test Scripts

This page lists scripts for testing the different parts of the Ibator UI. This information may also be helpful in learning how to use the different parts of the Eclipse user interface for Ibator.

Setup

  1. Make sure that MySQL is installed and running. The following scripts also assume that the password for root is also root
  2. Make sure that you have downloaded the MySQL Connector for Java and unzipped it somewhere on your local drive. The following scripts assume the MySQL JDBC driver is located at "/JavaTools/mysql-connector-java-5.1.12/mysql-connector-java-5.1.12-bin.jar".
  3. If you have not created the Ibator test database already, then execute the following script:
    
    drop schema if exists ibatortest;
    create schema ibatortest;
    use ibatortest;
    create table a (id int not null, description varchar(50), primary key(id));
    create table b (id int not null, description varchar(50), primary key(id));
    create table c (id int not null, description varchar(50), primary key(id));
    create table d (id int not null, description varchar(50), primary key(id));
    create table e (id int not null, description varchar(50), primary key(id));
    create table f (id int not null, description varchar(50), primary key(id));
    create table g (id int not null, description varchar(50), primary key(id));
    create table h (id int not null, description varchar(50), primary key(id));
    create table i (id int not null, description varchar(50), primary key(id));
    create table j (id int not null, description varchar(50), primary key(id));
          
  4. Make sure that the new version of the plugin has been built in the "IbatorUpdateSite" project.

Tests

The following tests are intended to be executed in the order listed. Some tests build on items created in previous tests.

Installation

  1. Install a fresh version of Eclipse (version 3.4.1 or later)
  2. Open the fresh Eclipse install, and create a new (empty) workspace
  3. Configure a local update site to point to the newly generated site (Help>Software Updates...)
  4. Show all versions of the feature
  5. Install the oldest version of the feature
  6. Restart Eclipse
  7. Do a regular software update and verify that the newest version of the feature is listed as an install option (this may also install other Eclipse updates)
  8. Restart Eclipse
  9. Verify that the latest version of the feature is listed as installed

Documentation

  1. Open the Eclipse help (Help>Help Contents)
  2. Verify that the book "Apache iBATIS Ibator User's Guide" appears in the contents.
  3. Verify that every item in the contents points to a valid page, and that all pages are referenced in the table of contents. This is especially important if new packages or help pages have been added anywhere.
  4. Verify that the core Ibator documentation pages do not show the options to show or hide the menu. These options should be disabled by the style sheet.
  5. Verify that the latest version of the release notes is shown both in the Eclipse UI documentation, and the Core Ibator documentation.

New File Wizard

  1. Create a new JavaProject called "IbatorTest". Make sure there is a separate source folder called src
  2. Add an additional source folder called generatedsrc
  3. Configure the build path to add the iBATIS JAR file (typically an external JAR in the ../devlib directory)
  4. Create a new package in the src folder called config
  5. Make a new Ibator configuration file:
    1. Right click on the config package
    2. Select New>Other>Apache iBATIS Ibator>Apache iBATIS Ibator Configuration File
    3. Press Next
    4. Verify that Location is set to "IbatorTest/src/config"
    5. Verify that File Name is set to "ibatorConfig.xml"
    6. Press Finish
    7. Verify that an editor opens with a skeleton Ibator configuration File
  6. Right click on the new file, then take the option "Generate iBATIS Artifacts"
  7. Verify that an error dialog is shown with the detail message "Exception getting JDBC Driver"
  8. Press "OK" to dismiss the dialog

Generate iBATIS Artifacts

  1. Open an editor on the file "ibatorConfig.xml" that you created in the previous test
  2. Change the contents of the file to the following:
    
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE ibatorConfiguration
      PUBLIC "-//Apache Software Foundation//DTD Apache iBATIS Ibator Configuration 1.0//EN"
      "http://ibatis.apache.org/dtd/ibator-config_1_0.dtd">
    <ibatorConfiguration>
      <classPathEntry location="/JavaTools/mysql-connector-java-5.1.12/mysql-connector-java-5.1.12-bin.jar" />
      <ibatorContext id="context1" targetRuntime="Ibatis2Java5" >
        <jdbcConnection driverClass="com.mysql.jdbc.Driver"
          connectionURL="jdbc:mysql://localhost/ibatortest"
          userId="root" password="root" >
        </jdbcConnection>
        <javaModelGenerator targetPackage="gen.model" targetProject="IbatorTest" />
        <sqlMapGenerator targetPackage="gen.sql" targetProject="IbatorTest" />
        <daoGenerator targetPackage="gen.dao" targetProject="IbatorTest" type="GENERIC-CI" />
        <table tableName="a" />
      </ibatorContext>
    
      <ibatorContext id="context2" targetRuntime="Ibatis2Java5" >
        <jdbcConnection driverClass="com.mysql.jdbc.Driver"
          connectionURL="jdbc:mysql://localhost/ibatortest"
          userId="root" password="root" >
        </jdbcConnection>
        <javaModelGenerator targetPackage="gen.src.model" targetProject="IbatorTest/generatedsrc" />
        <sqlMapGenerator targetPackage="gen.src.sql" targetProject="IbatorTest/generatedsrc" />
        <daoGenerator targetPackage="gen.src.dao" targetProject="IbatorTest/generatedsrc" type="GENERIC-SI" />
        <table schema="ibatortest" tableName="%" />
      </ibatorContext>
    </ibatorConfiguration>
        
  3. Change the location of the JDBC driver in the <classPathEntry> element if different on your system
  4. Save the file
  5. Right click on the file, then take the option "Generate iBATIS Artifacts"
  6. Verify that code is generated in the two different source folders. Code for table "a" should be in the "src" folder, code for tables "a" through "j" should be in the "generatedsrc" folder. Verify that there are no compilation errors or warnings.

Java File Merger

  1. Open the Java file gen.dao.ADAOImpl.java in the "src" folder
  2. Note the time of generation of the file from one of the @ibatorgenerated comments
  3. Add a private field of any type called mergetest and generate a getter and setter for the field.
  4. Save and close the file
  5. Right click on the Ibator configuration file from the last test, and then take the option "Generate iBATIS Artifacts"
  6. Verify that the progress bar is reasonably accurate
  7. Open the Java file gen.dao.ADAOImpl.java in the "src" folder
  8. Verify that the time of generation is later than the time noted above
  9. Verify that the field mergetest, and its getter and setter remain in the file (they will have been moved to the bottom of the file)
  10. Open the Ibator configuration file from the last test.
  11. Change the DAO type in context1 to SPRING
  12. Save and close the file
  13. Right click on the Ibator configuration file, and then take the option "Generate iBATIS Artifacts"
  14. Verify that src.dao.ADAOImpl now extends SqlMapClientDaoSupport. Note that there will be several errors in the workspace now because of the new dependencies on Spring that were generated.
  15. Re open the Ibator configuration file.
  16. Change the DAO type in context1 back to GENERIC-CI
  17. Save and close the file
  18. Right click on the Ibator configuration file, and then take the option "Generate iBATIS Artifacts"
  19. Verify that src.dao.ADAOImpl doesn't extend anything. There will be one error in the file related to the Spring import (the Java merger does not reconcile all imports). Delete the import and verify that there are no other errors in the workspace. Also, verify that the field mergetest and its associated getter and setter still exist.

Ant Build

  1. Close Eclipse if it is still open, then reopen Eclipse (this resets the plugin classloader for the custom classpath portion of the test).
  2. Open the Ibator configuration file from the last test.
  3. Delete the <classPathEntry> element from the file.
  4. Save and close the file.
  5. Create a new file build.xml in the "IbatorTest/src/config" package.
  6. Change the contents of the new file to the following:
    
    <project default="runIbator">
      <target name="runIbator">
        <eclipse.convertPath resourcepath="IbatorTest/src/config/ibatorConfig.xml"
                             property="thePath"/>
        <ibator.generate configfile="${thePath}" >
        </ibator.generate>
      </target>
    </project>
        
  7. Save and close the file.
  8. Delete the Java file gen.dao.ADAO.java. There will now be errors in the workspace.
  9. Right click on the new build.xml file, then select the menu option "Run As>Ant Build...". You should see the Ant launch configuration dialog open.
  10. Select the "JRE" tab, then select the "Run in the same JRE as the workspace" radio button.
  11. Press the "Run" button
  12. You should see an error dialog open with a runtime exception stating "Exception getting JDBC Driver". Press "OK" to dismiss the dialog.
  13. Right click on the new build.xml file, then select the menu option "Run As>Ant Build...". You should see the Ant launch configuration dialog open.
  14. Select the "Classpath" tab, then add the MySQL driver to "User Entries"
  15. Press the "Run" button
  16. After Ibator runs, you should see a "BUILD SUCCESSFUL" message.
  17. Verify that the workspace errors are gone.

Classpath Variables

  1. Create a new Java project called "IbatorPlugin". Make sure that there are separate folders for source and class files.
  2. Right click on the "IbatorPlugin" project, then take the menu option to "Add Ibator to Build Path".
  3. Verify that the IBATOR_JAR classpath variable has been added to the project's build path.
  4. Expand the Ibator JAR file, select any class and double click on the class. Verify that the source code is attached and that you see the source code for the class.
  5. Make a new Java package called plugin.
  6. Make a new Java class called plugin.TestPlugin that extends IbatorPluginAdapter.
  7. Change the generated validate method so that it returns true.
  8. Override the modelBaseRecordClassGenerated method and make the method match the following:
    
    @Override
    public boolean modelBaseRecordClassGenerated(TopLevelClass topLevelClass,
            IntrospectedTable introspectedTable) {
    
        FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType("java.io.Serializable");
    
        topLevelClass.addImportedType(fqjt);
        topLevelClass.addSuperInterface(fqjt);
    
        return true;
    }
          
  9. Save and close the Java file.
  10. Export plugin.TestPlugin as a JAR file to "/Temp/TestPlugin.jar". We need to export as a JAR file because Eclipse can't add class folders to an Ant launch :(
  11. Open the ibatorConfig.xml file from the previous tests.
  12. Add the plugin to the configuration. Add it after the first <ibatorContext> element like this:
    
    <ibatorContext id="context1" targetRuntime="Ibatis2Java5" >
      <ibatorPlugin type="plugin.TestPlugin"/>
      ...
          
  13. Save and close the configuration file.
  14. Right click on the build.xml file from the previous tests, then select the menu option "Run As>Ant Build...". You should see the Ant launch configuration dialog open.
  15. Select the "Classpath" tab, then add "/Temp/TestPlugin.jar" file to the classpath as an external JAR
  16. Press the "Run" button
  17. After Ibator runs, you should see a "BUILD SUCCESSFUL" message.
  18. Verify that gen.model.A.java now implements java.io.Serializable. Note that Eclipse may show a warning related to the missing serialVersionUID field. This is expected and can be ignored.