Thursday, November 14, 2013

How Do I Test My Provisioning Engine?



Ah! So, you have a brand new provisioning engine and you want to know how to test it. Well, that's really simple. You have two choices, first you can just terminate the Apache Tomcat UCDT service that is running and then relaunch it in a command mode window. Or, you can just leave it as is and use the system logs within UCDT to debug it.




First, let's talk about Log4J.

The system already has Log4J installed, so, you can just tag along and use the logging files to write your debugging data.

In case you have never used Log4J, you can simply add these few lines of code to make it work:

First, for any class you have created add this line just after the "public class....." line:


private static Logger logger = Logger.getLogger(<theClassNameOfTheClassIAmInsideOf>.class);


Now, to use Log4J you only need to sprinkle these kinds of lines about in strategic places:


logger.info("Entering method executeTemplate for LDAP there is no Values data.");


Perfect, now you can basically write debugging messages to the UCSPT-CE.log file that is located in:


C:\Program Files\Cisco Systems\UCDT\Tomcat\webapps\UCSPT-CE\logs 


Be liberal in writing to the file while in test/debug mode as it will only help you to find out where you are in the code.


The best way to debug, hands down, is to kill the Apache Tomcat UCDT service and run it in a command mode window. This will allow you to avoid Log4J and just do a ton of System.out.println's where ever you need so you can determine what is going on. And, one of the great side benefits is that you can just kill the CMD mode window to kill UCDT - waiting for the Apache Tomcat UCDT service to restart can be a little bit like watching grass grow on a hot summer day (I mean, it can be slow).

OK, I wont tell you how to stop a service, other than to say you will do it from your "Start Task Manager" function. Click on the Services tab and then click the Services button on that page. From there you can find it. If you are running something less than Windows 7 you will just have to google "services.msc", or just run it on your PC.

Once killed and stopped, you might want to change its properties so that its "Startup Type" is "Manual", you will need to launch UCDT manually if you do this.

You will need two things, first a setup.bat file and know where to put it.

The setup.bat file is a simple little bat file that will set up the classpath and path. So, within the folder:

C:\Program Files\Cisco Systems\UCDT\Tomcat\bin

create a new file called setup.bat and within that file paste these lines:

SET JAVA_HOME=C:\Program Files\Cisco Systems\UCDT\Tomcat\
SET JRE_HOME=C:\Program Files\Cisco Systems\UCDT\Tomcat\jre
SET PATH=%JAVA_HOME%;%PATH%;%JAVA_HOME%\bin;%PATH%;


It is the typical stuff you need to set, look in C:\Program Files\Cisco Systems\ and you will find all the folders deployed there.

From this point you can just add System.out.println() statements througout your code and watch the console to view any messages that will help you do identify where you are in the code or what is causing whatever problem your are working through.


Whether you want to use Log4J (highly recommend once you are in production mode) or you will want to use System.out.println, the choice is yours.

Good luck with it!










No comments:

Post a Comment