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
|
METHODS get_proxy_port
|
||||||
RETURNING
|
RETURNING
|
||||||
VALUE(rv_port) TYPE string.
|
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.
|
PROTECTED SECTION.
|
||||||
|
|
||||||
PRIVATE SECTION.
|
PRIVATE SECTION.
|
||||||
DATA mv_proxy_url TYPE string.
|
DATA mv_proxy_url TYPE string.
|
||||||
DATA mv_proxy_port TYPE string.
|
DATA mv_proxy_port TYPE string.
|
||||||
|
DATA mv_run_critical_tests TYPE abap_bool.
|
||||||
|
|
||||||
|
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
@ -1454,6 +1461,14 @@ CLASS lcl_settings IMPLEMENTATION.
|
||||||
rv_port = mv_proxy_port.
|
rv_port = mv_proxy_port.
|
||||||
ENDMETHOD.
|
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.
|
ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
|
@ -1488,10 +1503,18 @@ CLASS lcl_persistence_settings IMPLEMENTATION.
|
||||||
iv_type = 'SETTINGS'
|
iv_type = 'SETTINGS'
|
||||||
iv_value = 'PROXY_PORT'
|
iv_value = 'PROXY_PORT'
|
||||||
iv_data = io_settings->get_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.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
METHOD read.
|
METHOD read.
|
||||||
|
DATA: lv_critical_tests_as_string TYPE string,
|
||||||
|
lv_critical_tests_as_boolean TYPE abap_bool.
|
||||||
|
|
||||||
CREATE OBJECT ro_settings.
|
CREATE OBJECT ro_settings.
|
||||||
TRY.
|
TRY.
|
||||||
ro_settings->set_proxy_url(
|
ro_settings->set_proxy_url(
|
||||||
|
@ -1511,22 +1534,37 @@ CLASS lcl_persistence_settings IMPLEMENTATION.
|
||||||
CATCH lcx_not_found.
|
CATCH lcx_not_found.
|
||||||
ro_settings->set_proxy_port( '' ).
|
ro_settings->set_proxy_port( '' ).
|
||||||
ENDTRY.
|
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.
|
ENDMETHOD.
|
||||||
|
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
||||||
CLASS ltcl_persistence_settings DEFINITION FINAL FOR TESTING
|
CLASS ltcl_persistence_settings DEFINITION FINAL FOR TESTING
|
||||||
DURATION SHORT
|
DURATION SHORT
|
||||||
RISK LEVEL HARMLESS.
|
RISK LEVEL DANGEROUS.
|
||||||
|
|
||||||
PRIVATE SECTION.
|
PRIVATE SECTION.
|
||||||
METHODS:
|
METHODS:
|
||||||
setup,
|
setup,
|
||||||
modify_settings_proxy_url FOR TESTING,
|
clear_settings_database,
|
||||||
modify_settings_proxy_port FOR TESTING,
|
"Proxy
|
||||||
read_settings FOR TESTING,
|
modify_settings_proxy_url FOR TESTING RAISING cx_static_check,
|
||||||
read_not_found_url FOR TESTING,
|
modify_settings_proxy_port FOR TESTING RAISING cx_static_check,
|
||||||
read_not_found_port FOR TESTING.
|
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:
|
DATA:
|
||||||
mo_persistence_settings TYPE REF TO lcl_persistence_settings,
|
mo_persistence_settings TYPE REF TO lcl_persistence_settings,
|
||||||
mo_settings TYPE REF TO lcl_settings.
|
mo_settings TYPE REF TO lcl_settings.
|
||||||
|
@ -1535,13 +1573,15 @@ ENDCLASS.
|
||||||
CLASS ltcl_persistence_settings IMPLEMENTATION.
|
CLASS ltcl_persistence_settings IMPLEMENTATION.
|
||||||
METHOD setup.
|
METHOD setup.
|
||||||
CREATE OBJECT mo_persistence_settings.
|
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)
|
"These tests may fail if you are locking the entries (e.g. the ZABAPGIT transaction is open)
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
METHOD modify_settings_proxy_url.
|
METHOD modify_settings_proxy_url.
|
||||||
DATA lv_proxy_url TYPE string.
|
DATA lv_proxy_url TYPE string.
|
||||||
TRY.
|
|
||||||
CREATE OBJECT mo_settings.
|
|
||||||
mo_settings->set_proxy_url( 'http://proxy' ).
|
mo_settings->set_proxy_url( 'http://proxy' ).
|
||||||
|
|
||||||
mo_persistence_settings->modify( mo_settings ).
|
mo_persistence_settings->modify( mo_settings ).
|
||||||
|
@ -1553,15 +1593,10 @@ CLASS ltcl_persistence_settings IMPLEMENTATION.
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = lv_proxy_url
|
act = lv_proxy_url
|
||||||
exp = 'http://proxy' ).
|
exp = 'http://proxy' ).
|
||||||
CATCH cx_root.
|
|
||||||
cl_abap_unit_assert=>fail( 'Unexpected exception' ).
|
|
||||||
ENDTRY.
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
METHOD modify_settings_proxy_port.
|
METHOD modify_settings_proxy_port.
|
||||||
DATA lv_proxy_port TYPE string.
|
DATA lv_proxy_port TYPE string.
|
||||||
TRY.
|
|
||||||
CREATE OBJECT mo_settings.
|
|
||||||
mo_settings->set_proxy_port( '8080' ).
|
mo_settings->set_proxy_port( '8080' ).
|
||||||
|
|
||||||
mo_persistence_settings->modify( mo_settings ).
|
mo_persistence_settings->modify( mo_settings ).
|
||||||
|
@ -1573,13 +1608,9 @@ CLASS ltcl_persistence_settings IMPLEMENTATION.
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = lv_proxy_port
|
act = lv_proxy_port
|
||||||
exp = '8080' ).
|
exp = '8080' ).
|
||||||
CATCH cx_root.
|
|
||||||
cl_abap_unit_assert=>fail( 'Unexpected exception' ).
|
|
||||||
ENDTRY.
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
METHOD read_settings.
|
METHOD read_proxy_settings.
|
||||||
TRY.
|
|
||||||
lcl_app=>db( )->modify(
|
lcl_app=>db( )->modify(
|
||||||
iv_type = 'SETTINGS'
|
iv_type = 'SETTINGS'
|
||||||
iv_value = 'PROXY_URL'
|
iv_value = 'PROXY_URL'
|
||||||
|
@ -1598,50 +1629,84 @@ CLASS ltcl_persistence_settings IMPLEMENTATION.
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = mo_settings->get_proxy_port( )
|
act = mo_settings->get_proxy_port( )
|
||||||
exp = '1000' ).
|
exp = '1000' ).
|
||||||
CATCH cx_root.
|
|
||||||
cl_abap_unit_assert=>fail( 'Unexpected exception' ).
|
|
||||||
ENDTRY.
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
METHOD read_not_found_port.
|
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( ).
|
mo_settings = mo_persistence_settings->read( ).
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = mo_settings->get_proxy_port( )
|
act = mo_settings->get_proxy_port( )
|
||||||
exp = '' ).
|
exp = '' ).
|
||||||
CATCH cx_root.
|
|
||||||
cl_abap_unit_assert=>fail( 'Unexpected exception' ).
|
|
||||||
ENDTRY.
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
METHOD read_not_found_url.
|
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( ).
|
mo_settings = mo_persistence_settings->read( ).
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = mo_settings->get_proxy_url( )
|
act = mo_settings->get_proxy_url( )
|
||||||
exp = '' ).
|
exp = '' ).
|
||||||
CATCH cx_root.
|
ENDMETHOD.
|
||||||
cl_abap_unit_assert=>fail( 'Unexpected exception' ).
|
|
||||||
|
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.
|
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.
|
ENDMETHOD.
|
||||||
|
|
||||||
ENDCLASS.
|
ENDCLASS.
|
Loading…
Reference in New Issue
Block a user