CPPSERV


Home Projects Jobs Clientele Contact

cppserv


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

[PATCH] Add test suit for HttpSession functions



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

---
 ChangeLog                       |    5 +++++
 Makefile.adon                   |    2 +-
 tests/Makefile.adon             |    1 +
 tests/sessionGetAccessedTime.pl |   24 ++++++++++++++++++++++++
 tests/sessionGetCreationTime.pl |   24 ++++++++++++++++++++++++
 tests/sessionGetMaxTime.pl      |   24 ++++++++++++++++++++++++
 tests/sessionGetNumberHits.pl   |   24 ++++++++++++++++++++++++
 tests/sessionGetSession.pl      |   26 ++++++++++++++++++++++++++
 tests/sessionGetSessionId.pl    |   24 ++++++++++++++++++++++++
 9 files changed, 153 insertions(+), 1 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b25c28c..bfcadeb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sergey Jukov <sergey@total-knowledge.com>            Tue, 26 Sep 2006 13:00:00 -0800
+- Add testing suit for HttpSession functions isNew(), getAttribute(),
+  setAttribute(), getId(), getCreationTime(), getLastAccessedTime(),
+  getMaxInactiveInterval().
+
 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..9bd2ab3 100644
--- a/Makefile.adon
+++ b/Makefile.adon
@@ -1,2 +1,2 @@
-ADON_SUBDIRS := csp-store hello attributes reset utils fileupload redirect cookies session headers sharedata params BooksODBC database index
+ADON_SUBDIRS := csp-store tests hello attributes reset utils fileupload redirect cookies session headers sharedata params BooksODBC database index
 EXTRA_DIST := README engine.xml
