Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

One of the GSoC 2011 task : https://issues.apache.org/jira/browse/OFBIZ-4211

Info
titleBe Careful

Basic ant targets like build, run-install, run-tests should be working

Why

This task will be focusing on separating test and source code in each component.

At the moment, running the run-install task is compiling code and test code. What is expected is run-install compiling only the deployment code, and run-tests only the test code. Each sub-test task should also compile what is needed for it.

The code structure would be like this :

Code Block
src/main/java	Application/Library sources
src/test/java	Test sources

How

Project plan

  • Learn Ant into depth
  • Analyze the structure of the code base
  • Identify the test classes
  • Move the test classes into src/test/java and create the build.xml for building the test cases
Git repository

https://ganathr@github.com/ganathr/ofbiz.git

Analyze the structure of the code base

I went through the code and identified the test java classes some modules and changed their module structure as follows.
Since their were some modules were dependencies of others I had to do the changes according to the following order and test whether they were running.

  • content
  • party
  • workeffort
  • product
  • marketing
  • order
  • manufacturing
  • accounting
Content module

Current structure of the module

.
|-- src
|   |-- ControlApplet.java
|   `-- org
|       `-- ofbiz
|           `-- content
|               |-- test
|               |   `-- LuceneTests.java

Structure after test/code separation  of the module

.
|-- src
|    |-- ControlApplet.java
|    |--main
|    |     `-- java
|    |          `-- //rest of the code
|    `-- test
|        `-- java
|        `-- org
|            `-- ofbiz
|                `-- content
|                    `-- LuceneTests.java

party module

Current structure of the module

.
|-- src
|   `-- org
|       `-- ofbiz
|           `-- party
|               |-- communication
|               |   `-- CommunicationEventServices.java
|               |-- contact
|               |   |-- ContactHelper.java
|               |   |-- ContactMechServices.java
|               |   `-- ContactMechWorker.java
|               |-- content
|               |   `-- PartyContentWrapper.java
|               `-- party
|                   |-- PartyHelper.java
|                   |-- PartyRelationshipHelper.java
|                   |-- PartyRelationshipServices.java
|                   |-- PartyServices.java
|                   |-- PartyTypeHelper.java
|                   `-- PartyWorker.java

Structure after test/code separation of the module

.
|-- src
|    |-- main
|    |   `-- java
|    |       `-- java
|    |              `-- //rest of the code
|    `-- test
|        `-- java
|        `-- org
|            `-- ofbiz
|                `-- party

workeffort module

Current structure of the module

.
|-- src
|   `-- org
|       `-- ofbiz
|           `-- workeffort
|               |-- content
|               |   `-- WorkEffortContentWrapper.java
|               |-- project
|               `-- workeffort
|                   |-- ICalConverter.java
|                   |-- ICalHandlerFactory.java
|                   |-- ICalRecurConverter.java
|                   |-- ICalWorker.java
|                   |-- WorkEffortKeywordIndex.java
|                   |-- WorkEffortPartyAssignmentServices.java
|                   |-- WorkEffortSearchEvents.java
|                   |-- WorkEffortSearch.java
|                   |-- WorkEffortSearchSession.java
|                   |-- WorkEffortServices.java
|                   `-- WorkEffortWorker.java

Structure after test/code separation  of the module

.
|-- src
|     `-|- main
|    |   `-- java
|    |       `-- //rest of the code
|    `-- test
|        `-- java
|        `-- org
|            `-- ofbiz
|                `-- workeffort

product module

Current structure of the module

