beautypg.com

HP Integrity NonStop J-Series User Manual

Page 125

background image




Creating Test class to Test the RMI service

To create the test class that can be used to test the RMI Service, complete the following steps:
1.

Create a com.hp.empinfo.domain package and an RmiClientTest class under the
com.hp.empinfo.domain

package, as described in

“Creating the Controller for EmpInfo”

(page 91)

.

2.

Modify the RmiClientTest.java file to invoke the RMI service by adding the following
code:

package com.hp.empinfo.domain;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.hp.empinfo.service.EmployeeInfo;

public class RmiClientTest {

public static String [] configFileNames = new String [] {"applicationContext.xml","clientContext.xml"};
private static ApplicationContext applicationContext = null;

public static void main(String[] args) {
applicationContext = new ClassPathXmlApplicationContext(configFileNames);
EmployeeInfo empInfo = (EmployeeInfo)applicationContext.getBean("rmiProxy");
Employee employee = empInfo.getEmployee(2);

System.out.println("Employee First Name : "+employee.getFirstname());
System.out.println("Employee Last Name : "+employee.getLastname());
System.out.println("Employee Email : "+employee.getEmail());
System.out.println("Employee Id : "+employee.getEmpid());

}

}

Creating the clientContext.xml file

To create the clientContext.xml file, complete the following steps:
1.

Create the clientContext.xml file in the EmpInfo/WebContent/WEB-INF/ directory,
as described in

“Creating the EmpInfo-servlet.xml File” (page 86)

.

2.

Modify the clientContext.xml file to add the RMI client bean. After modification, the
clientContext.xml

file must appear as follows:


"http://www.springframework.org/dtd/spring-beans-2.0.dtd">


class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
classpath:client.properties



rmi://${serverName}:${rmiPort}/empDetail


com.hp.empinfo.service.EmployeeInfo


Creating the client.properties file

To create the client.properties file, complete the following steps:
1.

Create the client.properties file in the EmpInfo/WebContent/WEB-INF/ directory,
as described in

“Creating the jdbc.properties File” (page 107)

.

Overview of EmpInfo

125

This manual is related to the following products: