annotate Lib/IMPL/Test/Unit.pm @ 164:eb3e9861a761

SQL traits in progress
author wizard
date Mon, 28 Mar 2011 01:36:24 +0400
parents f8de52d3c112
children 4267a2ac3d46
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
1 package IMPL::Test::Unit;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
2 use strict;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
3 use warnings;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
4
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
5 use base qw(IMPL::Object);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
6 use IMPL::Class::Property;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
7
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
8 use Time::HiRes qw(gettimeofday tv_interval);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
9
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
10 use Error qw(:try);
83
74bae30eb25e (no commit message)
wizard
parents: 49
diff changeset
11 use Carp qw(carp);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
12 use IMPL::Test::Result;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
13 use IMPL::Test::FailException;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
14 use IMPL::Exception;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
15
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
16 BEGIN {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
17 public property Name => prop_all;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
18 public property Code => prop_all;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
19 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
20
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
21 sub CTOR {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
22 my ($this,$info) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
23
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
24 die new IMPL::InvalidArgumentException("TestInfo should be supplied as an argument") unless $info;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
25
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
26 $this->Name($info->Name || 'Annon');
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
27 $this->Code($info->Code)or die new IMPL::InvalidOperationException("Can't create test without entry point");
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
28 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
29
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
30 sub UnitName {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
31 my ($self) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
32 $self->toString;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
33 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
34
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
35 sub Cleanup {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
36 my ($this,$session) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
37
97
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents: 83
diff changeset
38 $session->{$_} = $this->$_() foreach map $_->DataList, $this->get_meta('IMPL::Test::Unit::SharedData',undef,1);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
39
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
40 1;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
41 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
42
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
43 sub StartUnit {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
44 my $class = shift;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
45
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
46 return {};
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
47 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
48
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
49 sub InitTest {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
50 my ($this,$session) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
51
97
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents: 83
diff changeset
52 $this->$_($session->{$_}) foreach map $_->DataList, $this->get_meta('IMPL::Test::Unit::SharedData',undef,1);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
53 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
54
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
55 sub FinishUnit {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
56 my ($class,$session) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
57
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
58 1;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
59 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
60
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
61 sub List {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
62 my $self = shift;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
63
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
64 return $self->get_meta('IMPL::Test::Unit::TestInfo',undef,1); # deep search with no criteria
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
65 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
66
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
67 sub Run {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
68 my ($this,$session) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
69
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
70 my $t = [gettimeofday];
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
71 return try {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
72 $this->InitTest($session);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
73 my $code = $this->Code;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
74
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
75
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
76 my $t0 = [gettimeofday];
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
77 my $elapsed;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
78
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
79 try {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
80 $this->$code();
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
81 $elapsed = tv_interval ( $t0 );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
82 } finally {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
83 # we need to call Cleanup anyway
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
84 $this->Cleanup($session);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
85 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
86
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
87 return new IMPL::Test::Result(
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
88 Name => $this->Name,
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
89 State => IMPL::Test::Result::SUCCESS,
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
90 TimeExclusive => $elapsed,
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
91 TimeInclusive => tv_interval ( $t )
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
92 );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
93 } catch IMPL::Test::FailException with {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
94 my $e = shift;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
95 return new IMPL::Test::Result(
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
96 Name => $this->Name,
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
97 State => IMPL::Test::Result::FAIL,
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
98 Exception => $e,
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
99 TimeInclusive => tv_interval ( $t )
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
100 );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
101 } otherwise {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
102 my $e = shift;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
103 return new IMPL::Test::Result(
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
104 Name => $this->Name,
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
105 State => IMPL::Test::Result::ERROR,
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
106 Exception => $e,
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
107 TimeInclusive => tv_interval ( $t )
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
108 );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
109 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
110 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
111
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
112 package IMPL::Test::Unit::TestInfo;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
113 use base qw(IMPL::Object::Meta);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
114 use IMPL::Class::Property;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
115
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
116 require IMPL::Exception;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
117
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
118 BEGIN {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
119 public property Name => prop_all;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
120 public property Code => prop_all;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
121 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
122
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
123 sub CTOR {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
124 my ($this,$name,$code) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
125
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
126 $this->Name($name);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
127 $this->Code($code) or die new IMPL::InvalidArgumentException("The Code is a required parameter");
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
128 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
129
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
130 package IMPL::Test::Unit::SharedData;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
131 use base qw(IMPL::Object::Meta);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
132 use IMPL::Class::Property;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
133
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
134 BEGIN {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
135 public property DataList => prop_all | prop_list;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
136 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
137
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
138 sub CTOR {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
139 my $this = shift;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
140
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
141 $this->DataList(\@_);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
142 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 14
diff changeset
143 1;