mirror of
https://github.com/abapGit/abapGit.git
synced 2025-05-01 12:20:51 +08:00
adjust persistence settings
This commit is contained in:
parent
cdafb2445d
commit
7d8c419893
|
@ -1426,11 +1426,18 @@ CLASS lcl_settings DEFINITION FINAL.
|
|||
METHODS get_proxy_port
|
||||
RETURNING
|
||||
VALUE(rv_port) TYPE string.
|
||||
METHODS set_run_critical_tests
|
||||
IMPORTING
|
||||
iv_run TYPE abap_bool.
|
||||
METHODS
|
||||
get_run_critical_tests
|
||||
RETURNING VALUE(rv_run) TYPE abap_bool.
|
||||
PROTECTED SECTION.
|
||||
|
||||
PRIVATE SECTION.
|
||||
DATA mv_proxy_url TYPE string.
|
||||
DATA mv_proxy_port TYPE string.
|
||||
DATA mv_run_critical_tests TYPE abap_bool.
|
||||
|
||||
|
||||
ENDCLASS.
|
||||
|
@ -1454,6 +1461,14 @@ CLASS lcl_settings IMPLEMENTATION.
|
|||
rv_port = mv_proxy_port.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD set_run_critical_tests.
|
||||
mv_run_critical_tests = iv_run.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD get_run_critical_tests.
|
||||
rv_run = mv_run_critical_tests.
|
||||
ENDMETHOD.
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
|
@ -1488,10 +1503,18 @@ CLASS lcl_persistence_settings IMPLEMENTATION.
|
|||
iv_type = 'SETTINGS'
|
||||
iv_value = 'PROXY_PORT'
|
||||
iv_data = io_settings->get_proxy_port( ) ).
|
||||
|
||||
lcl_app=>db( )->modify(
|
||||
iv_type = 'SETTINGS'
|
||||
iv_value = 'CRIT_TESTS'
|
||||
iv_data = io_settings->get_run_critical_tests( ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD read.
|
||||
DATA: lv_critical_tests_as_string TYPE string,
|
||||
lv_critical_tests_as_boolean TYPE abap_bool.
|
||||
|
||||
CREATE OBJECT ro_settings.
|
||||
TRY.
|
||||
ro_settings->set_proxy_url(
|
||||
|
@ -1511,22 +1534,37 @@ CLASS lcl_persistence_settings IMPLEMENTATION.
|
|||
CATCH lcx_not_found.
|
||||
ro_settings->set_proxy_port( '' ).
|
||||
ENDTRY.
|
||||
TRY.
|
||||
lv_critical_tests_as_boolean = lv_critical_tests_as_string = lcl_app=>db( )->read(
|
||||
iv_type = 'SETTINGS'
|
||||
iv_value = 'CRIT_TESTS'
|
||||
).
|
||||
ro_settings->set_run_critical_tests( lv_critical_tests_as_boolean ).
|
||||
CATCH lcx_not_found.
|
||||
ro_settings->set_run_critical_tests( abap_false ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
CLASS ltcl_persistence_settings DEFINITION FINAL FOR TESTING
|
||||
DURATION SHORT
|
||||
RISK LEVEL HARMLESS.
|
||||
RISK LEVEL DANGEROUS.
|
||||
|
||||
PRIVATE SECTION.
|
||||
METHODS:
|
||||
setup,
|
||||
modify_settings_proxy_url FOR TESTING,
|
||||
modify_settings_proxy_port FOR TESTING,
|
||||
read_settings FOR TESTING,
|
||||
read_not_found_url FOR TESTING,
|
||||
read_not_found_port FOR TESTING.
|
||||
clear_settings_database,
|
||||
"Proxy
|
||||
modify_settings_proxy_url FOR TESTING RAISING cx_static_check,
|
||||
modify_settings_proxy_port FOR TESTING RAISING cx_static_check,
|
||||
read_proxy_settings FOR TESTING RAISING cx_static_check,
|
||||
read_not_found_url FOR TESTING RAISING cx_static_check,
|
||||
read_not_found_port FOR TESTING RAISING cx_static_check,
|
||||
"Run critical tests
|
||||
modify_run_critical_tests FOR TESTING RAISING cx_static_check,
|
||||
read_run_critical_tests FOR TESTING RAISING cx_static_check,
|
||||
read_not_found_critical_tests FOR TESTING RAISING cx_static_check.
|
||||
DATA:
|
||||
mo_persistence_settings TYPE REF TO lcl_persistence_settings,
|
||||
mo_settings TYPE REF TO lcl_settings.
|
||||
|
@ -1535,13 +1573,15 @@ ENDCLASS.
|
|||
CLASS ltcl_persistence_settings IMPLEMENTATION.
|
||||
METHOD setup.
|
||||
CREATE OBJECT mo_persistence_settings.
|
||||
CREATE OBJECT mo_settings.
|
||||
clear_settings_database( ).
|
||||
|
||||
"These tests may fail if you are locking the entries (e.g. the ZABAPGIT transaction is open)
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD modify_settings_proxy_url.
|
||||
DATA lv_proxy_url TYPE string.
|
||||
TRY.
|
||||
CREATE OBJECT mo_settings.
|
||||
|
||||
mo_settings->set_proxy_url( 'http://proxy' ).
|
||||
|
||||
mo_persistence_settings->modify( mo_settings ).
|
||||
|
@ -1553,15 +1593,10 @@ CLASS ltcl_persistence_settings IMPLEMENTATION.
|
|||
cl_abap_unit_assert=>assert_equals(
|
||||
act = lv_proxy_url
|
||||
exp = 'http://proxy' ).
|
||||
CATCH cx_root.
|
||||
cl_abap_unit_assert=>fail( 'Unexpected exception' ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD modify_settings_proxy_port.
|
||||
DATA lv_proxy_port TYPE string.
|
||||
TRY.
|
||||
CREATE OBJECT mo_settings.
|
||||
mo_settings->set_proxy_port( '8080' ).
|
||||
|
||||
mo_persistence_settings->modify( mo_settings ).
|
||||
|
@ -1573,13 +1608,9 @@ CLASS ltcl_persistence_settings IMPLEMENTATION.
|
|||
cl_abap_unit_assert=>assert_equals(
|
||||
act = lv_proxy_port
|
||||
exp = '8080' ).
|
||||
CATCH cx_root.
|
||||
cl_abap_unit_assert=>fail( 'Unexpected exception' ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD read_settings.
|
||||
TRY.
|
||||
METHOD read_proxy_settings.
|
||||
lcl_app=>db( )->modify(
|
||||
iv_type = 'SETTINGS'
|
||||
iv_value = 'PROXY_URL'
|
||||
|
@ -1598,50 +1629,84 @@ CLASS ltcl_persistence_settings IMPLEMENTATION.
|
|||
cl_abap_unit_assert=>assert_equals(
|
||||
act = mo_settings->get_proxy_port( )
|
||||
exp = '1000' ).
|
||||
CATCH cx_root.
|
||||
cl_abap_unit_assert=>fail( 'Unexpected exception' ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD read_not_found_port.
|
||||
TRY.
|
||||
lcl_app=>db( )->modify(
|
||||
iv_type = 'SETTINGS'
|
||||
iv_value = 'PROXY_URL'
|
||||
iv_data = 'A_URL' ).
|
||||
lcl_app=>db( )->modify(
|
||||
iv_type = 'SETTINGS'
|
||||
iv_value = 'PROXY_PORT'
|
||||
iv_data = '' ).
|
||||
|
||||
mo_settings = mo_persistence_settings->read( ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
act = mo_settings->get_proxy_port( )
|
||||
exp = '' ).
|
||||
CATCH cx_root.
|
||||
cl_abap_unit_assert=>fail( 'Unexpected exception' ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD read_not_found_url.
|
||||
TRY.
|
||||
lcl_app=>db( )->modify(
|
||||
iv_type = 'SETTINGS'
|
||||
iv_value = 'PROXY_PORT'
|
||||
iv_data = '1000' ).
|
||||
lcl_app=>db( )->modify(
|
||||
iv_type = 'SETTINGS'
|
||||
iv_value = 'PROXY_URL'
|
||||
iv_data = '' ).
|
||||
|
||||
mo_settings = mo_persistence_settings->read( ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
act = mo_settings->get_proxy_url( )
|
||||
exp = '' ).
|
||||
CATCH cx_root.
|
||||
cl_abap_unit_assert=>fail( 'Unexpected exception' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD modify_run_critical_tests.
|
||||
DATA lv_run_critical_tests TYPE abap_bool.
|
||||
mo_settings->set_run_critical_tests( abap_true ).
|
||||
|
||||
mo_persistence_settings->modify( mo_settings ).
|
||||
|
||||
lv_run_critical_tests = lcl_app=>db( )->read(
|
||||
iv_type = 'SETTINGS'
|
||||
iv_value = 'CRIT_TESTS' ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
act = lv_run_critical_tests
|
||||
exp = abap_true ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD read_run_critical_tests.
|
||||
lcl_app=>db( )->modify(
|
||||
iv_type = 'SETTINGS'
|
||||
iv_value = 'CRIT_TESTS'
|
||||
iv_data = 'X' ).
|
||||
mo_settings = mo_persistence_settings->read( ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
act = mo_settings->get_run_critical_tests( )
|
||||
exp = abap_true ).
|
||||
ENDMETHOD.
|
||||
METHOD read_not_found_critical_tests.
|
||||
mo_settings = mo_persistence_settings->read( ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
act = mo_settings->get_run_critical_tests( )
|
||||
exp = abap_false ).
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD clear_settings_database.
|
||||
|
||||
TRY.
|
||||
lcl_app=>db( )->delete(
|
||||
iv_type = 'SETTINGS'
|
||||
iv_value = 'PROXY_URL' ).
|
||||
CATCH cx_static_check.
|
||||
"If entry didn't exist, that's okay
|
||||
ENDTRY.
|
||||
TRY.
|
||||
lcl_app=>db( )->delete(
|
||||
iv_type = 'SETTINGS'
|
||||
iv_value = 'PROXY_PORT' ).
|
||||
CATCH cx_static_check.
|
||||
"If entry didn't exist, that's okay
|
||||
ENDTRY.
|
||||
TRY.
|
||||
lcl_app=>db( )->delete(
|
||||
iv_type = 'SETTINGS'
|
||||
iv_value = 'CRIT_TESTS' ).
|
||||
CATCH cx_static_check.
|
||||
"If entry didn't exist, that's okay
|
||||
ENDTRY.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
ENDCLASS.
|
Loading…
Reference in New Issue
Block a user