4 use Test::More tests => 38;
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' );
24 ok( !defined $osd->longname );
25 is( $osd->description, 'Use Example.com to search the Web.' );
26 is( $osd->tags, 'example web' );
27 is( $osd->contact, 'admin@example.com' );
35 my $description = q(<?xml version="1.0" encoding="UTF-8"?>
36 <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
37 <ShortName>Web Search</ShortName>
38 <Description>Use Example.com to search the Web.</Description>
39 <Tags>example web</Tags>
40 <Contact>admin@example.com</Contact>
41 <Url type="application/rss+xml"
42 template="http://example.com/?q={searchTerms}&pw={startPage}&format=rss"/>
43 <Url type="application/atom+xml"
44 template="http://example.com/?q={searchTerms}&pw={startPage?}&format=atom"/>
47 template="https://intranet/search?format=html">
48 <Param name="s" value="{searchTerms}"/>
49 <Param name="o" value="{startIndex?}"/>
50 <Param name="c" value="{itemsPerPage?}"/>
51 <Param name="l" value="{language?}"/>
53 <LongName>Example.com Web Search</LongName>
54 <Image height="64" width="64" type="image/png">http://example.com/websearch.png</Image>
55 <Image height="16" width="16" type="image/vnd.microsoft.icon">http://example.com/websearch.ico</Image>
56 <Query role="example" searchTerms="cat" />
57 <Developer>Example.com Development Team</Developer>
59 Search data &copy; 2005, Example.com, Inc., All Rights Reserved
61 <SyndicationRight>open</SyndicationRight>
62 <AdultContent>false</AdultContent>
63 <Language>en-us</Language>
64 <OutputEncoding>UTF-8</OutputEncoding>
65 <InputEncoding>UTF-8</InputEncoding>
66 </OpenSearchDescription>
69 my $osd = WWW::OpenSearch::Description->new( $description );
70 isa_ok( $osd, 'WWW::OpenSearch::Description' );
71 is( $osd->shortname, 'Web Search' );
72 is( $osd->longname, 'Example.com Web Search' );
73 is( $osd->description, 'Use Example.com to search the Web.' );
74 is( $osd->tags, 'example web' );
75 is( $osd->contact, 'admin@example.com' );
76 is( $osd->developer, 'Example.com Development Team' );
77 is( $osd->attribution, '
78 Search data © 2005, Example.com, Inc., All Rights Reserved
80 is( $osd->inputencoding, 'UTF-8' );
81 is( $osd->outputencoding, 'UTF-8' );
82 is( $osd->language, 'en-us' );
83 is( $osd->adultcontent, 'false' );
84 is( $osd->syndicationright, 'open' );
86 is( $osd->image, 'http://example.com/websearch.png' );
90 is( $osd->query, undef );
99 my $description = q(<?xml version="1.0" encoding="UTF-8"?>
100 <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearchdescription/1.0/">
101 <Url>http://www.unto.net/aws?q={searchTerms}&searchindex=Electronics
102 &flavor=osrss&itempage={startPage}</Url>
103 <Format>http://a9.com/-/spec/opensearchrss/1.0/</Format>
104 <ShortName>Electronics</ShortName>
105 <LongName>Amazon Electronics</LongName>
106 <Description>Search for electronics on Amazon.com.</Description>
107 <Tags>amazon electronics</Tags>
108 <Image>http://www.unto.net/search/amazon_electronics.gif</Image>
109 <SampleSearch>ipod</SampleSearch>
110 <Developer>DeWitt Clinton</Developer>
111 <Contact>dewitt@unto.net</Contact>
112 <Attribution>Product and search data &copy; 2005, Amazon, Inc.,
113 All Rights Reserved</Attribution>
114 <SyndicationRight>open</SyndicationRight>
115 <AdultContent>false</AdultContent>
116 </OpenSearchDescription>
119 my $osd = WWW::OpenSearch::Description->new( $description );
120 isa_ok( $osd, 'WWW::OpenSearch::Description' );
121 is( $osd->shortname, 'Electronics' );
122 is( $osd->longname, 'Amazon Electronics' );
123 is( $osd->description, 'Search for electronics on Amazon.com.' );
124 is( $osd->tags, 'amazon electronics' );
125 is( $osd->contact, 'dewitt@unto.net' );
126 is( $osd->format, 'http://a9.com/-/spec/opensearchrss/1.0/' );
127 is( $osd->image, 'http://www.unto.net/search/amazon_electronics.gif' );
128 is( $osd->samplesearch, 'ipod' );
129 is( $osd->developer, 'DeWitt Clinton' );
130 is( $osd->attribution, 'Product and search data © 2005, Amazon, Inc.,
131 All Rights Reserved' );
132 is( $osd->syndicationright, 'open' );
133 is( $osd->adultcontent, 'false' );