.
|-- src
|   |-- org
|   |   `-- ofbiz
|   |       |-- product
|   |       |   |-- catalog
|   |       |   |   `-- CatalogWorker.java
|   |       |   |-- category
|   |       |   |   |-- CatalogUrlServlet.java
|   |       |   |   |-- CategoryContentWrapper.java
|   |       |   |   |-- CategoryServices.java
|   |       |   |   |-- CategoryWorker.java
|   |       |   |   `-- OfbizCatalogUrlTransform.java
|   |       |   |-- config
|   |       |   |   |-- ProductConfigItemContentWrapper.java
|   |       |   |   |-- ProductConfigWorker.java
|   |       |   |   |-- ProductConfigWrapperException.java
|   |       |   |   `-- ProductConfigWrapper.java
|   |       |   |-- feature
|   |       |   |   |-- ParametricSearch.java
|   |       |   |   `-- ProductFeatureServices.java
|   |       |   |-- image
|   |       |   |   `-- ScaleImage.java
|   |       |   |-- imagemanagement
|   |       |   |   |-- CropImage.java
|   |       |   |   |-- FrameImage.java
|   |       |   |   |-- ImageManagementServices.java
|   |       |   |   |-- ImageUrlServlet.java
|   |       |   |   |-- ReplaceImage.java
|   |       |   |   |-- RotateImage.java
|   |       |   |   `-- WatermarkImage.java
|   |       |   |-- inventory
|   |       |   |   |-- InventoryServices.java
|   |       |   |   `-- InventoryWorker.java
|   |       |   |-- price
|   |       |   |   `-- PriceServices.java
|   |       |   |-- product
|   |       |   |   |-- KeywordIndex.java
|   |       |   |   |-- ProductContentWrapper.java
|   |       |   |   |-- ProductEvents.java
|   |       |   |   |-- ProductPromoContentWrapper.java
|   |       |   |   |-- ProductSearchEvents.java
|   |       |   |   |-- ProductSearch.java
|   |       |   |   |-- ProductSearchSession.java
|   |       |   |   |-- ProductServices.java
|   |       |   |   |-- ProductUtilServices.java
|   |       |   |   |-- ProductWorker.java
|   |       |   |   `-- VariantEvents.java
|   |       |   |-- promo
|   |       |   |   `-- PromoServices.java
|   |       |   |-- spreadsheetimport
|   |       |   |   |-- ImportProductHelper.java
|   |       |   |   `-- ImportProductServices.java
|   |       |   |-- store
|   |       |   |   |-- ProductStoreSurveyWrapper.java
|   |       |   |   `-- ProductStoreWorker.java
|   |       |   |-- subscription
|   |       |   |   `-- SubscriptionServices.java
|   |       |   |-- supplier
|   |       |   |   `-- SupplierProductServices.java
|   |       |   `-- test
|   |       |       |-- InventoryItemTransferTest.java
|   |       |       `-- StockMovesTest.java
|   |       `-- shipment
|   |           |-- packing
|   |           |   |-- PackingEvent.java
|   |           |   |-- PackingServices.java
|   |           |   |-- PackingSession.java
|   |           |   `-- PackingSessionLine.java
|   |           |-- picklist
|   |           |   `-- PickListServices.java
|   |           |-- shipment
|   |           |   |-- ShipmentEvents.java
|   |           |   |-- ShipmentScheduledNotice.ftl
|   |           |   |-- ShipmentServices.java
|   |           |   `-- ShipmentWorker.java
|   |           |-- thirdparty
|   |           |   |-- dhl
|   |           |   |   `-- DhlServices.java
|   |           |   |-- fedex
|   |           |   |   `-- FedexServices.java
|   |           |   |-- ups
|   |           |   |   `-- UpsServices.java
|   |           |   `-- usps
|   |           |       |-- UspsMockApiServlet.java
|   |           |       |-- UspsServices.java
|   |           |       `-- UspsServicesTests.java
|   |           |-- verify
|   |           |   |-- VerifyPickServices.java
|   |           |   |-- VerifyPickSession.java
|   |           |   `-- VerifyPickSessionRow.java
|   |           `-- weightPackage
|   |               |-- WeightPackageServices.java
|   |               |-- WeightPackageSession.java
|   |               `-- WeightPackageSessionLine.java
|   `-- ShipmentScaleApplet.java

Structure after test/code separation of the module

.
|-- src
|   |-- main
|   |   `-- java
|   |         `-- //rest of the code    
|   `-- test
|       `-- java
|           `-- org
|               `-- ofbiz
|                   |-- product
|                   |   |-- InventoryItemTransferTest.java
|                   |   `-- StockMovesTest.java
|                   `-- shipment

marketing module

Current structure of the module

|-- src
|   `-- org
|       `-- ofbiz
|           |-- marketing
|           |   |-- marketing
|           |   |   `-- MarketingServices.java
|           |   |-- report
|           |   |   `-- ReportHelper.java
|           |   `-- tracking
|           |       `-- TrackingCodeEvents.java
|           `-- sfa
|               `-- vcard
|                   `-- VCard.java

Structure after test/code separation of the module

.
|-- src
|   |-- main
|   |   `-- java
|   |       `-- org
|   |           `-- ofbiz
|   |               |-- marketing
|   |               |   |-- marketing
|   |               |   |   `-- MarketingServices.java
|   |               |   |-- report
|   |               |   |   `-- ReportHelper.java
|   |               |   `-- tracking
|   |               |       `-- TrackingCodeEvents.java
|   |               `-- sfa
|   |                   `-- vcard
|   |                       `-- VCard.java
|   `-- test
|       `-- java
|           `-- org
|               `-- ofbiz
|                   |-- marketing
|                   `-- sfa