diff --git a/tests/Makefile.adon b/tests/Makefile.adon
new file mode 100644
index 0000000..ef28c62
--- /dev/null
+++ b/tests/Makefile.adon
@@ -0,0 +1 @@
+check_SCRIPTS:=sessionGetSession.pl sessionGetNumberHits.pl sessionGetSessionId.pl sessionGetCreationTime.pl sessionGetAccessedTime.pl sessionGetMaxTime.pl
diff --git a/tests/sessionGetAccessedTime.pl b/tests/sessionGetAccessedTime.pl
new file mode 100755
index 0000000..cafa28b
--- /dev/null
+++ b/tests/sessionGetAccessedTime.pl
@@ -0,0 +1,24 @@
+#!/usr/bin/perl
+
+# This script sessionGetAccessedTime.pl tests 
+# work of HttpSession function getLastAccessedTime().
+
+use LWP::UserAgent;
+$ua = LWP::UserAgent->new;
+my $host = $ENV{HOSTNAME};
+my $servletName = "SessionServlet";
+my $url = "http://localhost/~".$host."/csp/".$servletName;
+my $req = HTTP::Request->new(POST => $url);
+$req->content_type('application/x-www-form-urlencoded');
+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 "Work of HttpSession getLastAccessedTime() failed\n";
+	}
+} else {
+	die "Cannot get $url: ".$res->status_line."\n";
+}
diff --git a/tests/sessionGetCreationTime.pl b/tests/sessionGetCreationTime.pl
new file mode 100755
index 0000000..2583d9d
--- /dev/null
+++ b/tests/sessionGetCreationTime.pl
@@ -0,0 +1,24 @@
+#!/usr/bin/perl
+
+# This script sessionGetCreationTime.pl tests work of
+# HttpSession function getCreationTime().
+
+use LWP::UserAgent;
+$ua = LWP::UserAgent->new;
+my $host = $ENV{HOSTNAME};
+my $servletName = "SessionServlet";
+my $url = "http://localhost/~".$host."/csp/".$servletName;
+my $req = HTTP::Request->new(POST => $url);
+$req->content_type('application/x-www-form-urlencoded');
+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 "Work of HttpSession getCreationTime() failed\n";
+	}
+} else {
+	die "Cannot get $url: ".$res->status_line."\n";
+}
diff --git a/tests/sessionGetMaxTime.pl b/tests/sessionGetMaxTime.pl
new file mode 100755
index 0000000..f7b0add
--- /dev/null
+++ b/tests/sessionGetMaxTime.pl
@@ -0,0 +1,24 @@
+#!/usr/bin/perl
+
+# This script sessionGetMaxTime.pl tests work of
+# HttpSession function getMaxInactiveInterval().
+
+use LWP::UserAgent;
+$ua = LWP::UserAgent->new;
+my $host = $ENV{HOSTNAME};
+my $servletName = "SessionServlet";
+my $url = "http://localhost/~".$host."/csp/".$servletName;
+my $req = HTTP::Request->new(POST => $url);
+$req->content_type('application/x-www-form-urlencoded');
+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 "Work of HttpSession getMaxInactiveInterval() failed\n";
+	}
+} else {
+	die "Cannot get $url: ".$res->status_line."\n";
+}
diff --git a/tests/sessionGetNumberHits.pl b/tests/sessionGetNumberHits.pl
new file mode 100755
index 0000000..b1e67c1
--- /dev/null
+++ b/tests/sessionGetNumberHits.pl
@@ -0,0 +1,24 @@
+#!/usr/bin/perl
+
+# This script sessionGetNumberHits.pl tests work of
+# HttpSession getAttribute() and setAttribute() functions
+
+use LWP::UserAgent;
+$ua = LWP::UserAgent->new;
+my $host = $ENV{HOSTNAME};
+my $servletName = "SessionServlet";
+my $url = "http://localhost/~".$host."/csp/".$servletName;
+my $req = HTTP::Request->new(POST => $url);
+$req->content_type('application/x-www-form-urlencoded');
+my $res = $ua->request($req);
+if ($res->is_success) {
+	my $line = $res->content;
+	$line =~ s/\n+//g;
+	if($line =~ /You hit this page\s(\d+)\stimes/) {
+		print "Number of hits: ".$1."\n";
+	} else {
+		print "Work of HttpSession getAttribute()/setAttribute() failed\n";
+	}
+} else {
+	die "Cannot get $url: ".$res->status_line."\n";
+}
diff --git a/tests/sessionGetSession.pl b/tests/sessionGetSession.pl
new file mode 100755
index 0000000..08e94f9
--- /dev/null
+++ b/tests/sessionGetSession.pl
@@ -0,0 +1,26 @@
+#!/usr/bin/perl
+
+# This script sessionGetSession.pl tests work of
+# HttpSession function isNew(). 
+
+use LWP::UserAgent;
+$ua = LWP::UserAgent->new;
+my $host = $ENV{HOSTNAME};
+my $servletName = "SessionServlet";
+my $url = "http://localhost/~".$host."/csp/".$servletName;
+my $req = HTTP::Request->new(POST => $url);
+$req->content_type('application/x-www-form-urlencoded');
+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 "HttpSession isNew() failed\n";
+	}
+} else {
+	die "Cannot get $url: ".$res->status_line."\n";
+}
diff --git a/tests/sessionGetSessionId.pl b/tests/sessionGetSessionId.pl
new file mode 100755
index 0000000..a7f809c
--- /dev/null
+++ b/tests/sessionGetSessionId.pl
@@ -0,0 +1,24 @@
+#!/usr/bin/perl
+
+# This script sessionGetSessionId.pl tests work of
+# HttpSession function getId().
+
+use LWP::UserAgent;
+$ua = LWP::UserAgent->new;
+my $host = $ENV{HOSTNAME};
+my $servletName = "SessionServlet";
+my $url = "http://localhost/~".$host."/csp/".$servletName;
+my $req = HTTP::Request->new(POST => $url);
+$req->content_type('application/x-www-form-urlencoded');
+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 "Work of HttpSession getId() failed\n";
+	}
+} else {
+	die "Cannot get $url: ".$res->status_line."\n";
+}
-- 
1.4.2


Authoright © Total Knowledge: 2001-2008