Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Introduction
The Library Management System application for assisting a librarian in managing library books. The system
would provide basic set of features to add/update clients, add/update books, search for books, dues if any and
manage check-in / checkout processes. This test plan is a basic guideline for future testing in the LMS.
Testing Strategies -:
1. Unit Testing:
Definition: Test smallest testable parts of an application, called units, are individually and independently
scrutinized for proper operation.
Participants/ Tested by: Developers
Methodology: Used for the Database test, records in each table, Basic function test, add a student, add a book,
Network test
Definition: Integration testing is the phase in software testing in which individual software modules
are combined and tested as a group.
System integration testing (SIT) is a high-level software testing process in which testers verify that all
related systems maintain data integrity and can operate in coordination with other systems in the same
environment.
Participants/ Tested by: System Tester
Methodology: It is used for the Database test, Queries for insert, update, delete the records.
3. Acceptance Testing -:
Definition: Formal testing with respect to user needs, requirements, and business processes conducted to
determine whether or not a system satisfies Participants/ Tested by: Users / End Users
Methodology: It is used for Whole System Test.
Definition: Determine how a system performs in terms of responsiveness and stability under a particular
workload.
Stress testing tries to break the system under test by overwhelming its resources or by taking resources away
from it.
Participants/ Tested by: Tester
Methodology: It is used for the Database test, records in each table, Basic function test, Network test.
Index
1. Introduction.
2. Program.
3. Algorithm.
4. Documentation.
5. Flowchart.
6. Test cases
1. Boundary Value analysis
2. Equivalence value analysis.
3. Path testing.
1 .PROGRAM
package com.lms;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
public class LMSImpl
{ static List<BookDetails> books = new ArrayList<BookDetails>();
static Map<Integer, ArrayList<BookIssueDetails>> hm = new HashMap<Integer, ArrayList<BookIssueDetails>>();
public static void main(String[] args) {
addIssueDetails();
System.out.println("Library Management System");
System.out.println("Press 1 to add Book");
System.out.println("Press 2 to issue a book");
System.out.println("Press 3 to return a book");
System.out.println("Press 4 to print the book details");
System.out.println("Press 5 to print complete issue detais");
System.out.println("Press 6 to exit");
Scanner c = new Scanner(System.in);
int choice = c.nextInt();
do
{ switch (choice)
{ case 1:
addBook();
break;
case 2:
issueBook();
break;
case 3:
returnBook();
break;
case 4:
printBookDetails();
break;
case 5:
printCompleteIssueDetails();
break;
case 6:
System.exit(0);
default:
System.out.println("Invalid input");
break;
}
c = new Scanner(System.in);
choice = c.nextInt();}
while (choice > 0 && choice < 6);}
private static void printCompleteIssueDetails()
{ for (Map.Entry<Integer, ArrayList<BookIssueDetails>> entry : hm.entrySet())
{ for (BookIssueDetails b : entry.getValue()) {
System.out.println(entry.getKey() + " " + b.getBookNumber()
+ " " + b.getNsa5a6ame() + " " + b.getNoOfBookIssued()
+ " " + b.getIssueDate() + " " + b.getReturnDate());}}}
private static void printBookDetails() {
for (BookDetails b : books)
{ System.out.print(b.getBookNumber() + " " + b.getBookName() + " "+ b.getCount() + " " + b.getPrice());}}
private static void returnBook()
{ System.out.println("Enter studentId & bookId");
Scanner c = new Scanner(System.in);
int id = c.nextInt();
int bookId = c.nextInt();
List<BookIssueDetails> bd = hm.get(id);
for (BookIssueDetails b : bd) {
if (b.getBookNumber() == bookId)
{ Date issueDate = b.getIssueDate();
Date todayDate = new Date();
long diff = todayDate.getTime() - issueDate.getTime();
long diffDays = diff / (24 * 60 * 60 * 1000);
if (diffDays > 10)
{ int fine = (int) (diffDays - 10);
fine = fine * 10;
System.out.println("Total Fine " + fine + " Rs.");}}}}
private static void addIssueDetails() {
BookIssueDetails bd1 = new BookIssueDetails(1,"abc",1,new Date("04/04/2015"));
BookIssueDetails bd2 = new BookIssueDetails(2,"xyz",1,new Date());
BookIssueDetails bd3 = new BookIssueDetails(3,"mn",1,new Date());
BookIssueDetails bd4 = new BookIssueDetails(4,"u",1,new Date());
ArrayList<BookIssueDetails> list1 = new ArrayList<BookIssueDetails>();
ArrayList<BookIssueDetails> list2 = new ArrayList<BookIssueDetails>();
ArrayList<BookIssueDetails> list3 = new ArrayList<BookIssueDetails>();
Array List<BookIssueDetails> list4 = new Array List<BookIssueDetails> ();
list1.add (bd1);
list2.add (bd2);
list3.add (bd3);
list4.add (bd4);
hm.put (100, list1);
hm.put (101, list2);
hm.put (103, list3);
hm.put (104, list4);
}
Private static void issue Book ()
{ System.out.println ("Enter Student Id, Booknumber, name and price");
Scanner c = new Scanner (System. in);
int student = c.nextInt();
Scanner c1 = new Scanner (System. in);
int book Number = c1.nextInt();
Scanner c2 = new Scanner (System. in);
String name = c2.nextLine ();
Scanner c3 = new Scanner (System. in);
String issue Date = c3.nextLine ();
BookIssueDetails newIssuedBook = new BookIssueDetails ();
newIssuedBook.setName (name);
newIssuedBook.setBookNumer (book Number);
Array List<BookIssueDetails> l=new Array List<BookIssueDetails> ();
SimpleDateFormat formatter = new SimpleDateFormat ("dd-MMM-yyyy");
Try
{ Date date = formatter. Parse(issue Date);
newIssuedBook.setIssueDate (date);}
Catch (Parse Exception e) {e.printStackTrace ();}
List<BookIssueDetails> list = hm.get (student);
For (BookIssueDetails b: list)
{ int value = b.getNoOfBookIssued();
newIssuedBook.setNoOfBookIssued (++value);
l.add (newIssuedBook);
if (value > 2)
System.out.println ("You already issued max(2) books");
Else
hm.put (student, l) ;}}
Private static void add Book ()
{ System.out.println ("Enter Book number, name and price");
Scanner c = new Scanner (System. in);
int book Number = c.nextInt();
String name = c.nextLine ();
Double price = c.nextDouble ();
Book Details book = new Book Details (book Number, name, price);
Books. Add (book); }}
Package com.lms;
Import java.util.Date;
Public class BookIssueDetails {
Private Int book Number;
Private String name;
Private Int totalBookAllowed = 2;
Private Int noOfBookIssued=0;
private Date issueDate;
private Date returnDate;
public BookIssueDetails(int bookNumber,String name,int n,Date issueDate)
{ this.bookNumber=bookNumber;
this.name=name;
this.noOfBookIssued=n;
this.issueDate=issueDate;
}
public BookIssueDetails() {}
public int getBookNumber()
{ return bookNumber; }
public void setBookNumer(int bookNumber)
{ this.book Number = bookNumber; }
public int getNoOfBookIssued()
{ return noOfBookIssued;}
public void setNoOfBookIssued(int noOfBookIssued)
{ this.noOfBookIssued = noOfBookIssued; }
public Date getIssueDate()
{ return issueDate; }
public void setIssueDate(Date issueDate)
{this.issueDate = issueDate; }
public Date getReturnDate()
{ return returnDate; }
public void setReturnDate(Date returnDate)
{ this.returnDate = returnDate; }
public String getName()
{ return name; }
public void setName(String name)
{ this.name = name; }
public int getTotalBookAllowed()
{return totalBookAllowed;}
public void setTotalBookAllowed(int totalBookAllowed)
{this.totalBookAllowed = totalBookAllowed;}}
package com.lms;
public class BookDetails {
private int bookNumber;
private String bookName;
private Double price;
private int count;
public BookDetails(int bookNumber,String name,Double price)
{ this.bookNumber=bookNumber;
this.bookName=name;
this.price=price;
}
public int getCount()
{ return count; }
public void setCount(int count)
{ this.count = count; }
public int getBookNumber()
{return bookNumber; }
public void setBookNumber(int bookNumber)
{this.bookNumber = bookNumber; }
public String getBookName()
{return bookName;}
public void setBookName(String bookName)
{this.bookName = bookName;}
public Double getPrice()
{return price;}
public void setPrice(Double price)
{this.price = price;}}
package com.lms;
public class StudentDetails
{ private int studentId;
private String studentName;
private String className;
public int getStudentId()
{ return studentId;}
public void setStudentId(int studentId)
{ this.studentId = studentId;}
public String getStudentName()
{return studentName;}
public void setStudentName(String studentName)
{ this.studentName =studentName;}
public String getClassName()
{return className;}
public void setClassName(String className)
{this.className = className;}}}
2 .ALGORITHM
Algorithm:
Step1 : start
Step2 : addIssueDetails
Print Library Management System
Print Press 1 to add Book
Print Press 2 to issue a book
Print Press 3 to return a book
Print Press 4 to print the book details
Print Press 5 to print complete issue detais
Print Press 6 to exit
Step3 : do
Step4 : switch choice
case 1: addBook
break
case 2:issueBook
break
case 3:returnBook
break
case 4:printBookDetails
break
case 5:printCompleteIssueDetails
break
case 6:default:
print Invalid input
break
step5 : while choice > 0 && choice < 6
step6 : for BookIssueDetailsb entry.getValue
step7 : printentry.getKeyb.getBookNumber
step8 : b.getNameb.getNoOfBookIssued
step9 : b.getIssueDate b.getReturnDate
step10 : for BookDetails b : books
step11 : printb.getBookNumberb.getBookName
step12 : b.getCountb.getPrice
step13 : print Enter studentId&bookId
step14 : forBookIssueDetailsd
step15 : ifb.getBookNumberbookId
step16 : DateissueDate = b.getIssueDate
step17 : DatetodayDate = new Date
step18 : long diff = todayDate.getTime () - issueDate.getTime ()
step19 : longdiffDays = diff / (24 * 60 * 60 * 1000)
step20 : ifdiffDays> 10
step21 : int fine = (int) (diffDays - 10)
fine = fine * 10;
step22 : println Total Fine “+ fine + “Rs””
step23 : private static void addIssueDetails ()
BookIssueDetails bd1 = new BookIssueDetails (1,"abc", 1, new Date ("04/04/2015"))
BookIssueDetails bd2 = new BookIssueDetails (2,"xyz", 1, new Date ())
BookIssueDetails bd3 = new BookIssueDetails (3,"mn", 1, new Date ())
BookIssueDetails bd4 = new BookIssueDetails (4,"u", 1, new Date ())
Array List<BookIssueDetails> list1 = new Array List<BookIssueDetails>()
Array List<BookIssueDetails> list2 = new Array List<BookIssueDetails>()
Array List<BookIssueDetails> list3 = new Array List<BookIssueDetails>()
Array List<BookIssueDetails> list4 = new Array List<BookIssueDetails>()
list1.add (bd1)
list2.add (bd2)
list3.add (bd3)
list4.add (bd4)
hm.put (100, list1)
hm.put (101, list2)
hm.put (103, list3)
hm.put (104, list4)
step24 : private static void issue Book ()
Print Enter Student Id, Booknumber, name and price
Scanner c = new Scanner (System. in)
IntstudentId = c.nextInt ()
Scanner c1 = new Scanner (System. in)
IntbookNumber = c1.nextInt ()
Scanner c2 = new Scanner (System.in)
String name = c2.nextLine ()
Scanner c3 = new Scanner (System. in)
String issue Date = c3.nextLine ()
BookIssueDetailsnewIssuedBook = new BookIssueDetails ()
newIssuedBook.setName (name)
newIssuedBook.setBookNumer (book Number);
Step26 : Book Details book = new Book Details (book Number, name, price)
Books. Add (book)
step27 : public class Student Details
PrivateintstudentId
Private String student Name
Private String class Name
PublicintgetStudentId ()
ReturnstudentId
step28 : public void setStudentId (intstudentId)
this.studentId = studentId
step29 : public String getStudentName ()
ReturnstudentName
step30 : public void setStudentName (String student Name)
this.studentName = studentName
step31 : public String getClassName ()
returclassName
step32 : public void setClassName (String className)
this.className = className
3. FLOWCHART
Boundary value Test cases for input data
Add books
02 Enter the Book name Book name Message should Book name Pass
display Book name
03 Enter the Book price Book price Message should Book price Pass
display Book price
Issue books
04 Enter the Issue Issue date Message should Issue date Pass
date display Issue date
. Book Details
03 Enter the Book Price Book Price Message should Book Price Pass
display Book Price
04 Enter the number of Book count Message should Book count Pass
books i.e count display Book count
04 Enter the Book Book Return date Message should Book Return date Pass
Return date display Book Return
date
.Student details