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,168 @@
|
|
1
|
+
# When shared examples are called as
|
2
|
+
# it_behaves_like "SharedRhoconnectHelper", :rhoconnect_data => false
|
3
|
+
# then :rhoconnect_data group (@product1, ..., @data) skipped.
|
4
|
+
# To enable this group call examples as
|
5
|
+
# it_behaves_like "SharedRhoconnectHelper", :rhoconnect_data => true
|
6
|
+
shared_examples_for "SharedRhoconnectHelper" do |params|
|
7
|
+
include TestHelpers
|
8
|
+
# "TestappHelper"
|
9
|
+
let(:test_app_name) { 'application' }
|
10
|
+
# "RhoconnectHelper"
|
11
|
+
before(:all) do
|
12
|
+
Rhoconnect.bootstrap(get_testapp_path) do |rhoconnect|
|
13
|
+
rhoconnect.vendor_directory = File.join(File.dirname(__FILE__), '..', '..', 'vendor')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
before(:each) do
|
18
|
+
# "RhoconnectHelper"
|
19
|
+
Store.create
|
20
|
+
Store.db.flushdb
|
21
|
+
|
22
|
+
# "DBObjectsHelper"
|
23
|
+
@a_fields = { :name => test_app_name }
|
24
|
+
@a = (App.load(test_app_name) || App.create(@a_fields))
|
25
|
+
@u_fields = {:login => 'testuser'}
|
26
|
+
@u = User.create(@u_fields)
|
27
|
+
@u.password = 'testpass'
|
28
|
+
@c_fields = {
|
29
|
+
:device_type => 'Apple',
|
30
|
+
:device_pin => 'abcd',
|
31
|
+
:device_port => '3333',
|
32
|
+
:user_id => @u.id,
|
33
|
+
:app_id => @a.id
|
34
|
+
}
|
35
|
+
@s_fields = {
|
36
|
+
:name => 'SampleAdapter',
|
37
|
+
:url => 'http://example.com',
|
38
|
+
:login => 'testuser',
|
39
|
+
:password => 'testpass',
|
40
|
+
}
|
41
|
+
@s1_fields = {
|
42
|
+
:name => 'FixedSchemaAdapter',
|
43
|
+
:url => 'http://example.com',
|
44
|
+
:login => 'testuser',
|
45
|
+
:password => 'testpass',
|
46
|
+
}
|
47
|
+
@s_params = {
|
48
|
+
:user_id => @u.id,
|
49
|
+
:app_id => @a.id
|
50
|
+
}
|
51
|
+
@c = Client.create(@c_fields,{:source_name => @s_fields[:name]})
|
52
|
+
@s = Source.create(@s_fields,@s_params)
|
53
|
+
@s1 = Source.create(@s1_fields,@s_params)
|
54
|
+
@s2 = Source.create({:name=> 'Product2'},@s_params)
|
55
|
+
@s3 = Source.create({:name=> 'SimpleAdapter',:partition_type=> 'app'},@s_params)
|
56
|
+
@s1.belongs_to = [{'brand' => 'SampleAdapter'}].to_json
|
57
|
+
config = Rhoconnect.source_config["sources"]['FixedSchemaAdapter']
|
58
|
+
@s1.update(config)
|
59
|
+
@r = @s.read_state
|
60
|
+
@a.sources << @s.id
|
61
|
+
@a.sources << @s1.id
|
62
|
+
@a.sources << @s3.id
|
63
|
+
Source.update_associations(@a.sources)
|
64
|
+
@a.users << @u.id
|
65
|
+
|
66
|
+
# "RhoconnectDataHelper"
|
67
|
+
if params && params[:rhoconnect_data]
|
68
|
+
@source = 'Product'
|
69
|
+
@user_id = 5
|
70
|
+
@client_id = 1
|
71
|
+
|
72
|
+
@product1 = { 'name' => 'iPhone', 'brand' => 'Apple', 'price' => '199.99' }
|
73
|
+
@product2 = { 'name' => 'G2', 'brand' => 'Android', 'price' => '99.99' }
|
74
|
+
@product3 = { 'name' => 'Fuze', 'brand' => 'HTC', 'price' => '299.99' }
|
75
|
+
@product4 = { 'name' => 'Droid', 'brand' => 'Android', 'price' => '249.99'}
|
76
|
+
|
77
|
+
@data = {'1'=>@product1,'2'=>@product2,'3'=>@product3}
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
shared_examples_for "BenchSpecHelper" do
|
83
|
+
before(:each) do
|
84
|
+
Store.create
|
85
|
+
Store.db.flushdb
|
86
|
+
|
87
|
+
@product1 = { 'name' => 'iPhone', 'brand' => 'Apple', 'price' => '199.99' }
|
88
|
+
@product2 = { 'name' => 'G2', 'brand' => 'Android', 'price' => '99.99' }
|
89
|
+
@product3 = { 'name' => 'Fuze', 'brand' => 'HTC', 'price' => '299.99' }
|
90
|
+
@product4 = { 'name' => 'Droid', 'brand' => 'Android', 'price' => '249.99'}
|
91
|
+
|
92
|
+
@data = {'1'=>@product1,'2'=>@product2,'3'=>@product3}
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
shared_examples_for "ApiHelper" do
|
97
|
+
include Rack::Test::Methods
|
98
|
+
include Rhoconnect
|
99
|
+
include TestHelpers
|
100
|
+
|
101
|
+
let(:test_app_name) { 'application' }
|
102
|
+
|
103
|
+
before(:each) do
|
104
|
+
Store.create
|
105
|
+
Store.db.flushdb
|
106
|
+
|
107
|
+
require File.join(get_testapp_path, test_app_name)
|
108
|
+
Rhoconnect.bootstrap(get_testapp_path) do |rhoconnect|
|
109
|
+
rhoconnect.vendor_directory = File.join(rhoconnect.base_directory,'..','..','..','vendor')
|
110
|
+
end
|
111
|
+
Rhoconnect::Server.set :environment, :test
|
112
|
+
Rhoconnect::Server.set :run, false
|
113
|
+
Rhoconnect::Server.set :secret, "secure!"
|
114
|
+
@api_token = User.load('rhoadmin').token_id
|
115
|
+
|
116
|
+
@a_fields = { :name => test_app_name }
|
117
|
+
@a = (App.load(test_app_name) || App.create(@a_fields))
|
118
|
+
@u_fields = {:login => 'testuser'}
|
119
|
+
@u = User.create(@u_fields)
|
120
|
+
@u.password = 'testpass'
|
121
|
+
@c_fields = {
|
122
|
+
:device_type => 'Apple',
|
123
|
+
:device_pin => 'abcd',
|
124
|
+
:device_port => '3333',
|
125
|
+
:user_id => @u.id,
|
126
|
+
:app_id => @a.id
|
127
|
+
}
|
128
|
+
@s_fields = {
|
129
|
+
:name => 'SampleAdapter',
|
130
|
+
:url => 'http://example.com',
|
131
|
+
:login => 'testuser',
|
132
|
+
:password => 'testpass',
|
133
|
+
}
|
134
|
+
@s1_fields = {
|
135
|
+
:name => 'FixedSchemaAdapter',
|
136
|
+
:url => 'http://example.com',
|
137
|
+
:login => 'testuser',
|
138
|
+
:password => 'testpass',
|
139
|
+
}
|
140
|
+
@s_params = {
|
141
|
+
:user_id => @u.id,
|
142
|
+
:app_id => @a.id
|
143
|
+
}
|
144
|
+
@c = Client.create(@c_fields,{:source_name => @s_fields[:name]})
|
145
|
+
@s = Source.create(@s_fields,@s_params)
|
146
|
+
@s1 = Source.create(@s1_fields,@s_params)
|
147
|
+
@s2 = Source.create({:name=> 'Product2'},@s_params)
|
148
|
+
@s1.belongs_to = [{'brand' => 'SampleAdapter'}].to_json
|
149
|
+
config = Rhoconnect.source_config["sources"]['FixedSchemaAdapter']
|
150
|
+
@s1.update(config)
|
151
|
+
@r = @s.read_state
|
152
|
+
@a.sources << @s.id
|
153
|
+
@a.sources << @s1.id
|
154
|
+
Source.update_associations(@a.sources)
|
155
|
+
@a.users << @u.id
|
156
|
+
|
157
|
+
@source = 'Product'
|
158
|
+
@user_id = 5
|
159
|
+
@client_id = 1
|
160
|
+
|
161
|
+
@product1 = { 'name' => 'iPhone', 'brand' => 'Apple', 'price' => '199.99' }
|
162
|
+
@product2 = { 'name' => 'G2', 'brand' => 'Android', 'price' => '99.99' }
|
163
|
+
@product3 = { 'name' => 'Fuze', 'brand' => 'HTC', 'price' => '299.99' }
|
164
|
+
@product4 = { 'name' => 'Droid', 'brand' => 'Android', 'price' => '249.99'}
|
165
|
+
|
166
|
+
@data = {'1'=>@product1,'2'=>@product2,'3'=>@product3}
|
167
|
+
end
|
168
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__),'spec_helper')
|
2
|
+
require File.join(File.dirname(__FILE__), 'support', 'shared_examples')
|
3
|
+
|
4
|
+
describe "Sync Server States" do
|
5
|
+
it_behaves_like "SharedRhoconnectHelper", :rhoconnect_data => true do
|
6
|
+
before(:each) do
|
7
|
+
@s = Source.load(@s_fields[:name],@s_params)
|
8
|
+
@cs = ClientSync.new(@s,@c,2)
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "client creates objects" do
|
12
|
+
|
13
|
+
it "should create object and create link for client" do
|
14
|
+
@product1['link'] = 'temp1'
|
15
|
+
params = {'create'=>{'1'=>@product1}}
|
16
|
+
backend_data = {'backend_id'=>@product1}
|
17
|
+
set_state(@cs.client.docname(:cd_size) => 0,
|
18
|
+
@s.docname(:md_size) => 0)
|
19
|
+
@s.read_state.refresh_time = Time.now.to_i + 3600
|
20
|
+
@cs.receive_cud(params)
|
21
|
+
verify_result(@c.docname(:create) => {},
|
22
|
+
@c.docname(:cd_size) => "1",
|
23
|
+
@s.docname(:md_size) => "1",
|
24
|
+
@c.docname(:cd) => backend_data,
|
25
|
+
@c.docname(:create_links) => {'1'=>{'l'=>'backend_id'}},
|
26
|
+
@s.docname(:md) => backend_data)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should create object and send link to client" do
|
30
|
+
@product1['link'] = 'temp1'
|
31
|
+
params = {'create'=>{'1'=>@product1}}
|
32
|
+
backend_data = {'backend_id'=>@product1}
|
33
|
+
set_state(@cs.client.docname(:cd_size) => 0,
|
34
|
+
@s.docname(:md_size) => 0)
|
35
|
+
@s.read_state.refresh_time = Time.now.to_i + 3600
|
36
|
+
@cs.receive_cud(params)
|
37
|
+
verify_result(@c.docname(:create) => {},
|
38
|
+
@c.docname(:cd_size) => "1",
|
39
|
+
@s.docname(:md_size) => "1",
|
40
|
+
@c.docname(:cd) => backend_data,
|
41
|
+
@c.docname(:create_links) => {'1'=>{'l'=>'backend_id'}},
|
42
|
+
@s.docname(:md) => backend_data)
|
43
|
+
res = @cs.send_cud
|
44
|
+
res.should == [{"version"=>3}, {"token"=>res[1]['token']},
|
45
|
+
{"count"=>0}, {"progress_count"=>1}, {"total_count"=>1},
|
46
|
+
{"links"=> {'1'=>{'l'=>'backend_id'}}}]
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "client deletes objects" do
|
52
|
+
it "should delete object" do
|
53
|
+
params = {'delete'=>{'1'=>@product1}}
|
54
|
+
data = {'1'=>@product1,'2'=>@product2,'3'=>@product3}
|
55
|
+
expected = {'2'=>@product2,'3'=>@product3}
|
56
|
+
set_state(@cs.client.docname(:cd) => data,
|
57
|
+
@cs.client.docname(:cd_size) => data.size,
|
58
|
+
@s.docname(:md) => data,
|
59
|
+
@s.docname(:md_size) => data.size)
|
60
|
+
@s.read_state.refresh_time = Time.now.to_i + 3600
|
61
|
+
@cs.receive_cud(params)
|
62
|
+
verify_result(@cs.client.docname(:delete) => {},
|
63
|
+
@cs.client.docname(:cd) => expected,
|
64
|
+
@s.docname(:md) => expected,
|
65
|
+
@cs.client.docname(:delete_page) => {},
|
66
|
+
@cs.client.docname(:cd_size) => "2",
|
67
|
+
@s.docname(:md_size) => "2",
|
68
|
+
'test_delete_storage' => {'1'=>@product1})
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
require 'rhoconnect/test_methods'
|
2
|
+
require File.join(File.dirname(__FILE__),'spec_helper')
|
3
|
+
require File.join(File.dirname(__FILE__), 'support', 'shared_examples')
|
4
|
+
|
5
|
+
describe "TestMethods" do
|
6
|
+
# The module we're testing
|
7
|
+
include Rhoconnect::TestMethods
|
8
|
+
|
9
|
+
it_behaves_like "SharedRhoconnectHelper", :rhoconnect_data => true do
|
10
|
+
before(:each) do
|
11
|
+
Rhoconnect.bootstrap(get_testapp_path)
|
12
|
+
setup_test_for(SampleAdapter,'user1')
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:schema_string) { "{\"property\":{\"brand\":\"string\",\"name\":\"string\"},\"version\":\"1.0\"}" }
|
16
|
+
let(:foo_bar) { "{\"foo\":\"bar\"}" }
|
17
|
+
|
18
|
+
it "should setup_test_for an adapter and user" do
|
19
|
+
@u.is_a?(User).should == true
|
20
|
+
@s.is_a?(Source).should == true
|
21
|
+
@ss.is_a?(SourceSync).should == true
|
22
|
+
@ss.adapter.is_a?(SampleAdapter).should == true
|
23
|
+
@u.login.should == 'user1'
|
24
|
+
@s.name.should == 'SampleAdapter'
|
25
|
+
@c.id.size.should == 32
|
26
|
+
@c.device_pin.should == 'abcd'
|
27
|
+
@c.device_port.should == '3333'
|
28
|
+
@c.device_type.should == 'Apple'
|
29
|
+
@c.user_id.should == 'user1'
|
30
|
+
@c.app_id.should == 'application'
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should include test_schema helper" do
|
34
|
+
mock_schema_method([SampleAdapter]) do
|
35
|
+
expected = {'1'=>@product1,'2'=>@product2}
|
36
|
+
set_state('test_db_storage' => expected)
|
37
|
+
@ss.process_query
|
38
|
+
JSON.parse(test_schema).should == JSON.parse(schema_string)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should include test_metadata helper" do
|
43
|
+
mock_metadata_method([SampleAdapter]) do
|
44
|
+
expected = {'1'=>@product1,'2'=>@product2}
|
45
|
+
set_state('test_db_storage' => expected)
|
46
|
+
@ss.process_query
|
47
|
+
JSON.parse(test_metadata).should == JSON.parse(foo_bar)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should include test_query helper" do
|
52
|
+
expected = {'1'=>@product1,'2'=>@product2}
|
53
|
+
set_state('test_db_storage' => expected)
|
54
|
+
test_query.should == expected
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should include test_query helper when pass through" do
|
58
|
+
expected = {'1'=>@product1,'2'=>@product2}
|
59
|
+
set_state('test_db_storage' => expected)
|
60
|
+
@s.pass_through = 'true'
|
61
|
+
test_query.should == expected
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should include query_errors helper" do
|
65
|
+
expected = {"query-error"=>{'message'=>'failed'}}
|
66
|
+
set_state(@s.docname(:errors) => expected)
|
67
|
+
query_errors.should == expected
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should include test_create helper" do
|
71
|
+
@product4['link'] = 'test link'
|
72
|
+
test_create(@product4).should == 'backend_id'
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should include test_create helper when pass through" do
|
76
|
+
@s.pass_through = 'true'
|
77
|
+
test_create(@product4).should == {'processed' => ["temp-id"]}.to_json
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should include create_errors helper" do
|
81
|
+
expected = {"create-error"=>{'message'=>'failed'}}
|
82
|
+
set_state(@c.docname(:create_errors) => expected)
|
83
|
+
create_errors.should == expected
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should include test_update helper" do
|
87
|
+
record = {'4'=> { 'price' => '199.99' }}
|
88
|
+
test_update(record)
|
89
|
+
verify_result(@c.docname(:update) => {})
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should include test_update helper when pass through" do
|
93
|
+
record = {'4'=> { 'price' => '199.99' }}
|
94
|
+
@s.pass_through = 'true'
|
95
|
+
test_update(record).should == {'processed' => ["4"]}.to_json
|
96
|
+
verify_result(@c.docname(:update) => {})
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should include update_errors helper" do
|
100
|
+
expected = {"update-error"=>{'message'=>'failed'}}
|
101
|
+
set_state(@c.docname(:update_errors) => expected)
|
102
|
+
update_errors.should == expected
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should include test_delete helper" do
|
106
|
+
record = {'4'=> { 'price' => '199.99' }}
|
107
|
+
test_delete(record)
|
108
|
+
verify_result(@c.docname(:delete) => {})
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should include test_delete helper when pass through" do
|
112
|
+
record = {'4'=> { 'price' => '199.99' }}
|
113
|
+
@s.pass_through = 'true'
|
114
|
+
test_delete(record).should == {'processed' => ["4"]}.to_json
|
115
|
+
verify_result(@c.docname(:delete) => {})
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should include delete_errors helper" do
|
119
|
+
expected = {"delete-error"=>{'message'=>'failed'}}
|
120
|
+
set_state(@c.docname(:delete_errors) => expected)
|
121
|
+
delete_errors.should == expected
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should include md helper" do
|
125
|
+
set_state(@s.docname(:md) => @data)
|
126
|
+
md.should == @data
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should include cd helper" do
|
130
|
+
set_state(@c.docname(:cd) => @data)
|
131
|
+
cd.should == @data
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|