Order Module

Current structure of the module

.
|-- src
|   `-- org
|       `-- ofbiz
|           `-- order
|               `-- test
|                   |-- OrderTestServices.java
|                   |-- PurchaseOrderTest.java
|                   `-- SalesOrderTest.java

Structure after test/code separation  of the module

.
|-- src
|    |-- ControlApplet.java
|    |--main
|    |    `--java
|    |         `-- //rest of the code
|    |--test
|      `--java
|              `-- org
|                    `-- ofbiz
|                          `-- order
|                               |-- OrderTestServices.java
|                               |-- PurchaseOrderTest.java
|                               `-- SalesOrderTest.java

manufacturing module

Current structure of the module

.
|-- src
|   `-- org
|       `-- ofbiz
|           `-- manufacturing
|               |-- bom
|               |   |-- BOMHelper.java
|               |   |-- BOMNode.java
|               |   |-- BOMServices.java
|               |   `-- BOMTree.java
|               |-- jobshopmgt
|               |   |-- ProductionRunEvents.java
|               |   |-- ProductionRunHelper.java
|               |   |-- ProductionRun.java
|               |   `-- ProductionRunServices.java
|               |-- mrp
|               |   |-- InventoryEventPlannedServices.java
|               |   |-- MrpServices.java
|               |   `-- ProposedOrder.java
|               |-- routing
|               |   `-- RoutingServices.java
|               `-- techdata
|                   `-- TechDataServices.java

Structure after test/code separation of the module

.
|-- src
|    `-|- main
|    |   `-- java
|    |       `-- //rest of the code
|    `-- test
|        `-- java
|        `-- org
|            `-- ofbiz
|                `-- manufacturing

Accounting module

Current structure of the module
.
|-- src
|   `-- org
|       `-- ofbiz
|           `-- accounting
|               |-- test
|               |   `-- FinAccountTests.java
|               |-- thirdparty
|               |   |-- clearcommerce
|               |   |   `-- CCServicesTest.java
|               |   |-- ideal
|               |   |   `-- IdealPaymentServiceTest.java
|               |   |-- securepay
|               |   |   `-- SecurePayServiceTest.java

