annotate _test/Test/DOM/Node.pm @ 411:ee36115f6a34 ref20150831

sync
author cin
date Mon, 21 Sep 2015 00:53:10 +0300
parents 99ac2e19c0cc
children
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: 37
diff changeset
1 package Test::DOM::Node;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
2 use strict;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
3 use warnings;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
4
166
4267a2ac3d46 Added Class::Template,
wizard
parents: 148
diff changeset
5 use parent qw(IMPL::Test::Unit);
188
029c9610528c Memory leak tests in IMPL::Web::View
cin
parents: 166
diff changeset
6 use IMPL::Test qw(test shared failed cmparray assert);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
7 use IMPL::Class::Property;
188
029c9610528c Memory leak tests in IMPL::Web::View
cin
parents: 166
diff changeset
8 use Scalar::Util qw(weaken);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
9
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
10 require IMPL::DOM::Node;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
11
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
12 __PACKAGE__->PassThroughArgs;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
13
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
14 BEGIN {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
15 shared public property Root => prop_all;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
16 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
17
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
18 test Create => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
19 my ($this) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
20
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
21 $this->Root(new IMPL::DOM::Document(nodeName => 'Root')) or failed "Failed to create a document";
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
22 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
23
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
24 test InsertNode => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
25 my ($this) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
26 my $child = $this->Root->insertNode(new IMPL::DOM::Node(nodeName => 'Child')) or failed "Failed to insert a child node";
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
27 failed "fiestChild returned incorrect results" unless ($this->Root->firstChild || 0) == $child;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
28 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
29
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
30 test AppendNode => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
31 my ($this) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
32
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
33 my $child = $this->Root->appendNode(new IMPL::DOM::Node(nodeName => 'Child')) or failed "Failed to append a child node";
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
34
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
35 my $lastChild = $this->Root->removeLast;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
36
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
37 failed "removeLast returned incorrect results" unless $lastChild == $child;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
38 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
39
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
40 test GetDocumentNode => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
41 my ($this) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
42
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
43 my $child = $this->Root->firstChild->appendNode(new IMPL::DOM::Node(nodeName => 'GrandChild')) or failed "Failed to append a child node";
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
44
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
45 failed "document property is undef" unless $child->document;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
46 failed "document property returned incorrect value" unless $child->document == $this->Root;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
47 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
48
148
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
49 test DocumentCreateNode => sub {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
50 my ($this) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
51
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
52 my $child = $this->Root->firstChild->appendNode($this->Root->Create(Info => { uuid => '77f9-9a-6d58' } )) or failed "Failed to append a child node";
148
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
53
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
54 failed "document property is undef" unless $child->document;
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
55 failed "document property returned incorrect value" unless $child->document == $this->Root;
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
56 };
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
57
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
58 test MoveNode => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
59 my ($this) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
60
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
61 my $grandChild = $this->Root->firstChild->firstChild;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
62 $this->Root->appendNode($grandChild);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
63
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
64 failed "incorrect new parentNode value" unless ($grandChild->parentNode || 0) == $this->Root;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
65 failed "incorrect new document value" unless ($grandChild->document || 0) == $this->Root;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
66 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
67
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
68 test AppendRange => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
69 my ($this) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
70
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
71 my $count = $this->Root->childNodes->Count;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
72
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
73 $this->Root->appendRange(
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
74 map IMPL::DOM::Node->new(nodeName => "Item", nodeValue => $_),1..10
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
75 );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
76
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
77 failed
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
78 "Wrong number of a child nodes",
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
79 "Expected: ".($count+10),
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
80 "Actual: ".$this->Root->childNodes->Count
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
81 unless $count + 10 == $this->Root->childNodes->Count;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
82 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
83
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
84 test SelectNodes => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
85 my ($this) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
86
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
87 my @result = $this->Root->selectNodes("Item");
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
88
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
89 failed
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
90 "Wrong number of a selected nodes",
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
91 "Expected: 10",
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
92 "Actual: ".scalar(@result)
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
93 unless @result == 10;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
94 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
95
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
96 test SelectNodesByQuery => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
97 my ($this) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
98
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
99 my @result = $this->Root->selectNodes(sub { $_->nodeName =~ /child/i } );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
100 failed
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
101 "Wrong number of a selected nodes",
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
102 "Expected: 2",
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
103 "Actual: ".scalar(@result)
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
104 unless @result == 2;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
105 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
106
148
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
107 test SelectNodesPath => sub {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
108 my ($this) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
109
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
110 my @result = $this->Root->selectNodes('Child','Info');
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
111
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
112 failed "Failed to select a node by path 'Child/Info'" unless @result;
148
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
113 };
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
114
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
115 test SelectByAxisDescendant => sub {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
116 my ($this) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
117
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
118 my @result = $this->Root->selectNodes( { descendant => ['GrandChild','Info']} );
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
119
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
120 failed "Failed to select a node by path '//(GrandChild|Info)/'" unless @result == 2;
148
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
121 };
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
122
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
123 test SelectByAxisAncestor => sub {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
124 my ($this) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
125
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
126 my @result = $this->Root->selectSingleNode( { descendant => 'Info'} )->selectNodes( { ancestor => undef } ) ;
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
127
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
128 failed "Failed to select a node by path '//Info/ancestor:*'" unless @result == 2;
148
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
129 };
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
130
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
131 test CheckNodesValues => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
132 my ($this) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
133
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
134 my @expected = (1..10);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
135
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
136 my @result = map $_->nodeValue, grep $_->nodeValue, $this->Root->selectNodes("Item");
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
137
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
138 failed
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
139 "Some nodes returned wrong node values or in a wrong order",
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
140 "Expected: ".join(', ',@expected),
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
141 "Recieved: ".join(', ',@result)
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
142 unless cmparray(\@expected,\@result);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
143
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
144 failed
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
145 "a text property of a root node returned a wrong value",
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
146 "Expected: @expected",
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
147 "Recieved: ". $this->Root->text
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
148 unless $this->Root->text eq join '',@expected;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
149 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
150
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
151 test isComplex => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
152 my ($this) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
153
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
154 failed "property isComplex returned false for the root node" unless $this->Root->isComplex;
148
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
155 failed "property isComplex returned true for a simple node", $this->Root->selectSingleNode('Item')->childNodes->Count if $this->Root->selectSingleNode('Item')->isComplex;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
156 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
157
123
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
158 test setObjectProperty => sub {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
159 my ($this) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
160
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
161 my $node = Test::DOM::TypedNode->new(nodeName => 'TestNode');
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
162
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
163 my $name = 'Vergon 6';
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
164
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
165 $node->nodeProperty(name => $name);
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
166 failed "Failed to set a property 'name'", "Expected: $name", "Got: ".$node->name unless $node->name eq $name;
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
167
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
168 $name = 'entity_vergon_6';
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
169 $node->systemName($name);
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
170 failed "Failed to set a property 'systemName'", "Expected: $name", "Got: ".$node->nodeProperty('systemName') unless $node->nodeProperty('systemName') eq $name;
123
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
171 };
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
172
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
173 test setDynamicProperty => sub {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
174 my $node = Test::DOM::TypedNode->new(nodeName => 'TestNode');
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
175
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
176 my $uuid = 'entity_76fd98b9e7a';
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
177 $node->nodeProperty(uuid => $uuid);
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
178 failed "Failed to set a dynamic property 'uuid'", "Expected: $uuid", "Got: ".$node->nodeProperty('uuid') unless $node->nodeProperty('uuid') eq $uuid;
123
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
179 };
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
180
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
181 test setPrivateProperty => sub {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
182 my $node = Test::DOM::TypedNode->new(nodeName => 'TestNode');
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
183
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
184 eval {
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
185 $node->nodeProperty(_private => 'failed');
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
186 1;
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
187 } and failed "Setting a private property successfull";
123
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
188 };
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
189
124
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
190 test createNodeWithProps => sub {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
191 my $uuid = 'entity_76fd98b9e7a';
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
192 my $name = 'Vergon 6';
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
193 my $systemName = 'entity_vergon_6';
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
195 my $node = Test::DOM::TypedNode->new(
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
196 nodeName => 'TestNode',
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
197 uuid => $uuid,
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
198 name => $name,
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
199 systemName => $systemName
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
200 );
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
201
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
202 failed "Failed to get dynamic property 'uuid'" unless $node->nodeProperty('uuid') eq $uuid;
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
203 failed "Failed to get property 'name' through nodeProperty method" unless $node->nodeProperty('name') eq $name;
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
204 failed "Failed to get property name directly" unless $node->name eq $name;
124
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
205 };
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
206
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
207 test listNodePredefinedProps => sub {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
208 my $node = Test::DOM::TypedNode->new(nodeName => 'TestNode');
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
209
382
99ac2e19c0cc Implemented a strings map for a DOM schema
sergey
parents: 194
diff changeset
210 # the order of properties is not defined
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
211 my @props = $node->listProperties;
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
212 my @expected = qw(name _private);
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
213
382
99ac2e19c0cc Implemented a strings map for a DOM schema
sergey
parents: 194
diff changeset
214 failed "Got wrong list of props", @props unless cmparray([sort @props],[sort @expected]);
124
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
215 };
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
216
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
217 test listNodeAllProps => sub {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
218 my $node = Test::DOM::TypedNode->new(
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
219 nodeName => 'TestNode',
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
220 uuid => 'ade58f98b', # dynamic
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
221 name => 'noname', # predefined
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
222 systemName => 'no sys' # not visible to DOM
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
223 );
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
224
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
225 my @props = $node->listProperties;
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
226 my @expected = qw(name _private uuid); # systemName is not a DOM prop
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
227
382
99ac2e19c0cc Implemented a strings map for a DOM schema
sergey
parents: 194
diff changeset
228 failed "Got wrong list of props", @props unless cmparray([sort @props],[sort @expected]);
124
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
229 };
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 123
diff changeset
230
188
029c9610528c Memory leak tests in IMPL::Web::View
cin
parents: 166
diff changeset
231 test MemoryLeaks => sub {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
232 my $doc = new IMPL::DOM::Document(nodeName => 'Root');
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
233 weaken($doc);
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
234
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
235 assert(not defined $doc);
188
029c9610528c Memory leak tests in IMPL::Web::View
cin
parents: 166
diff changeset
236 };
029c9610528c Memory leak tests in IMPL::Web::View
cin
parents: 166
diff changeset
237
122
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 49
diff changeset
238 package Test::DOM::TypedNode;
166
4267a2ac3d46 Added Class::Template,
wizard
parents: 148
diff changeset
239 use parent qw(IMPL::DOM::Node);
122
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 49
diff changeset
240 use IMPL::Class::Property;
123
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
241 use IMPL::DOM::Property qw(_dom);
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
242
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
243 __PACKAGE__->PassThroughArgs;
122
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 49
diff changeset
244
123
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
245 BEGIN {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
246 public _dom property name => prop_all;
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
247 public property systemName => prop_all;
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
248 private _dom property _private => prop_all;
123
1d7e370a91fa Additional DOM::Node tests
wizard
parents: 122
diff changeset
249 }
122
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 49
diff changeset
250
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 49
diff changeset
251
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
252 1;