Skip to main content link. Accesskey S
  • Help
  • HCL Logo
  • HCL Notes and Domino Application Development wiki
  • THIS WIKI IS READ-ONLY. Individual names altered for privacy purposes.
  • HCL Forums and Blogs
  • Home
  • Product Documentation
  • Community Articles
  • Learning Center
  • API Documentation
Search
Community Articles > Developing Applications > Developing XPage Applications > XPage Tutorials > Testing XPages: Quick Start
  • Share Show Menu▼
  • Subscribe Show Menu▼

Recent articles by this author

Testing XPages: Quick Start

This article will go through the steps required to set up a provided test project to test your custom XPages controls. In this tutorial we will be using an example control project: com.example.greenbox, but same steps can be applied to other controls. To follow this tutorial, import the ...

Testing XPages with JUnit Test Framework

This article will go through the steps required to set up a test project to test custom XPages controls. In this tutorial we will be using an example control project: com.example.xsp, but same steps can be applied to other controls. To follow this tutorial, import the com.example.xsp project which ...
Community articleTesting XPages: Quick Start
Added by ~Yentl Nonfooburader | Edited by ~Fred Ektumilitetsi on April 23, 2014 | Version 85
  • Actions Show Menu▼
expanded Abstract
collapsed Abstract
No abstract provided.
ShowTable of Contents
HideTable of Contents
  • 1 Preparing Designer Development Environment
  • 2 Configuring Test Project
  • 3 Renaming The Test Project
  • 4 Running Test Framework and Fixing Fails
    • 4.1 Running JUnit tests
    • 4.2 GreenboxGroupReuseTest
    • 4.3 GreenboxControlCategoryKnownTest
    • 4.4 GreenboxRoleAccessibilityTest
    • 4.5 GreenboxSinceVersionsSetTest
    • 4.6 BaseRenderThemeControlTest
This article will go through the steps required to set up a provided test project to test your custom XPages controls.

In this tutorial we will be using an example control project: com.example.greenbox, but same steps can be applied to other controls.
To follow this tutorial, import the com.example.greenbox project which can be found in the article's Attachments list.
This is a shorter, less detailed version of the article Testing XPages with JUnit Test Framework.
This article is part of the XPages Extensibility API Developers Guide.

Preparing Designer Development Environment


First step is to launch Domino Designer and switch to Java Perspective.
From the menu select Window -> Open Perspective -> Java

