4 use Test::More tests => 48;
6 use_ok( 'WWW::OpenSearch::Description' );
10 my $description = q(<?xml version="1.0" encoding="UTF-8"?>
11 <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
12 <ShortName>Web Search</ShortName>
13 <Description>Use Example.com to search the Web.</Description>
14 <Tags>example web</Tags>
15 <Contact>admin@example.com</Contact>
16 <Url type="application/rss+xml"
17 template="http://example.com/?q={searchTerms}&pw={startPage?}&format=rss"/>
18 </OpenSearchDescription>
21 my $osd = WWW::OpenSearch::Description->new( $description );
22 isa_ok( $osd, 'WWW::OpenSearch::Description' );
23 is( $osd->shortname, 'Web Search', 'shortname' );
24 ok( !defined $osd->longname, 'longname' );
25 is( $osd->description, 'Use Example.com to search the Web.',
27 is( $osd->tags, 'example web', 'tags' );
28 is( $osd->contact, 'admin@example.com', 'contact' );
31 is( $osd->urls, 1, 'number of url objects' );
36 my $description = q(<?xml version="1.0" encoding="UTF-8"?>
37 <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
38 <ShortName>Web Search</ShortName>
39 <Description>Use Example.com to search the Web.</Description>
40 <Tags>example web</Tags>
41 <Contact>admin@example.com</Contact>
42 <Url type="application/rss+xml"
43 template="http://example.com/?q={searchTerms}&pw={startPage}&format=rss"/>
44 <Url type="application/atom+xml"
45 template="http://example.com/?q={searchTerms}&pw={startPage?}&format=atom"/>
48 template="https://intranet/search?format=html">
49 <Param name="s" value="{searchTerms}"/>
50 <Param name="o" value="{startIndex?}"/>
51 <Param name="c" value="{itemsPerPage?}"/>
52 <Param name="l" value="{language?}"/>
54 <LongName>Example.com Web Search</LongName>
55 <Image height="64" width="64" type="image/png">http://example.com/websearch.png</Image>
56 <Image height="16" width="16" type="image/vnd.microsoft.icon">http://example.com/websearch.ico</Image>
57 <Query role="example" searchTerms="cat" />
58 <Developer>Example.com Development Team</Developer>
60 Search data &copy; 2005, Example.com, Inc., All Rights Reserved
62 <SyndicationRight>open</SyndicationRight>
63 <AdultContent>false</AdultContent>
64 <Language>en-us</Language>
65 <OutputEncoding>UTF-8</OutputEncoding>
66 <InputEncoding>UTF-8</InputEncoding>
67 </OpenSearchDescription>
70 my $osd = WWW::OpenSearch::Description->new( $description );
71 isa_ok( $osd, 'WWW::OpenSearch::Description' );
72 is( $osd->shortname, 'Web Search', 'shortname' );
73 is( $osd->longname, 'Example.com Web Search', 'longname' );
74 is( $osd->description, 'Use Example.com to search the Web.',
76 is( $osd->tags, 'example web', 'tags' );
77 is( $osd->contact, 'admin@example.com', 'contact' );
78 is( $osd->developer, 'Example.com Development Team', 'developer' );
79 is( $osd->attribution, '
80 Search data © 2005, Example.com, Inc., All Rights Reserved
83 is( $osd->inputencoding, 'UTF-8', 'inputencoding' );
84 is( $osd->outputencoding, 'UTF-8', 'outputencoding' );
85 is( $osd->language, 'en-us', 'language' );
86 is( $osd->adultcontent, 'false', 'adultcontent' );
87 is( $osd->syndicationright, 'open', 'syndicationright' );
89 my $queries = $osd->query;
90 is( scalar @$queries, 1, 'number of query objects' );
91 is( $queries->[ 0 ]->role, 'example', 'role' );
92 is( $queries->[ 0 ]->searchTerms, 'cat', 'searchTerms' );
94 my $images = $osd->image;
95 is( scalar @$images, 2, 'number of image objects' );
96 is( $images->[ 0 ]->height, 64, 'height' );
97 is( $images->[ 0 ]->width, 64, 'width' );
98 is( $images->[ 0 ]->type, 'image/png', 'content type' );
99 is( $images->[ 0 ]->url, 'http://example.com/websearch.png', 'url' );
100 is( $images->[ 1 ]->height, 16, 'height' );
101 is( $images->[ 1 ]->width, 16, 'width' );
102 is( $images->[ 1 ]->type, 'image/vnd.microsoft.icon', 'content type' );
103 is( $images->[ 1 ]->url, 'http://example.com/websearch.ico', 'url' );
106 is( $osd->urls, 3, 'number of url objects' );
111 my $description = q(<?xml version="1.0" encoding="UTF-8"?>
112 <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearchdescription/1.0/">
113 <Url>http://www.unto.net/aws?q={searchTerms}&searchindex=Electronics
114 &flavor=osrss&itempage={startPage}</Url>
115 <Format>http://a9.com/-/spec/opensearchrss/1.0/</Format>
116 <ShortName>Electronics</ShortName>
117 <LongName>Amazon Electronics</LongName>
118 <Description>Search for electronics on Amazon.com.</Description>
119 <Tags>amazon electronics</Tags>
120 <Image>http://www.unto.net/search/amazon_electronics.gif</Image>
121 <SampleSearch>ipod</SampleSearch>
122 <Developer>DeWitt Clinton</Developer>
123 <Contact>dewitt@unto.net</Contact>
124 <Attribution>Product and search data &copy; 2005, Amazon, Inc.,
125 All Rights Reserved</Attribution>
126 <SyndicationRight>open</SyndicationRight>
127 <AdultContent>false</AdultContent>
128 </OpenSearchDescription>
131 my $osd = WWW::OpenSearch::Description->new( $description );
132 isa_ok( $osd, 'WWW::OpenSearch::Description' );
133 is( $osd->shortname, 'Electronics', 'shortname' );
134 is( $osd->longname, 'Amazon Electronics', 'longname' );
135 is( $osd->description, 'Search for electronics on Amazon.com.',
137 is( $osd->tags, 'amazon electronics', 'tags' );
138 is( $osd->contact, 'dewitt@unto.net', 'contact' );
139 is( $osd->format, 'http://a9.com/-/spec/opensearchrss/1.0/', 'format' );
140 is( $osd->image, 'http://www.unto.net/search/amazon_electronics.gif',
142 is( $osd->samplesearch, 'ipod', 'samplesearch' );
143 is( $osd->developer, 'DeWitt Clinton', 'developer' );
144 is( $osd->attribution, 'Product and search data © 2005, Amazon, Inc.,
145 All Rights Reserved', 'attribution'
147 is( $osd->syndicationright, 'open', 'syndicationright' );
148 is( $osd->adultcontent, 'false', 'adultcontent' );
151 is( $osd->urls, 1, 'urls' );