annotate _test/Test/DOM/Schema.pm @ 354:9330835535b9

fixed view double rendering
author cin
date Wed, 16 Oct 2013 17:28:40 +0400
parents 5c82eec23bb6
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: 28
diff changeset
1 package Test::DOM::Schema;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
2 use strict;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
3 use warnings;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
4
166
4267a2ac3d46 Added Class::Template,
wizard
parents: 101
diff changeset
5 use parent qw(IMPL::Test::Unit);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
6 use IMPL::Test qw(test failed shared);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
7 use IMPL::Class::Property;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
8
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
9 __PACKAGE__->PassThroughArgs;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
10
101
d8dc6cad3f55 Schema in progress
wizard
parents: 49
diff changeset
11 use IMPL::DOM::Schema;
d8dc6cad3f55 Schema in progress
wizard
parents: 49
diff changeset
12 use IMPL::DOM::Navigator::Builder;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
13
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
14 BEGIN {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
15 shared public property SampleSchema => prop_all;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
16 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
17
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
18 test GetMetaSchema => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
19 my $metaSchema = IMPL::DOM::Schema->MetaSchema();
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
20 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
21
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
22 test AutoverifyMetaSchema => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
23 my $metaSchema = IMPL::DOM::Schema->MetaSchema();
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
24
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
25 if (my @errors = $metaSchema->Validate($metaSchema)) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
26 failed "Self verification failed", map $_ ? $_->Message : 'unknown', @errors;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
27 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
28 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
29
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
30 test VerifyCorrectSchema => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
31 my ($this) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
32 my $metaSchema = IMPL::DOM::Schema->MetaSchema();
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
33
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
34 my $schema = new IMPL::DOM::Schema;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
35 $schema->appendRange(
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
36 IMPL::DOM::Schema::ComplexNode->new( name => 'personInfo' )->appendRange(
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
37 IMPL::DOM::Schema::NodeSet->new()->appendRange(
232
5c82eec23bb6 Fixed degradations due refactoring
sergey
parents: 194
diff changeset
38 IMPL::DOM::Schema::SimpleNode->new( name => 'firstName' ),
5c82eec23bb6 Fixed degradations due refactoring
sergey
parents: 194
diff changeset
39 IMPL::DOM::Schema::SimpleNode->new( name => 'lastName' ),
5c82eec23bb6 Fixed degradations due refactoring
sergey
parents: 194
diff changeset
40 IMPL::DOM::Schema::ComplexNode->new( name => 'address' )->appendRange(
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
41 IMPL::DOM::Schema::NodeSet->new()->appendRange(
232
5c82eec23bb6 Fixed degradations due refactoring
sergey
parents: 194
diff changeset
42 IMPL::DOM::Schema::SimpleNode->new( name => 'street' ),
5c82eec23bb6 Fixed degradations due refactoring
sergey
parents: 194
diff changeset
43 IMPL::DOM::Schema::SimpleNode->new( name => 'line', minOccur => 0 )
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
44 )
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
45 )
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
46 )
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
47 )
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
48 );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
50 $this->SampleSchema($schema);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
51
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
52 my @errors = $metaSchema->Validate($schema);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
53 failed "Failed to validate a wellformed schema", map $_->Message, @errors if @errors;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
54 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
55
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
56 test VerifyWrongSchema => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
57 my $metaSchema = IMPL::DOM::Schema->MetaSchema();
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
58
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
59 my $schema = new IMPL::DOM::Schema;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
60 $schema->appendRange(
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
61 IMPL::DOM::Schema::ComplexNode->new( name => 'personInfo' )->appendRange(
232
5c82eec23bb6 Fixed degradations due refactoring
sergey
parents: 194
diff changeset
62 IMPL::DOM::Schema::ComplexType->new( type => 'someType' ),
5c82eec23bb6 Fixed degradations due refactoring
sergey
parents: 194
diff changeset
63 IMPL::DOM::Schema::SimpleNode->new( name => 'lastName' ),
5c82eec23bb6 Fixed degradations due refactoring
sergey
parents: 194
diff changeset
64 IMPL::DOM::Schema::ComplexNode->new( name => 'address' )->appendRange(
5c82eec23bb6 Fixed degradations due refactoring
sergey
parents: 194
diff changeset
65 IMPL::DOM::Schema::SimpleNode->new( name => 'street' ),
5c82eec23bb6 Fixed degradations due refactoring
sergey
parents: 194
diff changeset
66 IMPL::DOM::Schema::SimpleNode->new( name => 'line' )
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
67 )
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
68 )
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
69 );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
70
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
71 my @errors = $metaSchema->Validate($schema);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
72 failed "A not wellformed schema validated correctly" unless @errors;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
73 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
74
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
75 test ValidateCorrectData => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
76 my ($this) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
77
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
78 my $data = IMPL::DOM::Node->new(nodeName => 'personInfo')->appendRange(
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
79 IMPL::DOM::Node->new(nodeName => 'firstName', nodeValue => 'John'),
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
80 IMPL::DOM::Node->new(nodeName => 'lastName', nodeValue => 'Smith'),
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
81 IMPL::DOM::Node->new(nodeName => 'address')->appendRange(
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
82 IMPL::DOM::Node->new(nodeName => 'street', nodeValue => 'main road')
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
83 )
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
84 );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
85
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
86 if (my @errors = $this->SampleSchema->Validate($data)) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
87 failed "Failed to validate a correct data", map $_->Message , @errors;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
88 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
89 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
90
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
91 test ValidateWrongData => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
92 my ($this) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
93
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
94 my $data = IMPL::DOM::Node->new(nodeName => 'personInfo')->appendRange(
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
95 IMPL::DOM::Node->new(nodeName => 'firstName', nodeValue => 'John'),
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
96 IMPL::DOM::Node->new(nodeName => 'address')->appendRange(
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
97 IMPL::DOM::Node->new(nodeName => 'street', nodeValue => 'main road')
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
98 )
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
99 );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
100
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
101 failed "A wrong data validated corretly" unless $this->SampleSchema->Validate($data);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
102 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
103
101
d8dc6cad3f55 Schema in progress
wizard
parents: 49
diff changeset
104 test LoadXmlSchemaTypes => sub {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 166
diff changeset
105 my ($this) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 166
diff changeset
106
4d0e1962161c Replaced tabs with spaces
cin
parents: 166
diff changeset
107 my $schema = IMPL::DOM::Schema->LoadSchema("Resources/types.xml") or failed "Failed to parse schema";
4d0e1962161c Replaced tabs with spaces
cin
parents: 166
diff changeset
108
4d0e1962161c Replaced tabs with spaces
cin
parents: 166
diff changeset
109 return 1;
101
d8dc6cad3f55 Schema in progress
wizard
parents: 49
diff changeset
110 };
d8dc6cad3f55 Schema in progress
wizard
parents: 49
diff changeset
111
d8dc6cad3f55 Schema in progress
wizard
parents: 49
diff changeset
112 test LoadXmlSchemaData => sub {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 166
diff changeset
113 my ($this) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 166
diff changeset
114
4d0e1962161c Replaced tabs with spaces
cin
parents: 166
diff changeset
115 my $schema = IMPL::DOM::Schema->LoadSchema("Resources/form.xml") or failed "Failed to parse schema";
4d0e1962161c Replaced tabs with spaces
cin
parents: 166
diff changeset
116
4d0e1962161c Replaced tabs with spaces
cin
parents: 166
diff changeset
117 return 1;
101
d8dc6cad3f55 Schema in progress
wizard
parents: 49
diff changeset
118 };
d8dc6cad3f55 Schema in progress
wizard
parents: 49
diff changeset
119
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
120
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 28
diff changeset
121 1;