(Note, if you don't see that screenshot, try refreshing your browser.)

Next, we download an ExtLib openNTF release from http://extlib.openntf.org/external link.
Extract srcOpenNTF.zip file.
Navigate to eclipse\plugins folder. Import com.ibm.xsp.test.framework project to Domino Designer.
Click File -> Import


Select General -> Existing Projects into Workspace

Click Next. Navigate to the folder where com.ibm.xsp.test.framework was extracted and import the project.

Download the two attachments(com.example.junit.tests.zip and com.example.greenbox.zip) provided in the article.
Extract the zip files and import the projects using the steps as above.

You will have three projects imported that look like so:


com.example.junit.tests will have 3 compilation errors. This is because it is referencing an old plugin library.
We will be replacing old references to point to our own plugin library(com.example.greenbox).


Configuring Test Project


In the MANIFEST.MF in the test project(com.example.junit.tests), remove dependency on the com.example.xsp project
Add a new dependency for your library plugin (in our case it's com.example.greenbox) so it looks like so:

Plug-ins dependency

In the com.example.junit.tests project open WEB-INF/xsp.properties file with the Properties File Editor


Change the dependency from com.example.library to your own (in our case it's com.example.greenbox.library)
The library id is being returned by getLibraryId method from GreenboxLibrary Java Class.
It should look like so:
xsp.library.depends=\
    com.ibm.xsp.core.library,\
    com.ibm.xsp.extsn.library,\
    com.ibm.xsp.designer.library,\
    com.ibm.xsp.domino.library,\
    com.example.greenbox.library
Open config.properties in the com.example.junit.tests test project package com.ibm.xsp.test.framework
Change the target.library and NamingConvention.package.prefix to your own control
(in our case it's com.example.greenbox.library and com.example.greenbox respectively). It should look like so:
# The XspLibrary.getLibraryId() value of the library 
# whose contents should be tested, defaults to none, 
# meaning that only local xsp-configs are loaded.
target.library=com.example.greenbox.library

# Package name and component-type prefix, like "com.ibm.xsp" or 
# "com.ibm.xsp.extlib", used in the NamingConventionTest
#NamingConvention.package.prefix=

NamingConvention.package.prefix=com.example.greenbox

# Extra libraries whose xsp-config files should be loaded
# when creating a registry 
extra.library.depends.designtime.nonapplication=\
    com.ibm.xsp.core.library,\
    com.ibm.xsp.extsn.library,\
    com.ibm.xsp.designer.library,\
    com.ibm.xsp.domino.library
In the com.example.junit.tests test project, open pages/simpleTestOfExampleControl.xsp
From Java perspective, the graphical editor is not available for XPages. Just click OK. It will open the source of the XPage.

Change the XPage(prefix, namespace, tag) to use your own control. In our case it should look like so:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:eg="http://greenbox.example.com/xsp/control">
    <eg:greenboxControl/>
</xp:view>


In the test project(com.example.junit.tests), open ExamplePrintTagNamesAndProps.java from the xsp.example.test.version package.
Somewhere around line #22 change the following code to use your own control (in our case it's Greenbox Library).
Change from:
tagsAndProps = filterToDependsLibrary(registry, (new ExampleLibrary()).getLibraryId(), tagsAndProps);

to
tagsAndProps = filterToDependsLibrary(registry, (new GreenboxLibrary()).getLibraryId(), tagsAndProps);

You might need to organize your imports (Right-click on the file. Source -> Organize Imports) to remove unused references to the old control.


Run the tests:
Right-click on the ExampleTestSuite Java Class in xsp.example.test package
Select Run As -> JUnit Test


This will result in JUnit fails, but ignore this for the moment.
Refresh the test project (com.example.junit.tests). gen folder should now contain generated Java Classes for the corresponding XPage above.

Renaming The Test Project


The sample test project was named to use with the example control. In this section we will go through the steps to rename the test project to use with our control.
For the tutorial purpose, we will be renaming the project to our Greenbox example control but same steps can applied to your own control.
We will start with renaming the project name and proceed to packages after.

Right click on the com.example.junit.tests project. Refactor -> Rename


Name the project to be com.example.greenbox.junit.tests


Now the project is renamed, but it still has the old project name on the file system.
Remove the project from the workspace:
Right-click on the com.example.greenbox.junit.tests. Select Delete.
Make sure you don't check Delete project contents on disk (cannot be undone) checkbox!


Navigate to the com.example.greenbox.junit.tests project's location on the file system.
It will still have the old project name: com.example.junit.tests. Again, rename the folder to com.example.greenbox.junit.tests.
Import the project back to your Domino Designer workspace.

We are going to rename the packages in the test project com.example.greenbox.junit.tests.

Right click on the xsp.example.test package. Refactor -> Rename


Name the package to be xsp.example.greenbox.test
Make sure the two checkboxes are selected: Update references and Rename subpackages


More likely, you will get a warning dialog. Click Continue.



Now your test project structure should look like so:


The com.ibm.xsp.test.framework package should not be renamed as the name is required by the test framework.

Now we are going to rename Java Classes to reflect the the use of our control.
Right click on ExampleTestSuite.java in the com.example.greenbox.test package. Refactor -> Rename


Name it to be GreenboxTestSuite like so


Follow the same pattern for the remaining Java Classes: replacing Example[...] with Greenbox[...].
So that the test project structure looks like so:


Running Test Framework and Fixing Fails


Here we will run JUnit and fix failures one by one.

Running JUnit tests


Same as in previous steps, run the JUnit test framework:
Right-click on the GreenboxTestSuite Java Class from xsp.eample.greenbox.test package
Select Run As -> JUnit Test


The result will have 6 failures. Next, we are going to address the failures one at the time. So by the end of this tutorial, we will have a fully working test project.

GreenboxGroupReuseTest


This test fails with the following message:
junit.framework.AssertionFailedError: 2 fail(s). :
META-INF/greenboxControl.xsp-config eg:greenboxControl title Should reuse <group-type-ref> for an existing control group: com.ibm.xsp.group.core.prop.title
Unused skip: META-INF/exampleControl.xsp-config eg:exampleControl title Should reuse <group-type-ref> for an existing control group: com.ibm.xsp.group.core.prop.title


Basically, this message is saying that there is an unused skip. Skips are used to ignore some failures which are not needed for the control to function.
As you can see the two messages are nearly identical.
This is because we were renaming the test project, but it still has references to the old project.

1. Copy the error message by right-clicking on the contents of the Failure Trace pane and selecting Copy Trace like so:

2. Paste the error message somewhere in a text file and copy just the second line:
META-INF/greenboxControl.xsp-config eg:greenboxControl title Should reuse <group-type-ref> for an existing control group: com.ibm.xsp.group.core.prop.title


3. Since the test that failed is GreenboxGroupReuseTest, double-click on the failure: xsp.example.greenbox.test.registry.GreenboxGroupReuseTest
It will open the corresponding file.

4. You will see the skips variable of String[] type. It will contain an old skip message. Replace with the one we copied earlier so it looks like so:
private String[] skips = new String[]{
    "META-INF/greenboxControl.xsp-config eg:greenboxControl title Should reuse <group-type-ref> for an existing control group: com.ibm.xsp.group.core.prop.title"
};

5. Rerun JUnit test. There will be one less failure(5 total).

GreenboxControlCategoryKnownTest


Same as with previous test, it fails with the "unused skip" message. So we are going to do the same here.

junit.framework.AssertionFailedError: 2 fail(s). :
META-INF/greenboxControl.xsp-config eg:greenboxControl unknown category: Example
Unused skip: META-INF/exampleControl.xsp-config eg:exampleControl unknown category: Example


1. Copy the error message by right-clicking on the contents of the Failure Trace pane and selecting Copy Trace
2. Paste the error message somewhere in a text file and copy just the second line:
META-INF/greenboxControl.xsp-config eg:greenboxControl unknown category: Example

3. Since the test that failed is GreenboxControlCategoryKnownTest, double-click on the corresponding failure.
4. You will see the skips variable of String[] type. It will contain an old skip message. Replace with the one we copied earlier so it looks like so:
private String[] skips = new String[]{
    "META-INF/greenboxControl.xsp-config eg:greenboxControl unknown category: Example"
};

5. Rerun JUnit test. There will be one less failure(4 total).

GreenboxRoleAccessibilityTest


Again, it is the same type of fail as the two previous test failures.

junit.framework.AssertionFailedError: 2 fail(s). :
META-INF/greenboxControl.xsp-config eg:greenboxControl Expected role property for accessibility does not exist.
Unused skip: META-INF/exampleControl.xsp-config eg:exampleControl Expected role property for accessibility does not exist.


1. Copy the error message by right-clicking on the contents of the Failure Trace pane and selecting Copy Trace
2. Paste the error message somewhere in a text file and copy just the second line:
META-INF/greenboxControl.xsp-config eg:greenboxControl Expected role property for accessibility does not exist.

3. Since the test that failed is GreenboxRoleAccessibilityTest, double-click on the corresponding failure.
4. You will see the skips variable of String[] type. It will contain an old skip message. Replace with the one we copied earlier so it looks like so:
private String[] skips = new String[]{
    "META-INF/greenboxControl.xsp-config eg:greenboxControl Expected role property for accessibility does not exist."
};

5. Rerun JUnit test. There will be one less failure(3 total).

GreenboxSinceVersionsSetTest


Under this test, there will be 2 failures:

junit.framework.AssertionFailedError: 2 fail(s). <since> version mismatch:
eg:exampleControl not found. Expected <since>1.0.0<
META-INF/greenboxControl.xsp-config eg:greenboxControl bad since version. Expected <since>1.0.0(probably)<, was <since>1.0.0<


and

junit.framework.AssertionFailedError: 1 fail(s). GreenboxSinceVersionLists$Example100List is out of date. Please regenerate that class. :
tag eg:greenboxControl has new props: 2 {header, title}


The first failure is about version mismatch. This is because we renamed our test project, but it's still referencing the old control and properties.
1. Right-click on the GreenboxPrintTagNamesAndProps from the xsp.example.greenbox.test.version package and run as Java Application like so:

This will print out an object with your control name and corresponding properties to the console. Like so:
PrintTagNamesAndProps.main()
new Object[]{"eg:greenboxControl", true, new String[]{
    "header",
    "title",
}},

Copy everything from the console output except the first line.
2. Open GreenboxSinceVersionLists Java Class from the xsp.exmaple.greenbox.test.version package.
Replace the already existing object with the one from above. So that it looks like this:
new Object[]{"eg:greenboxControl", true, new String[]{
    "header",
    "title",
}},

3. Rerun JUnit test. There will be two failures less (1 total).

BaseRenderThemeControlTest



The last failure is a known issue. The XPages team is working to fix this. Please ignore this failure.
To have a fully passing test project, run the Green Test Suite. It will ignore this failure.

Right-click on the GreenGreenboxTestSuite from the xsp.example.greenbox.test. Run As -> JUnit Test


The tests will pass.

For more detailed information and further explanation, see the Testing XPages with JUnit Test Framework article.

  • Actions Show Menu▼


expanded Attachments (3)
collapsed Attachments (3)
Edit the article to add or modify attachments.
File TypeSizeFile NameCreated OnDelete file
application/x-zip 26 KB com.example.junit.tests.zip 4/23/14, 1:05 PM
application/x-zip 10 KB com.example.greenbox.zip 4/23/14, 1:06 PM
application/x-zip 19 KB finished_project.zip 4/23/14, 1:07 PM
expanded Versions (85)
collapsed Versions (85)
Version Comparison     
VersionDateChanged by              Summary of changes
This version (85)Apr 23, 2014, 1:19:48 PM~Fred Ektumilitetsi  
84Jan 18, 2014, 6:13:52 PM~Paul Kiretex  
83Sep 13, 2013, 3:23:26 PM~Elizabeth Cisboosiburakol  
82May 23, 2013, 2:29:22 PM~John Optumilitgon  
81May 16, 2013, 12:06:24 PM~John Optumilitgon  
79May 16, 2013, 11:54:51 AM~John Optumilitgon  
78May 16, 2013, 11:49:07 AM~John Optumilitgon  
77May 10, 2013, 5:59:55 PM~John Optumilitgon  
76May 10, 2013, 5:52:32 PM~John Optumilitgon  
75May 10, 2013, 5:38:28 PM~John Optumilitgon  
74May 10, 2013, 5:33:31 PM~John Optumilitgon  
73May 10, 2013, 5:18:25 PM~John Optumilitgon  
72May 10, 2013, 5:16:40 PM~John Optumilitgon  
71May 10, 2013, 4:56:41 PM~John Optumilitgon  
70May 10, 2013, 4:42:32 PM~John Optumilitgon  
69May 10, 2013, 4:25:21 PM~John Optumilitgon  
68May 10, 2013, 4:23:08 PM~John Optumilitgon  
67May 10, 2013, 4:22:32 PM~John Optumilitgon  
66May 10, 2013, 4:22:02 PM~John Optumilitgon  
65May 10, 2013, 4:20:03 PM~John Optumilitgon  
64May 10, 2013, 4:19:33 PM~John Optumilitgon  
63May 10, 2013, 4:18:48 PM~John Optumilitgon  
62May 10, 2013, 4:18:19 PM~John Optumilitgon  
61May 10, 2013, 4:16:23 PM~John Optumilitgon  
60May 10, 2013, 4:14:19 PM~John Optumilitgon  
59May 10, 2013, 4:13:26 PM~John Optumilitgon  
58May 10, 2013, 3:52:14 PM~John Optumilitgon  
57May 9, 2013, 1:22:51 PM~John Optumilitgon  
56May 9, 2013, 1:20:23 PM~John Optumilitgon  
55May 9, 2013, 1:19:37 PM~John Optumilitgon  
54May 9, 2013, 1:17:31 PM~John Optumilitgon  
53May 9, 2013, 1:14:00 PM~John Optumilitgon  
52May 9, 2013, 1:08:46 PM~John Optumilitgon  
51May 9, 2013, 1:07:48 PM~John Optumilitgon  
50May 9, 2013, 1:04:15 PM~John Optumilitgon  
49May 9, 2013, 12:57:40 PM~John Optumilitgon  
48May 9, 2013, 12:54:39 PM~John Optumilitgon  
47May 9, 2013, 12:44:39 PM~John Optumilitgon  
46May 9, 2013, 12:33:21 PM~John Optumilitgon  
45May 3, 2013, 2:25:08 PM~John Optumilitgon  
44Apr 25, 2013, 1:45:19 PM~John Optumilitgon  
43Apr 24, 2013, 9:17:34 AM~John Optumilitgon  
42Apr 23, 2013, 10:05:44 AM~John Optumilitgon  
41Apr 23, 2013, 9:28:20 AM~John Optumilitgon  
40Apr 22, 2013, 1:33:56 PM~John Optumilitgon  
39Apr 22, 2013, 12:14:12 PM~John Optumilitgon  
38Apr 22, 2013, 12:07:53 PM~John Optumilitgon  
37Apr 22, 2013, 12:02:06 PM~John Optumilitgon  
36Apr 22, 2013, 10:31:45 AM~John Optumilitgon  
35Apr 22, 2013, 10:21:30 AM~John Optumilitgon  
34Apr 22, 2013, 10:21:07 AM~John Optumilitgon  
33Apr 22, 2013, 10:20:06 AM~John Optumilitgon  
32Apr 22, 2013, 10:16:22 AM~John Optumilitgon  
31Apr 22, 2013, 10:13:22 AM~John Optumilitgon  
30Apr 22, 2013, 10:09:01 AM~John Optumilitgon  
29Apr 22, 2013, 10:08:18 AM~John Optumilitgon  
28Apr 5, 2013, 2:00:12 PM~John Optumilitgon  
27Apr 5, 2013, 10:48:57 AM~John Optumilitgon  
26Apr 5, 2013, 10:46:32 AM~John Optumilitgon  
25Apr 5, 2013, 10:40:21 AM~John Optumilitgon  
24Apr 4, 2013, 12:48:37 PM~John Optumilitgon  
23Apr 4, 2013, 12:46:57 PM~John Optumilitgon  
22Apr 4, 2013, 12:38:54 PM~John Optumilitgon  
21Apr 4, 2013, 12:38:35 PM~John Optumilitgon  
20Apr 4, 2013, 12:36:04 PM~John Optumilitgon  
19Apr 3, 2013, 3:04:31 PM~John Optumilitgon  
18Apr 3, 2013, 3:03:54 PM~John Optumilitgon  
17Apr 3, 2013, 9:02:29 AM~John Optumilitgon  
16Apr 3, 2013, 9:02:03 AM~John Optumilitgon  
15Apr 3, 2013, 9:00:55 AM~John Optumilitgon  
14Apr 3, 2013, 8:52:17 AM~John Optumilitgon  
13Apr 2, 2013, 10:53:36 AM~John Optumilitgon  
12Apr 2, 2013, 10:51:08 AM~John Optumilitgon  
11Apr 2, 2013, 10:46:11 AM~John Optumilitgon  
10Apr 2, 2013, 10:40:16 AM~John Optumilitgon  
9Apr 2, 2013, 10:39:42 AM~John Optumilitgon  
8Apr 2, 2013, 10:39:10 AM~John Optumilitgon  
7Apr 2, 2013, 10:37:48 AM~John Optumilitgon  
6Apr 2, 2013, 10:36:16 AM~John Optumilitgon  
5Apr 2, 2013, 10:35:21 AM~John Optumilitgon  
4Apr 2, 2013, 10:28:25 AM~John Optumilitgon  
3Apr 2, 2013, 10:24:03 AM~John Optumilitgon  
2Apr 2, 2013, 10:17:43 AM~John Optumilitgon  
1Apr 2, 2013, 9:49:18 AM~John Optumilitgon  
1Apr 2, 2013, 9:53:14 AM~John Optumilitgon  
expanded Comments (0)
collapsed Comments (0)
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedAbout
  • HCL Software
  • HCL Digital Solutions community
  • HCL Software support
  • BlogsDigital Solutions blog
  • Community LinkHCL Software forums and blogs
  • About HCL
  • Privacy
  • Accessibility