This article illustrates how to create a simple page in sipXconfig, for both user and admin portal.
Notes
Throughout this article I will consider the '/main/sipXconfig' the root directory.
Intro
We use test-driven development (TDD) in order to create / modify a page or fix a issue.
TDD is an iterative software development process where you first write the test with the idea that it must fail. See http://en.wikipedia.org/wiki/Test-driven_development for more information.
For that we use JUnit, JWebUnit, HtmlUnit, DbUnit, etc.
Use 'ant' tool to run these tests (from 'sipXconfig' directory):
ant test-all -Dtest.name=MyTest
I Admin portal
1. Add a new menu (MyMenu) and a new entry (MyPage) to the new page
a. Add a test for the new menu and the new page
Under '/sipXconfig/web/test' directory, create a new package org.sipfoundry.sipxconfig.site.admin.mypackage and a new test class in this package (MyPageTestUi.java):
Run this test:
ant test-all -Dtest.name=MyPage
This test will fail with the following errors:
[~lceausescu@itcnetworks.ro:junit] Test org.sipfoundry.sipxconfig.site.admin.mypackage.MyPageTestUi FAILED
............
[~lceausescu@itcnetworks.ro:concat] testcase: MyPageTestUi
[~lceausescu@itcnetworks.ro:concat] junit.framework.AssertionFailedErrorjunit.framework.AssertionFailedError: Unable to find link with id [~lceausescu@itcnetworks.ro:menu.myPage]
b. Create the menu entry and the page
In sipXconfig/web/context/WEB-INF/common/AdminNavigation.html file, add the next piece of code:
and in sipXconfig/web/context/WEB-INF/common/AdminNavigation.properties, add the following two lines:
Now you can see these changes in the picture below:
Under 'sipXconfig/web/context/WEB-INF/admin/', create 'mypackage' directory and three files in this directory, as follows:
MyPage.page
MyPage.html
MyPage.properties
Create also /sipXconfig/web/src/org/sipfoundry/sipxconfig/site/user_portal/MyUserPage.java class
Now MyPageTestUi test will pass and changes can be seen below:
2. Add tabs for this page
a. Modify the unit test
MyPageTestUi.java
If we run this test again, it will fail:
[~lceausescu@itcnetworks.ro:junit] Test org.sipfoundry.sipxconfig.site.admin.mypackage.MyPageTestUi FAILED
.................................................
[~lceausescu@itcnetworks.ro:concat] testcase: MyPageTestUi
[~lceausescu@itcnetworks.ro:concat] junit.framework.AssertionFailedErrorjunit.framework.AssertionFailedError: Unable to find link with id [link:first]
b. Add the tabs
We will modify previously created files as follows:
MyPage.html
MyPage.properties
MyPage.java
Now MyPageTestUi test will pass and changes can be seen below:
II User portal
Adding a page in User portal is similar to adding a page in the Admin portal
1. Add a new entry to the new page (MyUserPage)
Under '/sipXconfig/web/test/org/sipfoundry/sipxconfig/site/user_portal' package create a new test class (MyUserPageTestUi.java):
Run the test - ant test-all -Dtest.name=MyUserPage
This test will fail:
junit Test org.sipfoundry.sipxconfig.site.user_portal.MyUserPageTestUi FAILED
.......................................................
concat testcase: MyUserPageTestUi
concat junit.framework.AssertionFailedErrorjunit.framework.AssertionFailedError: Unable to find link with id menu.myUserPage
In /sipXconfig/web/context/WEB-INF/user_portal/UserPortalNavigation.html file, add the next piece of code:
and in '/sipXconfig/web/context/WEB-INF/user_portal/UserPortalNavigation.properties' file, add
Now you can see these changes in the picture below:
In '/sipXconfig/web/context/WEB-INF/user_portal/' create three files:
MyUserPage.page
MyUserPage.html
MyUserPage.properties
Create also MyUserPage.java class, under /sipXconfig/web/src/org/sipfoundry/sipxconfig/site/user_portal/ package.
Now MyUserPageTestUi test will pass and changes can be seen below:
2. Add tabs for this page
Modify MyUserPageTestUi.java test class:
Re-run test: ant test-all -Dtest.name=MyUserPage
junit Test org.sipfoundry.sipxconfig.site.user_portal.MyUserPageTestUi FAILED
...................................
concat testcase: MyUserPageTestUi
concat junit.framework.AssertionFailedErrorjunit.framework.AssertionFailedError: Unable to find link with id first
We will modify previously created files as follows:
MyUserPage.html
MyUserPage.properties
MyUserPage.java
Now MyUserPageTestUi test will pass and changes can be seen below: