rhoconnect 3.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +208 -0
- data/CREDITS +38 -0
- data/Gemfile +18 -0
- data/Gemfile.lock +97 -0
- data/LICENSE +75 -0
- data/README.md +10 -0
- data/Rakefile +82 -0
- data/bench/bench +7 -0
- data/bench/bench_runner.rb +112 -0
- data/bench/benchapp/Gemfile +21 -0
- data/bench/benchapp/Gemfile.lock +76 -0
- data/bench/benchapp/Rakefile +22 -0
- data/bench/benchapp/application.rb +39 -0
- data/bench/benchapp/config.ru +36 -0
- data/bench/benchapp/settings/license.key +1 -0
- data/bench/benchapp/settings/settings.yml +20 -0
- data/bench/benchapp/sources/mock_adapter.rb +55 -0
- data/bench/benchapp/sources/queue_mock_adapter.rb +2 -0
- data/bench/benchapp/spec/sources/mock_adapter_spec.rb +25 -0
- data/bench/benchapp/spec/sources/queue_mock_adapter_spec.rb +25 -0
- data/bench/benchapp/spec/spec_helper.rb +42 -0
- data/bench/blobapp/Gemfile +31 -0
- data/bench/blobapp/Gemfile.lock +103 -0
- data/bench/blobapp/Rakefile +25 -0
- data/bench/blobapp/application.rb +44 -0
- data/bench/blobapp/config.ru +36 -0
- data/bench/blobapp/settings/license.key +1 -0
- data/bench/blobapp/settings/settings.yml +16 -0
- data/bench/blobapp/sources/blob_adapter.rb +71 -0
- data/bench/blobapp/spec/sources/blob_adapter_spec.rb +25 -0
- data/bench/blobapp/spec/spec_helper.rb +42 -0
- data/bench/lib/bench/cli.rb +16 -0
- data/bench/lib/bench/logging.rb +13 -0
- data/bench/lib/bench/mock_client.rb +41 -0
- data/bench/lib/bench/result.rb +50 -0
- data/bench/lib/bench/runner.rb +107 -0
- data/bench/lib/bench/session.rb +67 -0
- data/bench/lib/bench/statistics.rb +56 -0
- data/bench/lib/bench/test_data.rb +98 -0
- data/bench/lib/bench/timer.rb +10 -0
- data/bench/lib/bench/utils.rb +49 -0
- data/bench/lib/bench.rb +129 -0
- data/bench/lib/testdata/100-data.txt +148 -0
- data/bench/lib/testdata/5-data.txt +9 -0
- data/bench/lib/testdata/images/icon.ico +0 -0
- data/bench/lib/testdata/images/icon.png +0 -0
- data/bench/lib/testdata/images/loading-Landscape.png +0 -0
- data/bench/lib/testdata/images/loading-LandscapeLeft.png +0 -0
- data/bench/lib/testdata/images/loading-LandscapeRight.png +0 -0
- data/bench/lib/testdata/images/loading-Portrait.png +0 -0
- data/bench/lib/testdata/images/loading-PortraitUpsideDown.png +0 -0
- data/bench/lib/testdata/images/loading.png +0 -0
- data/bench/lib/testdata/images/loading@2x.png +0 -0
- data/bench/run_bench.sh +42 -0
- data/bench/run_blob_script.sh +3 -0
- data/bench/run_cud_script.sh +3 -0
- data/bench/run_query_md_script.sh +3 -0
- data/bench/run_query_only_script.sh +3 -0
- data/bench/run_query_script.sh +3 -0
- data/bench/scripts/blob_cud_script.rb +98 -0
- data/bench/scripts/cud_script.rb +92 -0
- data/bench/scripts/helpers.rb +101 -0
- data/bench/scripts/query_md_script.rb +45 -0
- data/bench/scripts/query_only_script.rb +51 -0
- data/bench/scripts/query_script.rb +45 -0
- data/bench/spec/bench_spec_helper.rb +33 -0
- data/bench/spec/logging_spec.rb +15 -0
- data/bench/spec/mock_adapter_spec.rb +61 -0
- data/bench/spec/mock_client_spec.rb +65 -0
- data/bench/spec/result_spec.rb +61 -0
- data/bench/spec/utils_spec.rb +36 -0
- data/bin/rhoconnect +34 -0
- data/bin/rhoconnect-setup +84 -0
- data/doc/async-jobs.txt +69 -0
- data/doc/authentication.txt +76 -0
- data/doc/benchmarks.txt +168 -0
- data/doc/blob-sync.txt +130 -0
- data/doc/bulk-sync.txt +102 -0
- data/doc/client.txt +432 -0
- data/doc/command-line.txt +210 -0
- data/doc/contributing.txt +60 -0
- data/doc/deploying.txt +82 -0
- data/doc/install.txt +28 -0
- data/doc/introduction.txt +20 -0
- data/doc/licensing.txt +18 -0
- data/doc/metadata.txt +458 -0
- data/doc/migration.txt +182 -0
- data/doc/public/css/print.css +29 -0
- data/doc/public/css/screen.css +257 -0
- data/doc/public/css/style.css +20 -0
- data/doc/push.txt +135 -0
- data/doc/release.txt +41 -0
- data/doc/rest-api.txt +367 -0
- data/doc/source-adapters.txt +325 -0
- data/doc/stats-middleware.txt +69 -0
- data/doc/testing.txt +222 -0
- data/doc/tutorial.txt +315 -0
- data/doc/web-console.txt +35 -0
- data/examples/simple/Rakefile +14 -0
- data/examples/simple/application.rb +27 -0
- data/examples/simple/config.ru +49 -0
- data/examples/simple/settings/license.key +1 -0
- data/examples/simple/settings/settings.yml +23 -0
- data/examples/simple/sources/sample_adapter.rb +5 -0
- data/examples/simple/sources/simple_adapter.rb +5 -0
- data/generators/rhoconnect.rb +119 -0
- data/generators/templates/application/Gemfile +21 -0
- data/generators/templates/application/Rakefile +22 -0
- data/generators/templates/application/application.rb +39 -0
- data/generators/templates/application/config.ru +36 -0
- data/generators/templates/application/settings/license.key +1 -0
- data/generators/templates/application/settings/settings.yml +14 -0
- data/generators/templates/application/spec/spec_helper.rb +42 -0
- data/generators/templates/source/source_adapter.rb +47 -0
- data/generators/templates/source/source_spec.rb +25 -0
- data/install.sh +408 -0
- data/installer/unix-like/rho_connect_install_checkers.rb +140 -0
- data/installer/unix-like/rho_connect_install_constants.rb +51 -0
- data/installer/unix-like/rho_connect_install_debian.rb +63 -0
- data/installer/unix-like/rho_connect_install_dnd.rb +58 -0
- data/installer/unix-like/rho_connect_install_get_params.rb +30 -0
- data/installer/unix-like/rho_connect_install_installers.rb +142 -0
- data/installer/unix-like/rho_connect_install_utilities.rb +85 -0
- data/installer/unix-like/rho_connect_install_yum.rb +63 -0
- data/installer/unix-like/rhoinstaller.rb +89 -0
- data/installer/utils/create_texts.rb +366 -0
- data/installer/utils/install_test.rb +140 -0
- data/installer/windows/EnvVarUpdate.nsh +328 -0
- data/installer/windows/ServiceLib.nsh +369 -0
- data/installer/windows/configUi.ini +44 -0
- data/installer/windows/icon.ico +0 -0
- data/installer/windows/rhosync.nsi +418 -0
- data/installer/windows/uninstall.bat +7 -0
- data/lib/rhoconnect/api/admin/get_api_token.rb +14 -0
- data/lib/rhoconnect/api/admin/get_license_info.rb +8 -0
- data/lib/rhoconnect/api/admin/login.rb +6 -0
- data/lib/rhoconnect/api/admin/reset.rb +10 -0
- data/lib/rhoconnect/api/admin/stats.rb +21 -0
- data/lib/rhoconnect/api/application/bulk_data.rb +7 -0
- data/lib/rhoconnect/api/application/clientcreate.rb +8 -0
- data/lib/rhoconnect/api/application/clientlogin.rb +6 -0
- data/lib/rhoconnect/api/application/clientregister.rb +6 -0
- data/lib/rhoconnect/api/application/clientreset.rb +6 -0
- data/lib/rhoconnect/api/application/query.rb +7 -0
- data/lib/rhoconnect/api/application/queue_updates.rb +6 -0
- data/lib/rhoconnect/api/application/search.rb +6 -0
- data/lib/rhoconnect/api/client/create_client.rb +3 -0
- data/lib/rhoconnect/api/client/delete_client.rb +5 -0
- data/lib/rhoconnect/api/client/get_client_params.rb +3 -0
- data/lib/rhoconnect/api/client/list_client_docs.rb +12 -0
- data/lib/rhoconnect/api/client/list_clients.rb +3 -0
- data/lib/rhoconnect/api/client/ping.rb +7 -0
- data/lib/rhoconnect/api/source/get_adapter.rb +3 -0
- data/lib/rhoconnect/api/source/get_db_doc.rb +7 -0
- data/lib/rhoconnect/api/source/get_source_params.rb +3 -0
- data/lib/rhoconnect/api/source/list_source_docs.rb +10 -0
- data/lib/rhoconnect/api/source/list_sources.rb +15 -0
- data/lib/rhoconnect/api/source/push_deletes.rb +8 -0
- data/lib/rhoconnect/api/source/push_objects.rb +8 -0
- data/lib/rhoconnect/api/source/save_adapter.rb +3 -0
- data/lib/rhoconnect/api/source/set_db_doc.rb +8 -0
- data/lib/rhoconnect/api/source/set_refresh_time.rb +8 -0
- data/lib/rhoconnect/api/source/upload_file.rb +4 -0
- data/lib/rhoconnect/api/user/create_user.rb +7 -0
- data/lib/rhoconnect/api/user/delete_user.rb +9 -0
- data/lib/rhoconnect/api/user/list_users.rb +3 -0
- data/lib/rhoconnect/api/user/update_user.rb +4 -0
- data/lib/rhoconnect/api_token.rb +19 -0
- data/lib/rhoconnect/app.rb +76 -0
- data/lib/rhoconnect/bulk_data/bulk_data.rb +88 -0
- data/lib/rhoconnect/bulk_data/syncdb.index.schema +4 -0
- data/lib/rhoconnect/bulk_data/syncdb.schema +41 -0
- data/lib/rhoconnect/bulk_data.rb +2 -0
- data/lib/rhoconnect/client.rb +96 -0
- data/lib/rhoconnect/client_sync.rb +412 -0
- data/lib/rhoconnect/console/app/helpers/auth_helper.rb +22 -0
- data/lib/rhoconnect/console/app/helpers/extensions.rb +19 -0
- data/lib/rhoconnect/console/app/helpers/helpers.rb +57 -0
- data/lib/rhoconnect/console/app/public/ThickBox.css +649 -0
- data/lib/rhoconnect/console/app/public/home.css +438 -0
- data/lib/rhoconnect/console/app/public/images/foot_logo_rhoconnect.png +0 -0
- data/lib/rhoconnect/console/app/public/images/header_halo.jpg +0 -0
- data/lib/rhoconnect/console/app/public/images/land_separator.gif +0 -0
- data/lib/rhoconnect/console/app/public/images/landing_header.jpg +0 -0
- data/lib/rhoconnect/console/app/public/images/logo_rhoconnect.png +0 -0
- data/lib/rhoconnect/console/app/public/images/rhomobile_rhohub_logo.png +0 -0
- data/lib/rhoconnect/console/app/public/images/tabs_separator.png +0 -0
- data/lib/rhoconnect/console/app/public/jqplot/excanvas.min.js +35 -0
- data/lib/rhoconnect/console/app/public/jqplot/jqplot.barRenderer.min.js +34 -0
- data/lib/rhoconnect/console/app/public/jqplot/jqplot.canvasAxisLabelRenderer.js +187 -0
- data/lib/rhoconnect/console/app/public/jqplot/jqplot.canvasAxisTickRenderer.js +226 -0
- data/lib/rhoconnect/console/app/public/jqplot/jqplot.canvasTextRenderer.js +408 -0
- data/lib/rhoconnect/console/app/public/jqplot/jqplot.categoryAxisRenderer.min.js +34 -0
- data/lib/rhoconnect/console/app/public/jqplot/jqplot.cursor.js +952 -0
- data/lib/rhoconnect/console/app/public/jqplot/jqplot.dateAxisRenderer.js +313 -0
- data/lib/rhoconnect/console/app/public/jqplot/jqplot.dateAxisRenderer.min.js +34 -0
- data/lib/rhoconnect/console/app/public/jqplot/jqplot.pointLabels.min.js +34 -0
- data/lib/rhoconnect/console/app/public/jqplot/jquery-1.4.2.min.js +154 -0
- data/lib/rhoconnect/console/app/public/jqplot/jquery.jqplot.min.css +1 -0
- data/lib/rhoconnect/console/app/public/jqplot/jquery.jqplot.min.js +34 -0
- data/lib/rhoconnect/console/app/public/main.css +7 -0
- data/lib/rhoconnect/console/app/public/reset.css +76 -0
- data/lib/rhoconnect/console/app/public/style.css +2201 -0
- data/lib/rhoconnect/console/app/public/text.txt +0 -0
- data/lib/rhoconnect/console/app/routes/adapter.rb +28 -0
- data/lib/rhoconnect/console/app/routes/auth.rb +29 -0
- data/lib/rhoconnect/console/app/routes/client.rb +31 -0
- data/lib/rhoconnect/console/app/routes/docs.rb +145 -0
- data/lib/rhoconnect/console/app/routes/heroku.rb +19 -0
- data/lib/rhoconnect/console/app/routes/home.rb +63 -0
- data/lib/rhoconnect/console/app/routes/timing.rb +242 -0
- data/lib/rhoconnect/console/app/routes/user.rb +117 -0
- data/lib/rhoconnect/console/app/views/adapter.erb +16 -0
- data/lib/rhoconnect/console/app/views/client.erb +30 -0
- data/lib/rhoconnect/console/app/views/content.erb +14 -0
- data/lib/rhoconnect/console/app/views/doc.erb +8 -0
- data/lib/rhoconnect/console/app/views/docdata.erb +28 -0
- data/lib/rhoconnect/console/app/views/docs.erb +30 -0
- data/lib/rhoconnect/console/app/views/edituser.erb +13 -0
- data/lib/rhoconnect/console/app/views/headermenu.erb +40 -0
- data/lib/rhoconnect/console/app/views/home.erb +24 -0
- data/lib/rhoconnect/console/app/views/index.erb +58 -0
- data/lib/rhoconnect/console/app/views/jqplot.erb +52 -0
- data/lib/rhoconnect/console/app/views/layout.erb +165 -0
- data/lib/rhoconnect/console/app/views/login.erb +26 -0
- data/lib/rhoconnect/console/app/views/newuser.erb +17 -0
- data/lib/rhoconnect/console/app/views/ping.erb +28 -0
- data/lib/rhoconnect/console/app/views/result.erb +11 -0
- data/lib/rhoconnect/console/app/views/rightboxlinks.erb +15 -0
- data/lib/rhoconnect/console/app/views/select_doc.erb +17 -0
- data/lib/rhoconnect/console/app/views/upload_doc.erb +23 -0
- data/lib/rhoconnect/console/app/views/user.erb +29 -0
- data/lib/rhoconnect/console/app/views/users.erb +12 -0
- data/lib/rhoconnect/console/rhoconnect_api.rb +245 -0
- data/lib/rhoconnect/console/server.rb +32 -0
- data/lib/rhoconnect/console.rb +3 -0
- data/lib/rhoconnect/cors.rb +229 -0
- data/lib/rhoconnect/credential.rb +9 -0
- data/lib/rhoconnect/db_adapter.rb +46 -0
- data/lib/rhoconnect/document.rb +49 -0
- data/lib/rhoconnect/dynamic_adapter.rb +91 -0
- data/lib/rhoconnect/generator.rb +1 -0
- data/lib/rhoconnect/jobs/bulk_data_job.rb +203 -0
- data/lib/rhoconnect/jobs/ping_job.rb +46 -0
- data/lib/rhoconnect/jobs/source_job.rb +16 -0
- data/lib/rhoconnect/license.rb +86 -0
- data/lib/rhoconnect/lock_ops.rb +11 -0
- data/lib/rhoconnect/model.rb +414 -0
- data/lib/rhoconnect/ping/android.rb +56 -0
- data/lib/rhoconnect/ping/apple.rb +52 -0
- data/lib/rhoconnect/ping/blackberry.rb +56 -0
- data/lib/rhoconnect/ping.rb +3 -0
- data/lib/rhoconnect/read_state.rb +31 -0
- data/lib/rhoconnect/rho_indifferent_access.rb +88 -0
- data/lib/rhoconnect/server/views/index.erb +13 -0
- data/lib/rhoconnect/server.rb +286 -0
- data/lib/rhoconnect/source.rb +289 -0
- data/lib/rhoconnect/source_adapter.rb +123 -0
- data/lib/rhoconnect/source_sync.rb +302 -0
- data/lib/rhoconnect/stats/middleware.rb +20 -0
- data/lib/rhoconnect/stats/record.rb +108 -0
- data/lib/rhoconnect/store.rb +232 -0
- data/lib/rhoconnect/tasks.rb +350 -0
- data/lib/rhoconnect/test_methods.rb +220 -0
- data/lib/rhoconnect/user.rb +95 -0
- data/lib/rhoconnect/version.rb +3 -0
- data/lib/rhoconnect/x_domain_session_wrapper.rb +53 -0
- data/lib/rhoconnect.rb +285 -0
- data/rhoconnect.gemspec +67 -0
- data/spec/api/admin/api_token_spec.rb +14 -0
- data/spec/api/admin/get_api_token_spec.rb +36 -0
- data/spec/api/admin/get_license_info_spec.rb +38 -0
- data/spec/api/admin/reset_spec.rb +22 -0
- data/spec/api/admin/stats_spec.rb +66 -0
- data/spec/api/api_helper.rb +21 -0
- data/spec/api/application/rhoconnect_api_spec.rb +548 -0
- data/spec/api/client/create_client_spec.rb +13 -0
- data/spec/api/client/delete_client_spec.rb +13 -0
- data/spec/api/client/get_client_params_spec.rb +18 -0
- data/spec/api/client/list_client_docs_spec.rb +32 -0
- data/spec/api/client/list_clients_spec.rb +22 -0
- data/spec/api/client/ping_spec.rb +23 -0
- data/spec/api/rhosync_api_spec.rb.orig +606 -0
- data/spec/api/source/adapter_spec.rb +29 -0
- data/spec/api/source/get_db_doc_spec.rb +21 -0
- data/spec/api/source/get_source_params_spec.rb +32 -0
- data/spec/api/source/list_source_docs_spec.rb +25 -0
- data/spec/api/source/list_sources_spec.rb +26 -0
- data/spec/api/source/push_deletes_spec.rb +18 -0
- data/spec/api/source/push_objects_spec.rb +27 -0
- data/spec/api/source/set_db_doc_spec.rb +19 -0
- data/spec/api/source/set_refresh_time_spec.rb +43 -0
- data/spec/api/source/upload_file_spec.rb +26 -0
- data/spec/api/user/create_user_spec.rb +16 -0
- data/spec/api/user/delete_user_spec.rb +36 -0
- data/spec/api/user/list_users_spec.rb +30 -0
- data/spec/api/user/update_user_spec.rb +31 -0
- data/spec/api_token_spec.rb +14 -0
- data/spec/app_spec.rb +18 -0
- data/spec/apps/emptyapp/application.rb +27 -0
- data/spec/apps/emptyapp/settings/license.key +1 -0
- data/spec/apps/emptyapp/settings/settings.yml +14 -0
- data/spec/apps/rhotestapp/Rakefile +1 -0
- data/spec/apps/rhotestapp/application.rb +19 -0
- data/spec/apps/rhotestapp/config.ru +1 -0
- data/spec/apps/rhotestapp/settings/apple_fake_cert.pem +1 -0
- data/spec/apps/rhotestapp/settings/license.key +1 -0
- data/spec/apps/rhotestapp/settings/settings.yml +36 -0
- data/spec/apps/rhotestapp/sources/base_adapter.rb +9 -0
- data/spec/apps/rhotestapp/sources/fixed_schema_adapter.rb +28 -0
- data/spec/apps/rhotestapp/sources/sample_adapter.rb +71 -0
- data/spec/apps/rhotestapp/sources/simple_adapter.rb +41 -0
- data/spec/apps/rhotestapp/sources/sub_adapter.rb +7 -0
- data/spec/apps/rhotestapp/vendor/mygem-0.1.0/lib/mygem/mygem.rb +8 -0
- data/spec/apps/rhotestapp/vendor/mygem-0.1.0/lib/mygem.rb +1 -0
- data/spec/bulk_data/bulk_data_spec.rb +97 -0
- data/spec/client_spec.rb +124 -0
- data/spec/client_sync_spec.rb +774 -0
- data/spec/doc/base.html +72 -0
- data/spec/doc/doc_spec.rb +376 -0
- data/spec/doc/footer.html +4 -0
- data/spec/doc/header.html +30 -0
- data/spec/document_spec.rb +31 -0
- data/spec/dynamic_adapter_spec.rb +43 -0
- data/spec/factories/factories.rb +17 -0
- data/spec/generator/generator_spec.rb +58 -0
- data/spec/generator/generator_spec_helper.rb +9 -0
- data/spec/jobs/bulk_data_job_spec.rb +125 -0
- data/spec/jobs/ping_job_spec.rb +102 -0
- data/spec/jobs/source_job_spec.rb +29 -0
- data/spec/license_spec.rb +66 -0
- data/spec/model_spec.rb +273 -0
- data/spec/perf/bulk_data_perf_spec.rb +32 -0
- data/spec/perf/perf_spec_helper.rb +50 -0
- data/spec/perf/store_perf_spec.rb +27 -0
- data/spec/ping/android_spec.rb +91 -0
- data/spec/ping/apple_spec.rb +70 -0
- data/spec/ping/blackberry_spec.rb +62 -0
- data/spec/read_state_spec.rb +35 -0
- data/spec/rhosync_spec.rb +75 -0
- data/spec/server/cors_spec.rb +287 -0
- data/spec/server/server_spec.rb +470 -0
- data/spec/server/x_domain_session_wrapper_spec.rb +150 -0
- data/spec/source_adapter_spec.rb +125 -0
- data/spec/source_spec.rb +114 -0
- data/spec/source_sync_spec.rb +328 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +231 -0
- data/spec/stats/middleware_spec.rb +53 -0
- data/spec/stats/record_spec.rb +92 -0
- data/spec/store_spec.rb +251 -0
- data/spec/support/shared_examples.rb +168 -0
- data/spec/sync_states_spec.rb +72 -0
- data/spec/test_methods_spec.rb +134 -0
- data/spec/testdata/1000-data.txt +1414 -0
- data/spec/testdata/compressed/compress-data.txt +1 -0
- data/spec/testdata/upload1.txt +1 -0
- data/spec/testdata/upload2.txt +1 -0
- data/spec/user_spec.rb +139 -0
- data/tasks/redis.rake +206 -0
- metadata +706 -0
@@ -0,0 +1,125 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__),'spec_helper')
|
2
|
+
require File.join(File.dirname(__FILE__), 'support', 'shared_examples')
|
3
|
+
|
4
|
+
class Rhoconnect::SourceAdapter
|
5
|
+
def inject_result(result)
|
6
|
+
@result = result
|
7
|
+
end
|
8
|
+
|
9
|
+
def inject_tmpdoc(docname)
|
10
|
+
@tmp_docname = docname
|
11
|
+
@stash_size = 0
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "SourceAdapter" do
|
16
|
+
it_behaves_like "SharedRhoconnectHelper", :rhoconnect_data => true do
|
17
|
+
before(:each) do
|
18
|
+
@s = Source.load('SimpleAdapter',@s_params)
|
19
|
+
@sa = SourceAdapter.create(@s,nil)
|
20
|
+
end
|
21
|
+
|
22
|
+
def setup_adapter(name)
|
23
|
+
fields = {
|
24
|
+
:name => name,
|
25
|
+
:url => 'http://example.com',
|
26
|
+
:login => 'testuser',
|
27
|
+
:password => 'testpass',
|
28
|
+
}
|
29
|
+
Source.create(fields,@s_params)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should create SourceAdapter with source" do
|
33
|
+
@sa.class.name.should == @s.name
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should create DynamicAdapter" do
|
37
|
+
@sa1 = SourceAdapter.create(@s2)
|
38
|
+
@sa1.class.name.should == 'Rhoconnect::DynamicAdapter'
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should capture exception in create" do
|
42
|
+
DynamicAdapter.should_receive(:new).once.and_raise(Exception)
|
43
|
+
lambda { @sa1 = SourceAdapter.create(@s2) }.should raise_error(Exception)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should fail to create SourceAdapter" do
|
47
|
+
broken_source = setup_adapter('Bro-ken')
|
48
|
+
lambda { SourceAdapter.create(broken_source) }.should raise_error(Exception)
|
49
|
+
broken_source.delete
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should create SourceAdapter with trailing spaces" do
|
53
|
+
s = setup_adapter('SimpleAdapter ')
|
54
|
+
SourceAdapter.create(s,nil).is_a?(SimpleAdapter).should be_true
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "SourceAdapter methods" do
|
58
|
+
it "should execute SourceAdapter login method with source vars" do
|
59
|
+
@sa.login.should == true
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should execute SourceAdapter query method" do
|
63
|
+
expected = {'1'=>@product1,'2'=>@product2}
|
64
|
+
@sa.inject_result expected
|
65
|
+
@sa.query.should == expected
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should execute SourceAdapter search method and modify params" do
|
69
|
+
params = {:hello => 'world'}
|
70
|
+
expected = {'1'=>@product1,'2'=>@product2}
|
71
|
+
@sa.inject_result expected
|
72
|
+
@sa.search(params).should == expected
|
73
|
+
params.should == {:hello => 'world', :foo => 'bar'}
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should execute SourceAdapter login with current_user" do
|
77
|
+
@sa.should_receive(:current_user).with(no_args()).and_return(@u)
|
78
|
+
@sa.login
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should execute SourceAdapter sync method" do
|
82
|
+
expected = {'1'=>@product1,'2'=>@product2}
|
83
|
+
@sa.inject_result expected
|
84
|
+
@sa.do_query
|
85
|
+
Store.get_data(@s.docname(:md)).should == expected
|
86
|
+
Store.get_value(@s.docname(:md_size)).to_i.should == 2
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should fail gracefully if @result is missing" do
|
90
|
+
@sa.inject_result nil
|
91
|
+
lambda { @sa.query }.should_not raise_error
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should reset count if @result is empty" do
|
95
|
+
@sa.inject_result({'1'=>@product1,'2'=>@product2})
|
96
|
+
@sa.do_query
|
97
|
+
Store.get_value(@s.docname(:md_size)).to_i.should == 2
|
98
|
+
@sa.inject_result({})
|
99
|
+
@sa.do_query
|
100
|
+
Store.get_value(@s.docname(:md_size)).to_i.should == 0
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should execute SourceAdapter create method" do
|
104
|
+
@sa.create(@product4).should == 'obj4'
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should stash @result in store and set it to nil" do
|
108
|
+
expected = {'1'=>@product1,'2'=>@product2}
|
109
|
+
@sa.inject_result(expected)
|
110
|
+
@sa.inject_tmpdoc('tmpdoc')
|
111
|
+
@sa.stash_result
|
112
|
+
Store.get_data('tmpdoc').should == expected
|
113
|
+
end
|
114
|
+
|
115
|
+
describe "SourceAdapter metadata method" do
|
116
|
+
|
117
|
+
it "should execute SourceAdapter metadata method" do
|
118
|
+
mock_metadata_method([SimpleAdapter]) do
|
119
|
+
@sa.metadata.should == "{\"foo\":\"bar\"}"
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
data/spec/source_spec.rb
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__),'spec_helper')
|
2
|
+
require File.join(File.dirname(__FILE__), 'support', 'shared_examples')
|
3
|
+
|
4
|
+
describe "Source" do
|
5
|
+
it_behaves_like "SharedRhoconnectHelper", :rhoconnect_data => false do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
@s = Source.load(@s_fields[:name],@s_params)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should create and load source with @s_fields and @s_params" do
|
12
|
+
@s.name.should == @s_fields[:name]
|
13
|
+
@s.url.should == @s_fields[:url]
|
14
|
+
@s.login.should == @s_fields[:login]
|
15
|
+
@s.app.name.should == @a_fields[:name]
|
16
|
+
@s.priority.should == 3
|
17
|
+
@s.callback_url.should be_nil
|
18
|
+
@s.queue.should be_nil
|
19
|
+
@s.query_queue.should be_nil
|
20
|
+
@s.cud_queue.should be_nil
|
21
|
+
@s.app_id.should == @s_params[:app_id]
|
22
|
+
@s.user_id.should == @s_params[:user_id]
|
23
|
+
@s.sync_type.should == :incremental
|
24
|
+
@s.partition_type.should == :user
|
25
|
+
@s.poll_interval.should == 300
|
26
|
+
|
27
|
+
@s1 = Source.load(@s.id,@s_params)
|
28
|
+
@s1.name.should == @s_fields[:name]
|
29
|
+
@s1.url.should == @s_fields[:url]
|
30
|
+
@s1.login.should == @s_fields[:login]
|
31
|
+
@s1.app.name.should == @a_fields[:name]
|
32
|
+
@s1.priority.should == 3
|
33
|
+
@s1.callback_url.should be_nil
|
34
|
+
@s1.poll_interval.should == 300
|
35
|
+
@s1.app_id.should == @s_params[:app_id]
|
36
|
+
@s1.user_id.should == @s_params[:user_id]
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should create source with user" do
|
40
|
+
@s.user.login.should == @u_fields[:login]
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should create source with app and document" do
|
44
|
+
@s.app.name.should == @a_fields[:name]
|
45
|
+
@s.docname(:md).should == "source:#{@s.app.id}:#{@u.id}:#{@s_fields[:name]}:md"
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should return values that set by setter method' do
|
49
|
+
@s.login = "shurab"
|
50
|
+
@s.login.should == "shurab"
|
51
|
+
@s.poll_interval = 350
|
52
|
+
@s.poll_interval.should == 350
|
53
|
+
@s.poll_interval = nil
|
54
|
+
@s.poll_interval.should == nil
|
55
|
+
@s.url = nil
|
56
|
+
@s.url.should be_nil
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should delete source" do
|
60
|
+
@s.delete
|
61
|
+
Source.is_exist?(@s_fields[:name]).should == false
|
62
|
+
@s = Source.create(@s_fields,@s_params)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should delete master and all documents associated with source" do
|
66
|
+
key = @s.docname('*')
|
67
|
+
set_state(key => @data)
|
68
|
+
@s.delete
|
69
|
+
verify_result(key => {})
|
70
|
+
Store.db.keys(key).should == []
|
71
|
+
@s = Source.create(@s_fields,@s_params)
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should create source with default partition user" do
|
75
|
+
@s1 = Source.load(@s_fields[:name],{:app_id => @a.id,:user_id => '*'})
|
76
|
+
@s1.partition.should == :user
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should create correct docname based on partition scheme" do
|
80
|
+
@s.partition = :app
|
81
|
+
@s.docname(:md).should == "source:#{@s.app.id}:__shared__:#{@s_fields[:name]}:md"
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should create source with default read/write queue" do
|
85
|
+
@s.delete
|
86
|
+
@s_fields[:queue] = :default
|
87
|
+
@s_fields[:query_queue] = :query
|
88
|
+
@s_fields[:cud_queue] = :cud
|
89
|
+
@s = Source.create(@s_fields,@s_params)
|
90
|
+
s = Source.load(@s_fields[:name],@s_params)
|
91
|
+
s.queue.should == :default
|
92
|
+
s.query_queue.should == :query
|
93
|
+
s.cud_queue.should == :cud
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should add associations based on belongs_to field for a source" do
|
97
|
+
@s2 = Source.create({:name => 'SimpleAdapter'}, @s_params)
|
98
|
+
@s2.belongs_to = [{'product_id' => 'SampleAdapter'}].to_json
|
99
|
+
sf = Source.load(@s1.name,{:app_id => @a.id,:user_id => '*'})
|
100
|
+
Source.update_associations([@s.name,@s1.name, @s2.name])
|
101
|
+
s = Source.load(@s.name,{:app_id => @a.id,:user_id => '*'})
|
102
|
+
s.has_many.should == "#{@s1.name},brand,#{@s2.name},product_id"
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should log warning about incorrect belongs_to format for a source" do
|
106
|
+
@s2 = Source.create({:name => 'SimpleAdapter'}, @s_params)
|
107
|
+
@s2.belongs_to = {'product_id' => 'SampleAdapter'}.to_json
|
108
|
+
Source.should_receive(:log).once.with(
|
109
|
+
"WARNING: Incorrect belongs_to format for SimpleAdapter, belongs_to should be an array."
|
110
|
+
)
|
111
|
+
Source.update_associations([@s.name,@s1.name, @s2.name])
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
@@ -0,0 +1,328 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__),'spec_helper')
|
2
|
+
require File.join(File.dirname(__FILE__), 'support', 'shared_examples')
|
3
|
+
|
4
|
+
describe "SourceSync" do
|
5
|
+
it_behaves_like "SharedRhoconnectHelper", :rhoconnect_data => true do
|
6
|
+
before(:each) do
|
7
|
+
@s = Source.load(@s_fields[:name],@s_params)
|
8
|
+
@ss = SourceSync.new(@s)
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:mock_schema) { {"property" => { "name" => "string", "brand" => "string" }, "version" => "1.0"} }
|
12
|
+
|
13
|
+
it "should create SourceSync" do
|
14
|
+
@ss.adapter.is_a?(SampleAdapter).should == true
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should fail to create SourceSync with InvalidArgumentError" do
|
18
|
+
lambda { SourceSync.new(nil) }.should raise_error(InvalidArgumentError, 'Invalid source')
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should raise SourceAdapterLoginException if login fails" do
|
22
|
+
msg = "Error logging in"
|
23
|
+
@u.login = nil
|
24
|
+
@ss = SourceSync.new(@s)
|
25
|
+
@ss.should_receive(:log).with("SourceAdapter raised login exception: #{msg}")
|
26
|
+
@ss.should_receive(:log).with(anything)
|
27
|
+
@ss.process_query
|
28
|
+
verify_result(@s.docname(:errors) => {'login-error'=>{'message'=>msg}})
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should raise SourceAdapterLogoffException if logoff fails" do
|
32
|
+
msg = "Error logging off"
|
33
|
+
@ss.should_receive(:log).with("SourceAdapter raised logoff exception: #{msg}")
|
34
|
+
@ss.should_receive(:log).with(anything)
|
35
|
+
set_test_data('test_db_storage',{},msg,'logoff error')
|
36
|
+
@ss.process_query
|
37
|
+
verify_result(@s.docname(:errors) => {'logoff-error'=>{'message'=>msg}})
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should hold on read on subsequent call of process" do
|
41
|
+
expected = {'1'=>@product1}
|
42
|
+
Store.put_data('test_db_storage',expected)
|
43
|
+
@ss.process_query
|
44
|
+
Store.put_data('test_db_storage',{'2'=>@product2})
|
45
|
+
@ss.process_query
|
46
|
+
verify_result(@s.docname(:md) => expected)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should read on every subsequent call of process" do
|
50
|
+
expected = {'2'=>@product2}
|
51
|
+
@s.poll_interval = 0
|
52
|
+
Store.put_data('test_db_storage',{'1'=>@product1})
|
53
|
+
@ss.process_query
|
54
|
+
Store.put_data('test_db_storage',expected)
|
55
|
+
@ss.process_query
|
56
|
+
verify_result(@s.docname(:md) => expected)
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should never call read on any call of process" do
|
60
|
+
@s.poll_interval = -1
|
61
|
+
Store.put_data('test_db_storage',{'1'=>@product1})
|
62
|
+
@ss.process_query
|
63
|
+
verify_result(@s.docname(:md) => {})
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "methods" do
|
67
|
+
|
68
|
+
it "should process source adapter" do
|
69
|
+
mock_metadata_method([SampleAdapter, SimpleAdapter]) do
|
70
|
+
expected = {'1'=>@product1,'2'=>@product2}
|
71
|
+
set_state('test_db_storage' => expected)
|
72
|
+
@ss.process_query
|
73
|
+
verify_result(@s.docname(:md) => expected,
|
74
|
+
@s.docname(:metadata) => "{\"foo\":\"bar\"}",
|
75
|
+
@s.docname(:metadata_sha1) => "a5e744d0164540d33b1d7ea616c28f2fa97e754a")
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should process source adapter schema" do
|
80
|
+
mock_schema_method([SampleAdapter]) do
|
81
|
+
expected = {'1'=>@product1,'2'=>@product2}
|
82
|
+
set_state('test_db_storage' => expected)
|
83
|
+
@ss.process_query
|
84
|
+
verify_result(@s.docname(:md) => expected)
|
85
|
+
JSON.parse(Store.get_value(@s.docname(:schema))).should == mock_schema
|
86
|
+
Store.get_value(@s.docname(:schema_sha1)) == get_sha1(mock_schema.to_json)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should process source adapter with stash" do
|
91
|
+
expected = {'1'=>@product1,'2'=>@product2}
|
92
|
+
set_state('test_db_storage' => expected)
|
93
|
+
#@ss.adapter.should_receive(:stash_result).once
|
94
|
+
@ss.process_query('stash_result' => true)
|
95
|
+
verify_result(@s.docname(:md) => expected,
|
96
|
+
@s.docname(:md_size) => expected.size.to_s)
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should process source adapter with pass_through set" do
|
100
|
+
expected = {'1'=>@product1,'2'=>@product2}
|
101
|
+
set_state('test_db_storage' => expected)
|
102
|
+
@s.pass_through = 'true'
|
103
|
+
@ss.process_query.should == expected
|
104
|
+
verify_result(@s.docname(:md) => {},
|
105
|
+
@s.docname(:md_size) => nil)
|
106
|
+
@s.pass_through = nil
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should call methods in source adapter" do
|
110
|
+
mock_metadata_method([SampleAdapter, SimpleAdapter]) do
|
111
|
+
expected = {'1'=>@product1,'2'=>@product2}
|
112
|
+
metadata = "{\"foo\":\"bar\"}"
|
113
|
+
@ss.adapter.should_receive(:login).once.with(no_args()).and_return(true)
|
114
|
+
@ss.adapter.should_receive(:metadata).once.with(no_args()).and_return(metadata)
|
115
|
+
@ss.adapter.should_receive(:query).once.with(no_args()).and_return(expected)
|
116
|
+
@ss.adapter.should_receive(:sync).once.with(no_args()).and_return(true)
|
117
|
+
@ss.adapter.should_receive(:logoff).once.with(no_args()).and_return(nil)
|
118
|
+
@ss.process_query
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
describe "create" do
|
123
|
+
it "should do create where adapter.create returns nil" do
|
124
|
+
set_state(@c.docname(:create) => {'2'=>@product2})
|
125
|
+
@ss.create(@c.id)
|
126
|
+
verify_result(@c.docname(:create_errors) => {},
|
127
|
+
@c.docname(:create_links) => {},
|
128
|
+
@c.docname(:create) => {})
|
129
|
+
end
|
130
|
+
|
131
|
+
it "should do create where adapter.create returns object link" do
|
132
|
+
@product4['link'] = 'test link'
|
133
|
+
set_state(@c.docname(:create) => {'4'=>@product4})
|
134
|
+
@ss.create(@c.id)
|
135
|
+
verify_result(@c.docname(:create_errors) => {},
|
136
|
+
@c.docname(:create_links) => {'4'=>{'l'=>'backend_id'}},
|
137
|
+
@c.docname(:create) => {})
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should raise exception on adapter.create" do
|
141
|
+
msg = "Error creating record"
|
142
|
+
data = add_error_object({'4'=>@product4,'2'=>@product2},msg)
|
143
|
+
set_state(@c.docname(:create) => data)
|
144
|
+
@ss.create(@c.id)
|
145
|
+
verify_result(@c.docname(:create_errors) =>
|
146
|
+
{"#{ERROR}-error"=>{"message"=>msg},ERROR=>data[ERROR]})
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
describe "update" do
|
151
|
+
it "should do update with no errors" do
|
152
|
+
set_state(@c.docname(:update) => {'4'=> { 'price' => '199.99' }})
|
153
|
+
@ss.update(@c.id)
|
154
|
+
verify_result(@c.docname(:update_errors) => {},
|
155
|
+
@c.docname(:update) => {})
|
156
|
+
end
|
157
|
+
|
158
|
+
it "should do update with errors" do
|
159
|
+
msg = "Error updating record"
|
160
|
+
data = add_error_object({'4'=> { 'price' => '199.99' }},msg)
|
161
|
+
set_state(@c.docname(:update) => data,
|
162
|
+
@c.docname(:cd) => { ERROR => { 'price' => '99.99' } }
|
163
|
+
)
|
164
|
+
@ss.update(@c.id)
|
165
|
+
verify_result(
|
166
|
+
@c.docname(:update_errors) =>
|
167
|
+
{"#{ERROR}-error"=>{"message"=>msg}, ERROR=>data[ERROR]},
|
168
|
+
@c.docname(:update) => {'4'=> { 'price' => '199.99'}},
|
169
|
+
@c.docname(:update_rollback) => {ERROR=>{"price"=>"99.99"}})
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
describe "delete" do
|
174
|
+
it "should do delete with no errors" do
|
175
|
+
set_state(@c.docname(:delete) => {'4'=>@product4},
|
176
|
+
@s.docname(:md) => {'4'=>@product4,'3'=>@product3},
|
177
|
+
@c.docname(:cd) => {'4'=>@product4,'3'=>@product3})
|
178
|
+
@ss.delete(@c.id)
|
179
|
+
verify_result(@c.docname(:delete_errors) => {},
|
180
|
+
@s.docname(:md) => {'3'=>@product3},
|
181
|
+
@c.docname(:cd) => {'3'=>@product3},
|
182
|
+
@c.docname(:delete) => {})
|
183
|
+
end
|
184
|
+
|
185
|
+
it "should do delete with errors" do
|
186
|
+
msg = "Error delete record"
|
187
|
+
data = add_error_object({'2'=>@product2},msg)
|
188
|
+
set_state(@c.docname(:delete) => data)
|
189
|
+
@ss.delete(@c.id)
|
190
|
+
|
191
|
+
# FIXME: Failed for jruby, ruby 1.9.2
|
192
|
+
# verify_result(@c.docname(:delete_errors) =>
|
193
|
+
# {"#{ERROR}-error"=>{"message"=>msg}, ERROR=>data[ERROR]},
|
194
|
+
# @c.docname(:delete) => {'2'=>@product2})
|
195
|
+
|
196
|
+
# Failure/Error: {"#{ERROR}-error"=>{"message"=>msg}, ERROR=>data[ERROR]},
|
197
|
+
# Verifying `client:application:testuser:b020a633ac2c43f7b0d30ef92dd43886:SampleAdapter:delete`
|
198
|
+
# expected: {"2"=>{"name"=>"G2", "brand"=>"Android", "price"=>"99.99"}}
|
199
|
+
# got: {} (using ==)
|
200
|
+
|
201
|
+
# Failure/Error: @c.docname(:delete) => {'2'=>@product2})
|
202
|
+
# Verifying `client:application:testuser:26a072a1da0d4bc18f69376e3229ab30:SampleAdapter:delete`
|
203
|
+
# expected: {"2"=>{"name"=>"G2", "brand"=>"Android", "price"=>"99.99"}}
|
204
|
+
# got: {} (using ==)
|
205
|
+
|
206
|
+
# But this one works everywhere !!!
|
207
|
+
verify_result(@c.docname(:delete_errors) => {"#{ERROR}-error"=>{"message"=>msg}, ERROR=>data[ERROR]})
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
describe "cud" do
|
212
|
+
it "should do process_cud" do
|
213
|
+
@ss.should_receive(:_auth_op).twice.and_return(true)
|
214
|
+
@ss.should_receive(:create).once.with(@c.id)
|
215
|
+
@ss.should_receive(:update).once.with(@c.id)
|
216
|
+
@ss.should_receive(:delete).once.with(@c.id)
|
217
|
+
@ss.process_cud(@c.id)
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
describe "query" do
|
222
|
+
it "should do query with no exception" do
|
223
|
+
verify_read_operation('query')
|
224
|
+
end
|
225
|
+
|
226
|
+
it "should do query with no exception pass through" do
|
227
|
+
verify_read_operation_pass_through('query')
|
228
|
+
end
|
229
|
+
|
230
|
+
it "should do query with exception raised" do
|
231
|
+
verify_read_operation_with_error('query')
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
describe "search" do
|
236
|
+
it "should do search with no exception" do
|
237
|
+
verify_read_operation('search')
|
238
|
+
end
|
239
|
+
|
240
|
+
it "should do search with no exception pass through" do
|
241
|
+
verify_read_operation_pass_through('search')
|
242
|
+
end
|
243
|
+
|
244
|
+
it "should do search with exception raised" do
|
245
|
+
verify_read_operation_with_error('search')
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
describe "app-level partitioning" do
|
250
|
+
it "should create app-level masterdoc with '__shared__' docname" do
|
251
|
+
@s1 = Source.load(@s_fields[:name],@s_params)
|
252
|
+
@s1.partition = :app
|
253
|
+
@ss1 = SourceSync.new(@s1)
|
254
|
+
expected = {'1'=>@product1,'2'=>@product2}
|
255
|
+
set_state('test_db_storage' => expected)
|
256
|
+
@ss1.process_query
|
257
|
+
verify_result("source:#{test_app_name}:__shared__:#{@s_fields[:name]}:md" => expected)
|
258
|
+
Store.db.keys("read_state:#{test_app_name}:__shared__*").sort.should ==
|
259
|
+
[ "read_state:#{test_app_name}:__shared__:SampleAdapter:refresh_time",
|
260
|
+
"read_state:#{test_app_name}:__shared__:SampleAdapter:rho__id"]
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
def verify_read_operation(operation)
|
265
|
+
expected = {'1'=>@product1,'2'=>@product2}
|
266
|
+
set_test_data('test_db_storage',expected)
|
267
|
+
Store.put_data(@s.docname(:errors),
|
268
|
+
{"#{operation}-error"=>{'message'=>'failed'}},true)
|
269
|
+
if operation == 'query'
|
270
|
+
@ss.read.should == true
|
271
|
+
verify_result(@s.docname(:md) => expected,
|
272
|
+
@s.docname(:errors) => {})
|
273
|
+
else
|
274
|
+
@ss.search(@c.id).should == true
|
275
|
+
verify_result(@c.docname(:search) => expected,
|
276
|
+
@c.docname(:search_errors) => {})
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
def verify_read_operation_pass_through(operation)
|
281
|
+
expected = {'1'=>@product1,'2'=>@product2}
|
282
|
+
set_test_data('test_db_storage',expected)
|
283
|
+
Store.put_data(@s.docname(:errors),
|
284
|
+
{"#{operation}-error"=>{'message'=>'failed'}},true)
|
285
|
+
@s.pass_through = 'true'
|
286
|
+
if operation == 'query'
|
287
|
+
@ss.read.should == expected
|
288
|
+
verify_result(@s.docname(:md) => {},
|
289
|
+
@s.docname(:errors) => {})
|
290
|
+
else
|
291
|
+
@ss.search(@c.id).should == expected
|
292
|
+
verify_result(@c.docname(:search) => {},
|
293
|
+
@c.docname(:search_errors) => {})
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
297
|
+
def verify_read_operation_with_error(operation)
|
298
|
+
msg = "Error during #{operation}"
|
299
|
+
@ss.should_receive(:log).with("SourceAdapter raised #{operation} exception: #{msg}")
|
300
|
+
@ss.should_receive(:log).with(anything)
|
301
|
+
set_test_data('test_db_storage',{},msg,"#{operation} error")
|
302
|
+
if operation == 'query'
|
303
|
+
@ss.read.should == true
|
304
|
+
verify_result(@s.docname(:md) => {},
|
305
|
+
@s.docname(:errors) => {'query-error'=>{'message'=>msg}})
|
306
|
+
else
|
307
|
+
@ss.search(@c.id).should == true
|
308
|
+
verify_result(@c.docname(:search) => {},
|
309
|
+
@c.docname(:search_errors) => {'search-error'=>{'message'=>msg}})
|
310
|
+
end
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
314
|
+
it "should enqueue process_cud SourceJob" do
|
315
|
+
@s.cud_queue = :cud
|
316
|
+
@ss.process_cud(@c.id)
|
317
|
+
Resque.peek(:cud).should == {"args"=>
|
318
|
+
["cud", @s.name, @a.name, @u.login, @c.id, nil], "class"=>"Rhoconnect::SourceJob"}
|
319
|
+
end
|
320
|
+
|
321
|
+
it "should enqueue process_query SourceJob" do
|
322
|
+
@s.query_queue = :abc
|
323
|
+
@ss.process_query({'foo'=>'bar'})
|
324
|
+
Resque.peek(:abc).should == {"args"=>
|
325
|
+
["query", @s.name, @a.name, @u.login, nil, {'foo'=>'bar'}], "class"=>"Rhoconnect::SourceJob"}
|
326
|
+
end
|
327
|
+
end
|
328
|
+
end
|
data/spec/spec.opts
ADDED