1use strict; 2use warnings; 3 4use Test::More; 5 6use RPC::ExtDirect::Test::Util; 7 8if ( $ENV{REGRESSION_TESTS} ) { 9 plan tests => 4; 10} 11else { 12 plan skip_all => 'Regression tests are not enabled.'; 13} 14 15# We will test deprecated API and don't want the warnings 16# cluttering STDERR 17$SIG{__WARN__} = sub {}; 18 19# Test modules are so simple they can't be broken 20use lib 't/lib2'; 21use RPC::ExtDirect::Test::Foo; 22use RPC::ExtDirect::Test::Bar; 23use RPC::ExtDirect::Test::Qux; 24 25use RPC::ExtDirect::API; 26 27# Set the debug flag 28local $RPC::ExtDirect::API::DEBUG = 1; 29 30my $expected = q~ 31Ext.app.REMOTING_API = { 32 "actions":{ 33 "Bar":[ 34 { "len":5, "name":"bar_bar" }, 35 { "formHandler":true, "name":"bar_baz" }, 36 { "len":4, "name":"bar_foo" } 37 ], 38 "Foo":[ 39 { "len":2, "name":"foo_bar" }, 40 { "name":"foo_baz", "params":["foo","bar","baz"] }, 41 { "name":"foo_blessed", "params":[], "strict":false }, 42 { "len":1, "name":"foo_foo" }, 43 { "len":0, "name":"foo_zero" } 44 ], 45 "Qux":[ 46 { "len":5, "name":"bar_bar" }, 47 { "formHandler":true, "name":"bar_baz" }, 48 { "len":4, "name":"bar_foo" }, 49 { "len":2, "name":"foo_bar" }, 50 { "name":"foo_baz", "params":["foo","bar","baz"] }, 51 { "len":1, "name":"foo_foo" } 52 ] 53 }, 54 "type":"remoting", 55 "url":"/extdirectrouter" 56}; 57~; 58 59my $remoting_api = eval { RPC::ExtDirect::API->get_remoting_api() }; 60 61is $@, '', "remoting_api() 1 eval $@"; 62cmp_api $remoting_api, $expected, "remoting_api() 1 result"; 63 64# "Reimport" with parameters 65 66RPC::ExtDirect::API->import( 67 namespace => 'myApp.Server', 68 router_path => '/router.cgi', 69 poll_path => '/poll.cgi', 70 remoting_var => 'Ext.app.REMOTE_CALL_API', 71 polling_var => 'Ext.app.REMOTE_EVENT_API', 72 auto_connect => 'HELL YEAH!', 73); 74 75$expected = q~ 76Ext.app.REMOTE_CALL_API = { 77 "actions":{ 78 "Bar":[ 79 { "len":5, "name":"bar_bar" }, 80 { "formHandler":true, "name":"bar_baz" }, 81 { "len":4, "name":"bar_foo" } 82 ], 83 "Foo":[ 84 { "len":2, "name":"foo_bar" }, 85 { "name":"foo_baz", "params":["foo","bar","baz"] }, 86 { "name":"foo_blessed", "params":[], "strict":false }, 87 { "len":1, "name":"foo_foo" }, 88 { "len":0, "name":"foo_zero" } 89 ], 90 "Qux":[ 91 { "len":5, "name":"bar_bar" }, 92 { "formHandler":true, "name":"bar_baz" }, 93 { "len":4, "name":"bar_foo" }, 94 { "len":2, "name":"foo_bar" }, 95 { "name":"foo_baz", "params":["foo","bar","baz"] }, 96 { "len":1, "name":"foo_foo" } 97 ] 98 }, 99 "namespace":"myApp.Server", 100 "type":"remoting", 101 "url":"/router.cgi" 102}; 103Ext.direct.Manager.addProvider(Ext.app.REMOTE_CALL_API); 104~; 105 106$remoting_api = eval { RPC::ExtDirect::API->get_remoting_api() }; 107 108is $@, '', "remoting_api() 2 eval $@"; 109cmp_api $remoting_api, $expected, "remoting_api() 2 result"; 110