Structure after test/code separation  of the module
.
|-- src
|    |--main
|    |    `--java
|    |         `-- //rest of the code
|    |--test
|      `--java
|              `-- org
|                    `-- ofbiz
|                           `-- accounting
|                                  |-- FinAccountTests.java
|                                  |-- thirdparty
|                                  |   |-- clearcommerce
|                                  |   |   `-- CCServicesTest.java
|                                  |   |-- ideal
|                                  |   |   `-- IdealPaymentServiceTest.java
|                                  |   |-- securepay
|                                  |   |   `-- SecurePayServiceTest.java

Script for automate the test code separation
Code Block
\#\!/bin/bash

sed 's,@prefix src,@prefix src/main/java,' <macros.xml >temp
cat temp >macros.xml
rm temp

for i in applications specialpurpose framework
do
 #echo $i
cd $i

 for dir in $(ls .)
 do
  #echo $dir
 
  if \[ $dir \!= .. \]; 
  then
   if \[ \-d $dir \]
   then
    cd $dir
    #echo $dir

    if \[ \-d src/ \];
    then
     
     sed "s,org/ofbiz/,main/java/org/ofbiz/,g" <build.xml >temp
     cat temp >build.xml          

     #echo $dir
     cd src/
     SRC=$(pwd)

     testdirs=$(find ./ \-type d \-name test \-printf '%P\n' \| sort \-r) 

     mkdir \-p main/java/ test/java/

     if \[ $dir = 'content' \]; 
     then
      git mv ControlApplet.java main/java/
     
     elif \[ $dir = 'accounting' \];
     then
      mkdir \-p test/java/org/ofbiz/accounting/thirdparty/clearcommerce/
      mkdir test/java/org/ofbiz/accounting/thirdparty/ideal/
      mkdir test/java/org/ofbiz/accounting/thirdparty/securepay/
      git mv org/ofbiz/accounting/thirdparty/clearcommerce/CCServicesTest.java test/java/org/ofbiz/accounting/thirdparty/clearcommerce/
      git mv org/ofbiz/accounting/thirdparty/ideal/IdealPaymentServiceTest.java test/java/org/ofbiz/accounting/thirdparty/ideal/
      git mv org/ofbiz/accounting/thirdparty/securepay/SecurePayServiceTest.java test/java/org/ofbiz/accounting/thirdparty/securepay/
     
     elif \[ $dir = 'product' \];
     then
      git mv ShipmentScaleApplet.java main/java/

      mkdir \-p test/java/org/ofbiz/shipment/thirdparty/usps/
      git mv org/ofbiz/shipment/thirdparty/usps/UspsServicesTests.java test/java/org/ofbiz/shipment/thirdparty/usps/
     fi         

     for test in $testdirs
     do
      test=$(echo $test \| replace test '')

      mkdir \-p test/java/$test    
 
      for x in $(ls $test/test/)
      do
       echo $x
       sed 's,\.test;,;,' <$test/test/$x >temp      
       cat temp >$test/test/$x
      
       sed 's,\.test\.,\.,g' <$test/test/$x >temp
       cat temp >$test/test/$x 

       echo $test
       sed "s#main/java/$test test/#test/java/$test#g" <../build.xml >temp # ./org/ofbiz does not match

 cat temp >../build.xml

 done
      rm temp      

        git mv $test test/\* test/java/$test
       rm \-r $test test/ #git only

   
     done          

     git mv org/ main/java/
      
     cd ..

     if \[ $dir = 'service' \];
     then
      sed 's,\.test\.,\.,g' <servicedef/services_test_se.xml >temp
      cat temp >servicedef/services_test_se.xml

      sed 's,\.test\.,\.,g' <testdef/servicetests.xml >temp
      cat temp >testdef/servicetests.xml

     elif \[ $dir = 'minilang' \];
     then
      sed 's,\.test\.,\.,g' <testdef/MinilangTests.xml >temp
      cat temp >testdef/MinilangTests.xml

     elif \[ $dir = 'entity' \];
     then
      sed 's,\.test\.,\.,g' <testdef/entitytests.xml >temp
      cat temp >testdef/entitytests.xml    

     elif \[ $dir = 'base' \];
     then
      sed 's,\.test\.,\.,g' <build.xml >temp
      cat temp >build.xml

      sed 's,main/java/org/ofbiz/base/json,org/ofbiz/base/json,g' <build.xml >temp
      cat temp >build.xml 

      sed 's,\.test\.,\.,g' <config/test-containers.xml >temp
      cat temp >config/test-containers.xml

      sed 's,\.test\.,\.,g' <testdef/basetests.xml >temp
      cat temp >testdef/basetests.xml               

     elif \[ $dir = 'securityext' \]; 
     then
      sed 's,\.test\.,\.,g' <testdef/securitytests.xml >temp
      cat temp >testdef/securitytests.xml

      sed 's,\.test\.,\.,g' <testdef/data/SecurityTestData.xml >temp
      cat temp >testdef/data/SecurityTestData.xml

     elif \[ $dir = 'product' \]; 
     then
      sed 's,\.test\.,\.,g' <testdef/FacilityTest.xml >temp
      cat temp >testdef/FacilityTest.xml

      sed 's,ShipmentScaleApplet,main/java/ShipmentScaleApplet,g' <build.xml >temp
      cat temp >build.xml

     elif \[ $dir = 'order' \];
     then
      sed 's,\.test\.,\.,g' <servicedef/services.xml >temp
      cat temp >servicedef/services.xml

      sed 's,\.test\.,\.,g' <testdef/OrderTest.xml >temp
      cat temp >testdef/OrderTest.xml

     elif \[ $dir = 'content' \]; 
     then
      sed 's,\.test\.,\.,g' <testdef/lucenetests.xml >temp
      cat temp >testdef/lucenetests.xml  
 
     elif \[ $dir = 'accounting' \]; 
     then
      sed 's,\.test\.,\.,g' <testdef/accountingtests.xml >temp
      cat temp >testdef/accountingtests.xml

      sed 's,main/java/org/ofbiz/accounting/thirdparty/ideal,**/java/org/ofbiz/accounting/thirdparty/ideal,g'<build.xml >temp
      cat temp >build.xml   
     
     elif \[ $dir = 'sql' \];
     then
      sed 's,main/java/org/ofbiz/sql,org/ofbiz/sql,g' <build.xml >temp
      cat temp >build.xml 

     elif \[ $dir = 'start' \];
     then     
      sed 's,org/ofbiz/base/start/,main/java/org/ofbiz/base/start/,g' <src/main/java/org/ofbiz/base/start/Config.java >temp
      cat temp >src/main/java/org/ofbiz/base/start/Config.java     
     fi 
 
     rm temp

    elif \[ $dir = 'documents' \];
    then
     echo $dir
     sed 's,\.test\.,\.,g' <UnitTest.xml >temp
     cat temp >UnitTest.xml
     rm temp  
    fi    
    cd ..
   fi  
  fi

 done
cd ..
done