CTK Guidebook
Creating your CTK Project
In this description, the Interface Projects are the projects which are used to generate all of the interface and library artefacts from the models.
The Interface Projects are all created using the Project Creator.
Running an interface project will create the stub code needed for libraries or for creating the CTK.
In principle the generated stub code should not be manually modified or extended in the Interface Project.
We need to create a separate CTK project to use this stub code.
In general the process for creating a working CTK project is as follows;
1. Checkout all the models in an interface project as described in Getting_Started but substitute the branch your are working in for the name of the project. Each Interface Project has a number of modules and these all have to be built using maven to get the dependencies into your local maven (.m2) repository. We are not presently deploying any of the generated jars to a public repository.
2. To build the stub CTK code you must must uncomment all of the java modules in the <xxx>_BaseProject before you open a terminal and type
mvn clean install
3. Copy and build the working CTK project
The interface Project only creates the skeleton of the CTK. We need to create a separate CTK project by cloning and renaming the <xxx>_CTKProject (CTK). We will then manually add additional code into these clones to make the CTK. (<xxx> is the name of the interface)
To be clear, WE DO NOT modify the projects used to create the stub code. We copy them into a different branch and modify the copies.
After copying and renaming the CTK project, we need to change the name of the project pom.xml files to match the name of each CTK project. It should not be named the same as the <xxx>_CTKProject (CTK). If you have built the Interface projects correctly, all of the dependencies will be in the local maven repository to all ow you to build your new copied projects.
You need to open a terminal the new copied projects and type
mvn clean install
After that you need to type
mvn eclipse:eclipse.
This has described the general process we are following.
Looking at the Default Operation Test Implementations
CTK tests code will be generated in the following folder.
<PathToWorkSpace>\TIP_XXX_CTKProject\target\generated-sources\ (e.g. C:\ws-ri-ctk\TIP_RAM_CTKProject\target\generated-sources\)
All of the tests in the JOSIF CTK framework inherit from
org.openoss.test.BaseTestNGTestClass.java
in the TIP_EjbImpl_BaseClasses project. In Josif Release 1.1, this class contained a static reference to an application context which was used by all of the tests which inherited from it. This worked fine but was not a suitable strategy for running tests in a web app which might be simultaneously used by more than one user ( multi threading).
This strategy has been replaced by having the BaseTestNGTestClass inherit from
org.springframework.test.context.testng.AbstractTestNGSpringContextTests
which allows each test to pick up a common spring application context (TestContext) without using a static reference.
@ContextConfiguration(locations=\{"/BaseTestNGTestClass-context.xml"\}) public class BaseTestNGTestClass extends org.springframework.test.context.testng.AbstractTestNGSpringContextTests\{ ...
In the present implementation this common TestContext defined in BaseTestNGTestClass-context.xml is simply used as a container for all tests to access the same application context which is constructed from properties files when the BaseTestNGTestClass is first run. This simply avoids a static reference to the application context. There may be opportunity in the future to simplify the application context construction but for now the constructed application context against which the tests run is the same as in JOSIF Release 1.1 for backwards compatibility.
Running your CTK Project
The JOSIF CTK framework is packaged as a simple war which can run in jetty. To run the framework from maven,
1. Build the entire project from the bvase project to make sure that you have al the required dependencies
2. open a terminal in the CTK project
3. type mvn jetty:run-war
4. The CTK will host a web browser at http//localhost:9091/CTK
5. The address of the RI to which the CTK tries to connect is set by the file src/main/resources/tipinterface.properties
- This file is used to set the instance specific URL for the service
- http://<hostAddress>:<hostPort>/<systemName>/<serviceContext>/<InterfaceName>
- <InterfaceName> is standardised in the build for the particular interface
- org.openoss.tip.interface.hostAddress=localhost
org.openoss.tip.interface.hostAddress=88.96.72.51
org.openoss.tip.interface.hostPort=9090
org.openoss.tip.interface.systemName=RI
org.openoss.tip.interface.serviceContext=services
You can run an RI and CTK on the same machine as they use different ports.
The address/port 88.96.72.51:9090 is the current address of the hosted RI.
The present CTK uses a simple web app having a single JSP. This provides buttons to run the tests and view the results. The CTK uses the testNG framework (http://testng.org) and the Spring Test testNG integration (http://static.springsource.org/spring/docs/2.5.x)/reference/testing.html. The Run Tests action of the Test.jsp starts a new instance of the TestNG test runner which discovers and runs all of the annotated tests in a given class path.