CPPSERV


Home Projects Jobs Clientele Contact

cppserv


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Add test suits for servlets



From: Sergey Jukov <sergey@total-knowledge.com>

---
 ChangeLog                       |    3 +++
 Makefile.adon                   |    3 +++
 tests/sessionGetAccessedTime.pl |   28 ++++++++++++++++++++++++++++
 tests/sessionGetCreationTime.pl |   28 ++++++++++++++++++++++++++++
 tests/sessionGetMaxTime.pl      |   28 ++++++++++++++++++++++++++++
 tests/sessionGetNumberHits.pl   |   28 ++++++++++++++++++++++++++++
 tests/sessionGetSession.pl      |   30 ++++++++++++++++++++++++++++++
 tests/sessionGetSessionId.pl    |   28 ++++++++++++++++++++++++++++
 8 files changed, 176 insertions(+), 0 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b25c28c..b4e79ce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+Sergey Jukov <sergey@total-knowledge.com>            Mon, 25 Sep 2006 13:30:00 -0800
+- Add testing suits for servlets
+
 Sergey Jukov <sergey@total-knowledge.com>            Wed, 20 Sep 2006 14:40:00 -0800
 - Add testing getId(), getCreationTime(), getLastAccessedTime(),
   setMaxInactiveInterval(), getMaxInactiveInterval(), isNew() and
diff --git a/Makefile.adon b/Makefile.adon
index c6d485f..8365448 100644
--- a/Makefile.adon
+++ b/Makefile.adon
@@ -1,2 +1,5 @@
 ADON_SUBDIRS := csp-store hello attributes reset utils fileupload redirect cookies session headers sharedata params BooksODBC database index
 EXTRA_DIST := README engine.xml
