Download input information

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Project Proposal
590 L – Distributed Component
Architecture
Medical Data Analysis
Team Members:
Sravanthi Karumanchi
Shalini Pradhan
Galina Walters
I.Test Plan
TEST CASE 1.
Authenticating for valid user.
INPUT INFORMATION
1. Valid Username
2. Valid Password
CONDITION TABLE
EXPECTED OUTPUT / OBJECTIVE
The right login name and a fitting
password are typed in.
The Output-Screen will be created by the
OutputGenerator Servlet and then displayed.
OBJECTIVE
MET?
Y
TEST CASE 2.
Invalid Log in
INPUT INFORMATION
1. Username
2. Password
CONDITION TABLE
The right login name and wrong password
are typed in.
EXPECTED OUTPUT / OBJECTIVE
The “Access Denied JSP Page” -Screen
will be created by the OutputGenerator
Servlet and then displayed.
OBJECTIVE
MET?
Y
TEST CASE 3.
Invalid Log in
INPUT INFORMATION
1. Username
2. Password
CONDITION TABLE
The wrong login name and a password.
EXPECTED OUTPUT / OBJECTIVE
OBJECTIVE
MET?
The “Access Denied JSP Page” -Screen will Y
be created by the OutputGenerator Servlet
and then displayed.
TEST CASE 4.
Request for information by a user logged in as a doctor
INPUT INFORMATION
1. Username
2. Password
3. Role retrieved from User database
CONDITION TABLE

EXPECTED OUTPUT / OBJECTIVE
All values appear once according to 
the role: doctor and permissions
assigned to him.
Page formatted correctly with the
permissions given is displayed i.e.,
doctor page
OBJECTIVE
MET?
Y
TEST CASE 5.
Request for information by a user logged in as a researcher
INPUT INFORMATION
1. Username
2. Password
3. Role retrieved from User database
CONDITION TABLE

EXPECTED OUTPUT / OBJECTIVE
All values appear once according to 
the role: researcher and permissions
assigned to him.
Page formatted correctly with the
permissions given is displayed i.e., the
researcher page
OBJECTIVE
MET?
Y
TEST CASE 6.
Request for information by a user logged in as a researcher and a doctor
INPUT INFORMATION
1. Username
2. Password
3. Role retrieved from User database
CONDITION TABLE

EXPECTED OUTPUT / OBJECTIVE
All values appear once according to 
the role: doctor/researcher and
permissions assigned to these roles.
Page formatted correctly with the
permissions given is displayed i.e., the
doctor page and researcher page
OBJECTIVE
MET?
Y
TEST CASE 7.
Request for individual patient record based on the Social Security Number queried by a
doctor.
INPUT INFORMATION
1. Social Security Number.
CONDITION
1.User is assigned a role as doctor
2.The entered Social Security
Number is valid.
3. Display the record of the patient
when Social Security Number
matches with the one entered and so
with the Username entered
EXPECTED OUTPUT /
OBJECTIVE
Page formatted correctly with
the details of the patient whose
social security number
matches.
OBJECTIVE
MET?
Y
TEST CASE 8.
Request for list of patients records supervised by the doctor.
INPUT INFORMATION
1. Username.
2. Retrieve first name and last name of the doctor from the table.
CONDITION TABLE
EXPECTED OUTPUT / OBJECTIVE
1. User is assigned the role as a doctor 
2. Records of the patients that match the
username are displayed
Page formatted to display the patient
records depending on the last name and
first name of the doctor retrieved from
the table is displayed.
OBJECTIVE
MET?
Y
TEST CASE 9.
Request for list of patients records sorted by age.
INPUT INFORMATION
1. Selecting age.
CONDITION TABLE
EXPECTED OUTPUT / OBJECTIVE
1.Column consists of age of the patient. Page formatted correctly with age as one
2. User is assigned a researcher role
value.
OBJECTIVE
MET?
Y
TEST CASE 10.
Request for the list of patients records sorted by duration of disease
INPUT INFORMATION
1. Duration from when the disease prevails.
CONDITION TABLE
EXPECTED OUTPUT / OBJECTIVE
1.When the radio button, duration is
selected by a researcher, the records
which show the duration from when
the disease prevails are displayed.
2.User is assigned a role as a
researcher
Page formatted correctly with the following
information:
Name of the Disease
Duration
OBJECTIVE
MET?
Y
TEST CASE 11.
Request for the list of patients records sorted by disease name.
INPUT INFORMATION
1. Name of the disease
CONDITION TABLE
EXPECTED OUTPUT / OBJECTIVE
1. When the disease is mentioned all
Page formatted correctly with the following
records matching the criteria are
information:
displayed
2. User is assigned a role as a  Name of the disease
researcher
 List of patients having the disease
