+Wed Aug 20 10:42:00 PST 2008 (jshirley) - Release 0.65
+ Fully revamped tests to work without any JSON support
+ Final removal of JSON::Syck
+ Special thanks to jgoulah for helping test this release
+
Wed Aug 13 08:55:00 PST 2008 (jshirley) - Release 0.64
New dist to fix issue with Module::Install
feature 'JSON (application/json) support',
-default => 0,
- 'JSON' => undef;
- 'JSON::XS' => undef;
+ 'JSON' => '2.12';
+ 'JSON::XS' => '2.2222';
feature 'Data::Denter (text/x-data-denter) support',
-default => 0,
BEGIN { require 5.008001; }
-our $VERSION = '0.64';
+our $VERSION = '0.65';
# This is wrong in several ways. First, there's no guarantee that
# Catalyst.pm has not been subclassed. Two, there's no guarantee that
L<Catalyst::Action::Serialize>, L<Catalyst::Action::Deserialize>
-=head1 AUTHOR
+=head1 MAINTAINER
-Adam Jacob <adam@stalecoffee.org>, with lots of help from mst and jrockway
+J. Shirley <jshirley@gmail.com>
-Marchex, Inc. paid me while I developed this module. (http://www.marchex.com)
+=head1 CONTRIBUTORS
-=head1 CONTRIBUTERS
+Christopher Laco
+
+Luke Saunders
+
+John Goulah
Daisuke Maki <daisuke@endeworks.jp>
+=head1 AUTHOR
+
+Adam Jacob <adam@stalecoffee.org>, with lots of help from mst and jrockway
+
+Marchex, Inc. paid me while I developed this module. (http://www.marchex.com)
+
=head1 LICENSE
You may distribute this code under the same terms as Perl itself.
package Catalyst::Controller::REST;
-our $VERSION = 0.64;
+our $VERSION = '0.65';
=head1 NAME
'stash_key' => 'rest',
'map' => {
'text/x-yaml' => 'YAML',
- 'application/json' => 'JSON',
+ 'application/json' => 'JSON',
'text/x-data-dumper' => [ 'Data::Serializer', 'Data::Dumper' ],
'text/broken' => 'Broken',
},
use Data::Serializer;
use FindBin;
use Data::Dump qw(dump);
-use JSON::Syck;
use lib ("$FindBin::Bin/lib", "$FindBin::Bin/../lib", "$FindBin::Bin/broken");
use Test::Rest;
$req->remove_header('Content-Type');
$req->header('Accept', 'text/x-yaml');
my $res = request($req);
- ok( $res->is_success, 'GET the serialized request succeeded' );
- is( $res->content, $data, "Request returned proper data");
- is( $res->header('Content-type'), 'text/x-yaml', '... with expected content-type')
+ SKIP: {
+ skip "can't test text/x-yaml without YAML support",
+ 3 if (
+ not $res->is_success and
+ $res->content =~ m#Content-Type text/x-yaml is not supported#
+ );
+ ok( $res->is_success, 'GET the serialized request succeeded' );
+ is( $res->content, $data, "Request returned proper data");
+ is( $res->header('Content-type'), 'text/x-yaml', '... with expected content-type')
+
+ };
}
-{
- my $at = Test::Rest->new('content_type' => 'text/doesnt-exist');
+SKIP: {
+ eval 'require JSON';
+ skip "can't test application/json without JSON support", 3 if $@;
+ my $json = JSON->new;
+ my $at = Test::Rest->new('content_type' => 'text/doesnt-exist');
my $req = $at->get(url => '/test');
$req->header('Accept', 'application/json');
my $res = request($req);
- ok( $res->is_success, 'GET the serialized request succeeded' );
- my $ret = JSON::Syck::Load($res->content);
- is( $ret->{lou}, 'is my cat', "Request returned proper data");
- is( $res->header('Content-type'), 'application/json', 'Accept header used if content-type mapping not found')
-}
+ ok( $res->is_success, 'GET the serialized request succeeded' );
+ my $ret = $json->decode($res->content);
+ is( $ret->{lou}, 'is my cat', "Request returned proper data");
+ is( $res->header('Content-type'), 'application/json', 'Accept header used if content-type mapping not found')
+};
# Make sure we don't get a bogus content-type when using default
# serializer (rt.cpan.org ticket 27949)
$request->headers( HTTP::Headers->new );
$request->parameters( {} );
$request->method('GET');
- $request->content_type('text/x-json');
+ $request->content_type('application/json');
$request->headers->header(
'Accept' =>
# From Firefox 2.0 when it requests an html page
);
is_deeply( $request->accepted_content_types,
- [ qw( text/x-json
+ [ qw( application/json
text/xml application/xml application/xhtml+xml
image/png
text/html
use strict;
use warnings;
-use Test::More tests => 9;
+use Test::More;
use FindBin;
use lib ("$FindBin::Bin/lib", "$FindBin::Bin/../lib");
use Test::Rest;
-use_ok 'Catalyst::Test', 'Test::Serialize';
+eval 'require JSON';
+plan skip_all => 'Install JSON to run this test' if ($@);
-SKIP: {
- my $has_serializer = eval "require JSON::Syck";
+plan tests => 9;
- skip "JSON::Syck not available", 8, unless $has_serializer;
+use_ok 'Catalyst::Test', 'Test::Serialize';
- for ('text/x-json', 'application/json') {
- my $t = Test::Rest->new('content_type' => $_);
- my $monkey_template = {
- monkey => 'likes chicken!',
- };
- my $mres = request($t->get(url => '/monkey_get'));
- ok( $mres->is_success, 'GET the monkey succeeded' );
- is_deeply(JSON::Syck::Load($mres->content), $monkey_template, "GET returned the right data");
+my $json = JSON->new;
+# The text/x-json should throw a warning
+for ('text/x-json', 'application/json') {
+ my $t = Test::Rest->new('content_type' => $_);
+ my $monkey_template = {
+ monkey => 'likes chicken!',
+ };
+ my $mres = request($t->get(url => '/monkey_get'));
+ ok( $mres->is_success, 'GET the monkey succeeded' );
+ is_deeply($json->decode($mres->content), $monkey_template, "GET returned the right data");
- my $post_data = {
- 'sushi' => 'is good for monkey',
- };
- my $mres_post = request($t->post(url => '/monkey_put', data => JSON::Syck::Dump($post_data)));
- ok( $mres_post->is_success, "POST to the monkey succeeded");
- is_deeply($mres_post->content, "is good for monkey", "POST data matches");
- }
-};
+ my $post_data = {
+ 'sushi' => 'is good for monkey',
+ };
+ my $mres_post = request($t->post(url => '/monkey_put', data => $json->encode($post_data)));
+ ok( $mres_post->is_success, "POST to the monkey succeeded");
+ is_deeply($mres_post->content, "is good for monkey", "POST data matches");
+}
1;