From 9e4394808f2a9f4c8a69b7a7f5100b7b2d0e87b0 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Sat, 12 Jul 2008 04:26:23 +0000 Subject: [PATCH] Fix more JSON errors in WebGUI.conf.original Add a test to make sure that it is valid JSON. --- etc/WebGUI.conf.original | 6 ++-- t/WebGUI_conf.t | 63 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 t/WebGUI_conf.t diff --git a/etc/WebGUI.conf.original b/etc/WebGUI.conf.original index cf9b6d215..2ffa0ab9a 100644 --- a/etc/WebGUI.conf.original +++ b/etc/WebGUI.conf.original @@ -248,7 +248,7 @@ "WebGUI::Asset::Wobject::SyndicatedContent", "WebGUI::Asset::Wobject::Thingy", "WebGUI::Asset::Wobject::TimeTracking", - "WebGUI::Asset::Wobject::UserList" + "WebGUI::Asset::Wobject::UserList", "WebGUI::Asset::Wobject::WeatherData", "WebGUI::Asset::Wobject::WSClient" ], @@ -258,7 +258,7 @@ # management. "utilityAssets" : [ - "WebGUI::Asset::File" + "WebGUI::Asset::File", "WebGUI::Asset::File::Image", "WebGUI::Asset::RichEdit", "WebGUI::Asset::Template" @@ -434,7 +434,7 @@ "WebGUI::Workflow::Activity::ExpireGroupings", "WebGUI::Workflow::Activity::ExpireSubscriptionCodes", "WebGUI::Workflow::Activity::GetSyndicatedContent", - "WebGUI::Workflow::Activity::NotifyAdminsWithOpenVersionTags" + "WebGUI::Workflow::Activity::NotifyAdminsWithOpenVersionTags", "WebGUI::Workflow::Activity::ProcessRecurringPayments", "WebGUI::Workflow::Activity::PurgeOldAssetRevisions", "WebGUI::Workflow::Activity::PurgeOldTrash", diff --git a/t/WebGUI_conf.t b/t/WebGUI_conf.t new file mode 100644 index 000000000..d1bc002a6 --- /dev/null +++ b/t/WebGUI_conf.t @@ -0,0 +1,63 @@ +# vim:syntax=perl +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2008 Plain Black Corporation. +#------------------------------------------------------------------- +# Please read the legal notices (docs/legal.txt) and the license +# (docs/license.txt) that came with this distribution before using +# this software. +#------------------------------------------------------------------ +# http://www.plainblack.com info@plainblack.com +#------------------------------------------------------------------ + +# Test the default WebGUI.conf file to make sure it is valid JSON. + +use FindBin; +use strict; +use lib "$FindBin::Bin/lib"; +use Test::More; +use WebGUI::Test; # Must use this before any other WebGUI modules +use WebGUI::Session; +use JSON; +use Path::Class; + +#---------------------------------------------------------------------------- +# Init +my $session = WebGUI::Test->session; + + +#---------------------------------------------------------------------------- +# Tests + +plan tests => 3; # Increment this number for each test you create + +#---------------------------------------------------------------------------- +# put your tests here + +my $defaultConfigFile = Path::Class::File->new(WebGUI::Test->root, qw/etc WebGUI.conf.original/); + +ok (-e $defaultConfigFile->stringify, 'WebGUI.conf.original exists'); + +open my $jsonHandle, join('', '<', $defaultConfigFile->stringify); +my $jsonText; +{ + local $/; + $jsonText = <$jsonHandle>; +} +close $jsonHandle; + +ok($jsonText, 'The file is not empty'); + +my $perlScalar; +eval { $perlScalar = JSON->new->relaxed(1)->decode($jsonText) }; + +diag $@; + +if ($@) { + my $index; + ($index) = $@ =~ /character offset (\d+)/; + my $fragment = substr $jsonText, int($index/100)*100, 100; + diag "Problem found in default WebGUI.conf file, look near here:"; + diag $fragment; +} + +ok( defined $perlScalar, 'JSON is valid');