OBJECTIVE
MET?
Y
Y
TEST CASE 12
Input transmission, HTML Form to the Servlet.
INPUT INFORMATION
1. Input attributes for database setup
2. Table column
3. Number of Classes
4. Computation actions
CONDITION TABLE
EXPECTED OUTPUT / OBJECTIVE
Valid database / table / column input
All attributes and their values appear
correctly in the Servlet.
OBJECTIVE
MET?
Y
TEST CASE 13.
Valid Extraction of data from the User database.
INPUT INFORMATION
1. database is set.
2. table is set.
3. column is set.
CONDITION TABLE
Valid set database / table / column
EXPECTED OUTPUT / OBJECTIVE
OBJECTIVE
MET?
Return value is a valid, not-empty ResultSet Y
containing Username, Role, Set of
permissions.
Database has entry in ODBC table
TEST CASE 14.
Valid Extraction of data from the data database(1).
INPUT INFORMATION
4. database is set.
5. table is set.
6. column is set.
CONDITION TABLE
Valid set database / table / column
EXPECTED OUTPUT / OBJECTIVE
OBJECTIVE
MET?
Return value is a valid, not-empty ResultSet Y
containing patient’s information
Database has entry in ODBC table
TEST CASE 15.
Valid Extraction of data from the data database(2).
INPUT INFORMATION
7. database is set.
8. table is set.
9. column is set.
CONDITION TABLE
Valid set database / table / column
Database has entry in ODBC table
EXPECTED OUTPUT / OBJECTIVE
OBJECTIVE
MET?
Return value is a valid, not-empty ResultSet Y
containing patient’s information
TEST CASE 16.
Valid creation of the result Hashtable.
INPUT INFORMATION
1. Computation results.
CONDITION TABLE
EXPECTED OUTPUT / OBJECTIVE
class returns valid ResultSet
Creation of a Hashtable with the following
possible content
Computations are correctly done



Patient record
Patient records based on age
Patient records based on duration of
disease
Patient records based on disease
Patient record based on doctor name
Patient record based on SSN



OBJECTIVE
MET?
Y
Y
Y
Y
Y
Y
TEST CASE 17.
Output of the retrieved results as HTML.
INPUT INFORMATION
1. filled result Hashtable.
CONDITION TABLE
EXPECTED OUTPUT / OBJECTIVE
Valid filled result hashtable
All chosen results are printed on the screen





