comparison _test/Test/DOM/Builder.pm @ 34:a8086f85a571

Dom Builder
author Sergey
date Mon, 16 Nov 2009 18:39:25 +0300
parents
children f25d021780b3
comparison
equal deleted inserted replaced
33:0004faa276dc 34:a8086f85a571
1 package Test::DOM::Builder;
2 use strict;
3 use warnings;
4
5 use base qw(IMPL::Test::Unit);
6 __PACKAGE__->PassThroughArgs;
7
8 use IMPL::Class::Property;
9 use IMPL::Test qw(test failed shared);
10
11 require IMPL::DOM::Schema;
12 require IMPL::DOM::Navigator::Builder;
13 require IMPL::DOM::Document;
14
15 BEGIN {
16 public property schemaDoc => prop_all;
17 }
18
19 sub CTOR {
20 my ($this) = @_;
21
22 my $schema = new IMPL::DOM::Schema;
23 $schema->appendRange(
24 IMPL::DOM::Schema::ComplexNode->new( name => 'personInfo' )->appendRange(
25 IMPL::DOM::Schema::NodeSet->new()->appendRange(
26 new IMPL::DOM::Schema::SimpleNode( name => 'firstName' ),
27 new IMPL::DOM::Schema::SimpleNode( name => 'lastName' ),
28 new IMPL::DOM::Schema::ComplexNode( name => 'address' )->appendRange(
29 IMPL::DOM::Schema::NodeSet->new()->appendRange(
30 new IMPL::DOM::Schema::SimpleNode( name => 'street' ),
31 new IMPL::DOM::Schema::SimpleNode( name => 'line', minOccur => 0 )
32 )
33 )
34 )
35 )
36 );
37
38 $this->schemaDoc( $schema );
39 }
40
41 test CreateBuilder => sub {
42 my ($this) = @_;
43
44 my $builder = IMPL::DOM::Navigator::Builder->new(
45 new IMPL::DOM::Document(nodeName => 'personInfo'),
46 $this->schemaDoc
47 );
48 };
49
50 test BuildDocument => sub {
51 my ($this) = @_;
52
53 my $builder = IMPL::DOM::Navigator::Builder->new(
54 'IMPL::DOM::Document',
55 $this->schemaDoc
56 );
57
58 $builder->NavigateCreate('personInfo', version => '1');
59 $builder->NavigateCreate('firstName')->nodeValue('Nemo');
60 $builder->Back();
61 $builder->NavigateCreate('address', local => 1);
62 $builder->NavigateCreate('street')->nodeValue('Hellroad');
63 $builder->Back();
64 $builder->Back();
65 $builder->Back();
66
67 return 1;
68 };
69
70
71 1;