+the_tests := tests/sessionGetSession.pl tests/sessionGetNumberHits.pl tests/sessionGetSessionId.pl tests/sessionGetCreationTime.pl tests/sessionGetAccessedTime.pl tests/sessionGetMaxTime.pl
+TESTS := $(the_tests)
+check_SCRIPTS:=$(TESTS)
\ No newline at end of file
diff --git a/tests/sessionGetAccessedTime.pl b/tests/sessionGetAccessedTime.pl
new file mode 100755
index 0000000..17c0dda
--- /dev/null
+++ b/tests/sessionGetAccessedTime.pl
@@ -0,0 +1,28 @@
+#!/usr/bin/perl
+
+use LWP::UserAgent;
+$ua = LWP::UserAgent->new;
+
+my $req = HTTP::Request->new(POST => 'http://localhost/~sergey/csp/SessionServlet');
+$req->content_type('application/x-www-form-urlencoded');
+$req->content('key=value');
+
+my $res = $ua->request($req);
+
+if ($res->is_success) {
+	my $line = $res->content;
+	$line =~ s/\n+//g;
+	if($line =~ /Last Accessed time:\s(.*)Maximum/) {
+		print "Last Accessed time: ".$1."\n";
+	}
+} else {
+	print $res->status_line, "\n";
+}
+
+
+
+
+
+
+
+
diff --git a/tests/sessionGetCreationTime.pl b/tests/sessionGetCreationTime.pl
new file mode 100755
index 0000000..006ea3e
--- /dev/null
+++ b/tests/sessionGetCreationTime.pl
@@ -0,0 +1,28 @@
+#!/usr/bin/perl
+
+use LWP::UserAgent;
+$ua = LWP::UserAgent->new;
+
+my $req = HTTP::Request->new(POST => 'http://localhost/~sergey/csp/SessionServlet');
+$req->content_type('application/x-www-form-urlencoded');
+$req->content('key=value');
+
+my $res = $ua->request($req);
+
+if ($res->is_success) {
+	my $line = $res->content;
+	$line =~ s/\n+//g;
+	if($line =~ /Creation time:\s(.*)Last/) {
+		print "Creation time: ".$1."\n";
+	}
+} else {
+	print $res->status_line, "\n";
+}
+
+
+
+
+
+
+
+
diff --git a/tests/sessionGetMaxTime.pl b/tests/sessionGetMaxTime.pl
new file mode 100755
index 0000000..88da4d1
--- /dev/null
+++ b/tests/sessionGetMaxTime.pl
@@ -0,0 +1,28 @@
+#!/usr/bin/perl
+
+use LWP::UserAgent;
+$ua = LWP::UserAgent->new;
+
+my $req = HTTP::Request->new(POST => 'http://localhost/~sergey/csp/SessionServlet');
+$req->content_type('application/x-www-form-urlencoded');
+$req->content('key=value');
+
+my $res = $ua->request($req);
+
+if ($res->is_success) {
+	my $line = $res->content;
+	$line =~ s/\n+//g;
+	if($line =~ /Maximum time interval:\s(.*)\sseconds/) {
+		print "Maximum time interval: ".$1." seconds\n";
+	}
+} else {
+	print $res->status_line, "\n";
+}
+
+
+
+
+
+
+
+
diff --git a/tests/sessionGetNumberHits.pl b/tests/sessionGetNumberHits.pl
new file mode 100755
index 0000000..6aabad9
--- /dev/null
+++ b/tests/sessionGetNumberHits.pl
@@ -0,0 +1,28 @@
+#!/usr/bin/perl
+
+use LWP::UserAgent;
+$ua = LWP::UserAgent->new;
+
+my $req = HTTP::Request->new(POST => 'http://localhost/~sergey/csp/SessionServlet');
+$req->content_type('application/x-www-form-urlencoded');
+$req->content('key=value');
+
+my $res = $ua->request($req);
+
+if ($res->is_success) {
+	my $line = $res->content;
+	$line =~ s/\n+//g;
+	if($line =~ /You hit this page\s(.*)\stimes/) {
+		print "Number of hits: ".$1."\n";
+	}
+} else {
+	print $res->status_line, "\n";
+}
+
+
+
+
+
+
+
+
diff --git a/tests/sessionGetSession.pl b/tests/sessionGetSession.pl
new file mode 100755
index 0000000..2c9863c
--- /dev/null
+++ b/tests/sessionGetSession.pl
@@ -0,0 +1,30 @@
+#!/usr/bin/perl
+
+use LWP::UserAgent;
+$ua = LWP::UserAgent->new;
+
+my $req = HTTP::Request->new(POST => 'http://localhost/~sergey/csp/SessionServlet');
+$req->content_type('application/x-www-form-urlencoded');
+$req->content('key=value');
+
+my $res = $ua->request($req);
+
+if ($res->is_success) {
+	my $line = $res->content;
+	$line =~ s/\n+//g;
+	if($line =~ /New\ssession/) {
+		print "Is new session: YES\n";
+	} elsif($line =~ /Old\ssession/) {
+		print "Is new session: NO\n";
+	}
+} else {
+	print $res->status_line, "\n";
+}
+
+
+
+
+
+
+
+
diff --git a/tests/sessionGetSessionId.pl b/tests/sessionGetSessionId.pl
new file mode 100755
index 0000000..0d6ab2e
--- /dev/null
+++ b/tests/sessionGetSessionId.pl
@@ -0,0 +1,28 @@
+#!/usr/bin/perl
+
+use LWP::UserAgent;
+$ua = LWP::UserAgent->new;
+
+my $req = HTTP::Request->new(POST => 'http://localhost/~sergey/csp/SessionServlet');
+$req->content_type('application/x-www-form-urlencoded');
+$req->content('key=value');
+
+my $res = $ua->request($req);
+
+if ($res->is_success) {
+	my $line = $res->content;
+	$line =~ s/\n+//g;
+	if($line =~ /SessionID:\s(.*)Creation/) {
+		print "SessionID: ".$1."\n";
+	}
+} else {
+	print $res->status_line, "\n";
+}
+
+
+
+
+
+
+
+
-- 
1.4.2


Authoright © Total Knowledge: 2001-2008