OBJECTIVE
MET?
Y
Patient Records
Y
Patient Records based on age
Patient Records based on duration of the
disease
Patient Records based on disease
Patient Records based on the Social
Security Number mentioned
TEST CASE 18.
All files can be accessed using Jboss (http://localhost:8080/bean/…. )
INPUT INFORMATION
1. WAR-archive
CONDITION TABLE
All files are in the right position in the
War archive
EXPECTED OUTPUT / OBJECTIVE
OBJECTIVE
MET?
If you type http://localhost:8080/bean/filename Y
the file will be displayed or executed



Home.html
Result.jsp
Accessdenied.jsp
Y
Y
Y
TEST CASE 19.
Pressing “Back to main page”.
INPUT INFORMATION
1. Press the button “Back to home page”.
CONDITION TABLE
EXPECTED OUTPUT / OBJECTIVE
The button “Back to home page” is
visible.
The page home.html will be displayed.
OBJECTIVE
MET?
Y
TEST CASE 20.
The sending of a request without naming the operation or naming a wrong operation.
INPUT INFORMATION
1. http://localhost:8080/bean/OutputGenerator?operation=Nonsense
CONDITION TABLE
EXPECTED OUTPUT / OBJECTIVE
The operation name is not valid.
Display of the wrong.jsp page
OBJECTIVE
MET?
Y
Code
Home Interface called UserHome.java
The Enterprise JavaBean's (EJB) home interface lists the methods by which an
application can create, remove, and, for entity beans, find instances of the bean. When an
application containing this home interface is deployed, a class that implements the
interface is generated. Then, an instance of the generated home class is created and
installed in the Java Naming Directory Interface (JNDI) name space where it is visible to
clients. At runtime, a client obtains a reference to an enterprise bean (actually, a remote
interface) by executing either a create or, for entity beans, a finder method on the bean's
home.
package medical.bean;
import javax.ejb.*;
import java.rmi.*;
import java.util.*;
import javax.ejb.CreateException;
import javax.ejb.FinderException;
public interface UserHome extends EJBHome
{
//public String create(String uid, String Password) throws Exception, RemoteException;
public UserRemote create(String uid, String Password) throws RemoteException,
CreateException;
public UserRemote findByPrimaryKey (String pk) throws FinderException,
RemoteException;
}
Remote Interface named as UserRemote.java
The Enterprise JavaBean's remote interface lists which business methods a client
application can access within a bean instance. The remote interface also allows the client
application to obtain the bean's home interface, to remove a bean instance, obtain a
handle for the bean, and in the case of entity beans, obtain the bean's primary key.
package medical.bean;
// This is the remote interface
import javax.ejb.*;
import java.rmi.*;
import java.util.*;
public interface UserRemote extends EJBObject
{
//public String UserDetails();
public String getLName(String id, String pwd) throws RemoteException;
public String getFName(String id, String pwd) throws RemoteException;
public int getAccess(String id, String pwd) throws RemoteException;
}
An entity bean represents a business object in a persistent storage mechanism. Some
examples of business objects are customers, orders, and products. In the J2EE SDK, the
persistent storage mechanism is a relational database. Typically, each entity bean has an
underlying table in a relational database and in our case it is the user-password database
where the Usernames and Passwords are stored. The Entity bean connects to the database
using JDBC:ODBC Driver and then accesses data and then checks for authentication.
Code for UserBean(Entity Bean)
package medical.bean;
import javax.ejb.*;
import java.rmi.*;
import java.util.*;
import javax.naming.*;
import java.sql.*;
public class UserBean implements EntityBean
{
public String uid;
public String upwd;
public String lName;
public String fName;
public int access;
public EntityContext context; // added by NUpura
public String getLName(String id, String pwd) {
uid = id;
upwd = pwd;
Connection con = null;
PreparedStatement ps = null;
ResultSet result = null;
String lName = null;
try {
//Get Last Name
ps = con.prepareStatement ("select Last_Name from Userpassword where
Username = ? and Password = ?");
ps.setString(1, uid);
ps.setString(2,upwd);
result = ps.executeQuery();
if(!result.next())
throw new ObjectNotFoundException("Cannot find User with id = "
+uid);
else
return lName;
}
catch(SQLException se)
{
// throw new RemoteException();
}
catch(ObjectNotFoundException oe)
{
//
throw new RemoteException();
}
finally
{
try
{
if (ps != null)
ps.close();
if (con != null)
con.close();
}
catch(Exception e) {}
}
}
public String getFName(String id, String pwd) {
uid = id;
upwd = pwd;
Connection con = null;
PreparedStatement ps = null;
ResultSet result = null;
String fName = null;
//Get First Name
ps = con.prepareStatement ("select First_Name from Userpassword where
Username = ? and Password = ?");
ps.setString(1, uid);
ps.setString(2,upwd);
result = ps.executeQuery();
if(!result.next())
throw new ObjectNotFoundException("Cannot find User with id = "
+uid);
else
return fName;
finally
{
try
{
if (ps != null)
ps.close();
if (con != null)
con.close();
}
catch(Exception e) {}
}
}
public int getAccess(String id, String pwd) {
uid = id;
upwd = pwd;
Connection con = null;
PreparedStatement ps = null;
ResultSet result = null;
int Access = 0;
//Get Role
ps = con.prepareStatement ("select Role_id from Userpassword where Username
= ? and Password = ?");
ps.setString(1, uid);
ps.setString(2,upwd);
result = ps.executeQuery();
if(!result.next())
throw new ObjectNotFoundException("Cannot find User with id = "
+uid);
else
return access;
finally
{
try
{
if (ps != null)
ps.close();
if (con != null)
con.close();
}
}
catch(Exception e) {}
}
// added by Nupura
public void setEntityContext(EntityContext ctx)
{
context = ctx;
}
public void unsetEntityContext()
{
context = null;
}
// ejbCreate method should take all the User Table columns as Input parameters
public String ejbCreate(String id, String pwd) throws CreateException
{
uid = id;
upwd = pwd;
Connection con = null;
PreparedStatement ps = null;
ResultSet result = null;
try
{
con = this.getConnection();
//Changed on March 31
// ps = con.prepareStatement ("insert into User (id)" + "values(?)");
ps = con.prepareStatement ("select First_Name, Last_Name, Role_id
from Userpassword where Username = ? and Password = ?");
ps.setString(1, uid);
ps.setString(2,upwd);
//do next, result.getString to get the result..
result = ps.executeQuery();
if(!result.next())
throw new Exception("Cannot find User with id = " +uid);
else
{
fName =result.getString("First_Name");
lName = result.getString("Last_Name");
access = result.getInt("Role_id");
}
}
catch(SQLException se)
{
//throw new RemoteException();
}
catch(Exception oe)
{
}
finally
{
try
{
if (ps != null)
ps.close();
if (con != null)
con.close();
}
catch(Exception e) {}
}
return fName;
}
public void ejbPostCreate(String id, String pwd)
throws CreateException
{
System.out.println("IN the post ejb create method ...");
}
// The ejbFindByPrimaryKey verifies the existence of the database row for the given
primary key:
public String ejbFindByPrimaryKey (String pk) throws FinderException
{
Connection con = null;
PreparedStatement ps = null;
ResultSet result = null;
try
{
con = this.getConnection();
ps = con.prepareStatement ("select id from User where id =?");
ps.setString(1, uid);
result = ps.executeQuery();
if(!result.next())
throw new Exception("Cannot find User with id = " +uid);
else
return pk;
}
catch(SQLException se)
{
//
throw new RemoteException();
}
catch(Exception oe)
{
}
finally
{
try
{
if(result!=null)
result.close();
if (ps != null)
ps.close();
if (con != null)
con.close();
}
catch(Exception e) {}
}
return pk;
}
// this method should remove a row from User Table
// if you don't want to implement the delete logic, leave this method blank. But you
have to atleast define this method.
// If you don't define this method, it will result in a compilation error.
public void ejbRemove()
{
Connection con = null;
PreparedStatement ps =null;
try
{
con = this.getConnection();
ps = con.prepareStatement("delete from User where uid = ?");
ps.setString(1, uid);
ps.executeUpdate();
}
catch(SQLException se)
{
// do something like print error to standard output
}
finally
{
try
{
if (ps != null)
ps.close();
if (con != null)
con.close();
}
catch(Exception e) {}
}
} // ejbRemove ends here
public Connection getConnection() throws SQLException
{
try
{
Class.forName("sunjdbc.odbc.JdbcOdbcDriver"); // uses jdbc odbc driver.
you can use other drivers if you want
// If you are using MS access, then use "jdbc:odbc:xyz" where xyz is the
.mdb file.
// user and password are self explantory.
//
Connection con = DriverManager.getConnection("jdbc:odbc:xyz","user",
"password");
return con;
}
catch(Exception e)
{
throw new SQLException();
}
}
// You can implement these methods if you want. But in most cases it is not required
to implement these methods.
// still you should always define those methods and leave implementation blank to
avoid compilation errors.
public void ejbActivate() {}
public void ejbPassivate() {}
public void ejbLoad(){}
public void ejbStore(){}
}
Deployment descriptor is a file in the ejb-jar file that defines the following kinds of
information:


EJB structural information, such as the EJB name, class, home and remote
interfaces, bean type (session or entity), environment entries, resource factory
references, EJB references, security role references, as well as additional
information based on the bean type.
Application assembly information, such as EJB references, security roles,
security role references, method permissions, and container transaction attributes.
Specifying assembly descriptor information is an optional task that an Application
Assembler perform
Deployment Descriptor
<?xml version="1.0" encoding="UTF-8" ?>
- <!-finished on March 26, 2002
-->
- <ejb-jar>
<description>JBoss Medical Access Controller Application</description>
<display-name>medical EJB</display-name>
- <enterprise-beans>
- <session>
<ejb-name>FilterBean</ejb-name>
<home>medical.bean.FilterHome</home>
<remote>medical.bean.FilterRemote</remote>
<ejb-class>medical.bean.FilterBean</ejb-class>
<session-type>Stateful</session-type>
<transaction-type>Bean</transaction-type>
</session>
- <entity>
<ejb-name>UserBean</ejb-name>
<home>medical.bean.UserHome</home>
<remote>medical.bean.UserRemote</remote>
<ejb-class>medical.bean.UserBean</ejb-class>
<persistence-type>Bean</persistence-type>
<prim-key-class>java.lang.String</prim-key-class>
<reentrant>False</reentrant>
</entity>
- <session>
<ejb-name>ListRetrievalBean</ejb-name>
<home>medical.bean.ListRetrievalHome</home>
<remote>medical.bean.ListRetrievalRemote</remote>
<ejb-class>medical.bean.ListRetrievalBean</ejb-class>
<session-type>Stateful</session-type>
<transaction-type>Bean</transaction-type>
</session>
- <entity>
<ejb-name>RecordRetrievalBean</ejb-name>
<home>medical.bean.RecordRetrievalHome</home>
<remote>medical.bean.RecordRetrievalRemote</remote>
<ejb-class>medical.bean.RecordRetrievalBean</ejb-class>
<persistence-type>Bean</persistence-type>
<prim-key-class>java.lang.String</prim-key-class>
<reentrant>False</reentrant>
</entity>
</enterprise-beans>
</ejb-jar>
servlet is a Java programming language class used to extend the capabilities of servers
that host applications accessed via a request-response programming model. Although
servlets can respond to any type of request, they are commonly used to extend the
applications hosted by Web servers.
OutputGenerator Servlet
package medical.bean;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Hashtable;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
//import umkc.appserver.userbean;
//import umkc.appserver.userhome;
public class OutputGenerator extends HttpServlet
{
private UserHome userhome;
private UserRemote userremote;
private String database;
private String table;
private int[] action;
private Hashtable result;
private String[] collumn;
// private ImgCreator ImgCreator;
public void init(ServletConfig config)
{
try{
super.init(config);
}
catch(Exception e){}
}
public void destroy()
{
// other destroy code
//removeBean();
super.destroy();
}
protected void doPost(HttpServletRequest request, HttpServletResponse response)
{
// Set content-type header before accessing the Writer
response.setContentType("text/html");
// Write the data of the response
try{
PrintWriter out = response.getWriter();
//PrintWriter out = new PrintWriter(response.getOutputStream());
}catch(Exception e){}
Properties passwords = null;
String operation = request.getParameter("Login");
//testing the passwd and login
String login = request.getParameter("Username");
String passwd = request.getParameter("PasswordVerify");
//esablish connection to the userbean (entity bean)
try {
javax.naming.Context jndiContext = new
javax.naming.InitialContext(System.getProperties());
Object ref = jndiContext.lookup("bean/UserBean");
userhome = (UserHome)PortableRemoteObject.narrow(ref, UserHome.class);
userremote = userhome.create(login, passwd); //Remote interface
//Getting the Name and the access
String lname = userremote.getLName(login,passwd);
String fname = userremote.getFName(login,passwd);
int access = userremote.getAccess(login,passwd);
} catch (Exception e) {
e.printStackTrace();
}
}
}
There are many more already coded beans and servlets whose code is not added here.