Exemple #1
0
    def test_parse_flat_dictionary(self):
        text = """{
            "key1" => "value1"
            "key2" => "value2"
            }"""

        result = jboss7_cli._parse(text)

        self.assertEqual(len(result), 2)
        self.assertEqual(result["key1"], "value1")
        self.assertEqual(result["key2"], "value2")
Exemple #2
0
    def test_parse_flat_dictionary(self):
        text = '''{
            "key1" => "value1"
            "key2" => "value2"
            }'''

        result = jboss7_cli._parse(text)

        self.assertEqual(len(result), 2)
        self.assertEqual(result['key1'], 'value1')
        self.assertEqual(result['key2'], 'value2')
Exemple #3
0
    def test_parse_flat_dictionary(self):
        text = '''{
            "key1" => "value1"
            "key2" => "value2"
            }'''

        result = jboss7_cli._parse(text)

        self.assertEqual(len(result), 2)
        self.assertEqual(result['key1'], 'value1')
        self.assertEqual(result['key2'], 'value2')
Exemple #4
0
    def test_parse_string_after_dict(self):
        text = '''{
            "result" => {
                "jta" => true
            },
            "response-headers" => {"process-state" => "reload-required"}
        }'''

        result = jboss7_cli._parse(text)

        self.assertTrue(result['result']['jta'])
        self.assertEqual(result['response-headers']['process-state'], 'reload-required')
Exemple #5
0
    def test_parse_string_after_dict(self):
        text = """{
            "result" => {
                "jta" => true
            },
            "response-headers" => {"process-state" => "reload-required"}
        }"""

        result = jboss7_cli._parse(text)

        self.assertTrue(result["result"]["jta"])
        self.assertEqual(result["response-headers"]["process-state"], "reload-required")
Exemple #6
0
    def test_parse_string_after_dict(self):
        text = '''{
            "result" => {
                "jta" => true
            },
            "response-headers" => {"process-state" => "reload-required"}
        }'''

        result = jboss7_cli._parse(text)

        self.assertTrue(result['result']['jta'])
        self.assertEqual(result['response-headers']['process-state'], 'reload-required')
Exemple #7
0
    def test_parse_nested_dictionary(self):
        text = '''{
            "key1" => "value1",
            "key2" => {
                "nested_key1" => "nested_value1"
            }
        }'''

        result = jboss7_cli._parse(text)

        self.assertEqual(len(result), 2)
        self.assertEqual(result['key1'], 'value1')
        self.assertEqual(len(result['key2']), 1)
        self.assertEqual(result['key2']['nested_key1'], 'nested_value1')
Exemple #8
0
    def test_numbers_without_quotes(self):
        text = r"""{
                "outcome" => "success",
                "result" => {
                    "min-pool-size" => 1233,
                    "new-connection-sql" => undefined
                }
            }"""

        result = jboss7_cli._parse(text)

        self.assertEqual(result["outcome"], "success")
        self.assertEqual(result["result"]["min-pool-size"], 1233)
        self.assertIsNone(result["result"]["new-connection-sql"])
Exemple #9
0
    def test_parse_nested_dictionary(self):
        text = '''{
            "key1" => "value1",
            "key2" => {
                "nested_key1" => "nested_value1"
            }
        }'''

        result = jboss7_cli._parse(text)

        self.assertEqual(len(result), 2)
        self.assertEqual(result['key1'], 'value1')
        self.assertEqual(len(result['key2']), 1)
        self.assertEqual(result['key2']['nested_key1'], 'nested_value1')
Exemple #10
0
    def test_handling_double_backslash_in_return_values(self):
        text = r"""{
                 "outcome" => "success",
                 "result" => {
                    "binding-type" => "simple",
                    "value" => "DOMAIN\\foo"
                   }
                }"""

        result = jboss7_cli._parse(text)

        self.assertEqual(result["outcome"], "success")
        self.assertEqual(result["result"]["binding-type"], "simple")
        self.assertEqual(result["result"]["value"], r"DOMAIN\foo")
Exemple #11
0
    def test_numbers_without_quotes(self):
        text = r'''{
                "outcome" => "success",
                "result" => {
                    "min-pool-size" => 1233,
                    "new-connection-sql" => undefined
                }
            }'''

        result = jboss7_cli._parse(text)

        self.assertEqual(result['outcome'], 'success')
        self.assertEqual(result['result']['min-pool-size'], 1233)
        self.assertIsNone(result['result']['new-connection-sql'])
Exemple #12
0
    def test_parse_nested_dictionary(self):
        text = """{
            "key1" => "value1",
            "key2" => {
                "nested_key1" => "nested_value1"
            }
        }"""

        result = jboss7_cli._parse(text)

        self.assertEqual(len(result), 2)
        self.assertEqual(result["key1"], "value1")
        self.assertEqual(len(result["key2"]), 1)
        self.assertEqual(result["key2"]["nested_key1"], "nested_value1")
Exemple #13
0
    def test_handling_double_backslash_in_return_values(self):
        text = r'''{
                 "outcome" => "success",
                 "result" => {
                    "binding-type" => "simple",
                    "value" => "DOMAIN\\foo"
                   }
                }'''

        result = jboss7_cli._parse(text)

        self.assertEqual(result['outcome'], 'success')
        self.assertEqual(result['result']['binding-type'], 'simple')
        self.assertEqual(result['result']['value'], r'DOMAIN\foo')
Exemple #14
0
    def test_numbers_without_quotes(self):
        text = r'''{
                "outcome" => "success",
                "result" => {
                    "min-pool-size" => 1233,
                    "new-connection-sql" => undefined
                }
            }'''

        result = jboss7_cli._parse(text)

        self.assertEqual(result['outcome'], 'success')
        self.assertEqual(result['result']['min-pool-size'], 1233)
        self.assertIsNone(result['result']['new-connection-sql'])
Exemple #15
0
    def test_handling_double_backslash_in_return_values(self):
        text = r'''{
                 "outcome" => "success",
                 "result" => {
                    "binding-type" => "simple",
                    "value" => "DOMAIN\\user"
                   }
                }'''

        result = jboss7_cli._parse(text)

        self.assertEqual(result['outcome'], 'success')
        self.assertEqual(result['result']['binding-type'], 'simple')
        self.assertEqual(result['result']['value'], r'DOMAIN\user')
Exemple #16
0
    def test_multiline_strings_with_escaped_quotes(self):
        text = r'''{
            "outcome" => "failed",
            "failure-description" => "JBAS014807: Management resource '[
            (\"subsystem\" => \"datasources\"),
            (\"data-source\" => \"asc\")
        ]' not found",
            "rolled-back" => true,
            "response-headers" => {"process-state" => "reload-required"}
        }'''

        result = jboss7_cli._parse(text)

        self.assertEqual(result['outcome'], 'failed')
        self.assertTrue(result['rolled-back'])
        self.assertEqual(result['response-headers']['process-state'], 'reload-required')
        self.assertEqual(result['failure-description'], r'''JBAS014807: Management resource '[
            (\"subsystem\" => \"datasources\"),
            (\"data-source\" => \"asc\")
        ]' not found''')
Exemple #17
0
    def test_multiline_strings_with_escaped_quotes(self):
        text = r'''{
            "outcome" => "failed",
            "failure-description" => "JBAS014807: Management resource '[
            (\"subsystem\" => \"datasources\"),
            (\"data-source\" => \"asc\")
        ]' not found",
            "rolled-back" => true,
            "response-headers" => {"process-state" => "reload-required"}
        }'''

        result = jboss7_cli._parse(text)

        self.assertEqual(result['outcome'], 'failed')
        self.assertTrue(result['rolled-back'])
        self.assertEqual(result['response-headers']['process-state'], 'reload-required')
        self.assertEqual(result['failure-description'], r'''JBAS014807: Management resource '[
            (\"subsystem\" => \"datasources\"),
            (\"data-source\" => \"asc\")
        ]' not found''')
Exemple #18
0
    def test_datasource_complete_resource_description(self):
        cli_output = """{
            "outcome" => "success",
            "result" => {
                "description" => "A JDBC data-source configuration",
                "head-comment-allowed" => true,
                "tail-comment-allowed" => true,
                "attributes" => {
                    "connection-url" => {
                        "type" => STRING,
                        "description" => "The JDBC driver connection URL",
                        "expressions-allowed" => true,
                        "nillable" => false,
                        "min-length" => 1L,
                        "max-length" => 2147483647L,
                        "access-type" => "read-write",
                        "storage" => "configuration",
                        "restart-required" => "no-services"
                    }
                },
                "children" => {"connection-properties" => {"description" => "The connection-properties element allows you to pass in arbitrary connection properties to the Driver.connect(url, props) method"}}
            }
        }
        """

        result = jboss7_cli._parse(cli_output)

        self.assertEqual(result["outcome"], "success")
        conn_url_attributes = result["result"]["attributes"]["connection-url"]
        self.assertEqual(conn_url_attributes["type"], "STRING")
        self.assertEqual(conn_url_attributes["description"],
                         "The JDBC driver connection URL")
        self.assertTrue(conn_url_attributes["expressions-allowed"])
        self.assertFalse(conn_url_attributes["nillable"])
        self.assertEqual(conn_url_attributes["min-length"], 1)
        self.assertEqual(conn_url_attributes["max-length"], 2147483647)
        self.assertEqual(conn_url_attributes["access-type"], "read-write")
        self.assertEqual(conn_url_attributes["storage"], "configuration")
        self.assertEqual(conn_url_attributes["restart-required"],
                         "no-services")
Exemple #19
0
    def test_datasource_complete_resource_description(self):
        cli_output = '''{
            "outcome" => "success",
            "result" => {
                "description" => "A JDBC data-source configuration",
                "head-comment-allowed" => true,
                "tail-comment-allowed" => true,
                "attributes" => {
                    "connection-url" => {
                        "type" => STRING,
                        "description" => "The JDBC driver connection URL",
                        "expressions-allowed" => true,
                        "nillable" => false,
                        "min-length" => 1L,
                        "max-length" => 2147483647L,
                        "access-type" => "read-write",
                        "storage" => "configuration",
                        "restart-required" => "no-services"
                    }
                },
                "children" => {"connection-properties" => {"description" => "The connection-properties element allows you to pass in arbitrary connection properties to the Driver.connect(url, props) method"}}
            }
        }
        '''

        result = jboss7_cli._parse(cli_output)

        self.assertEqual(result['outcome'], 'success')
        conn_url_attributes = result['result']['attributes']['connection-url']
        self.assertEqual(conn_url_attributes['type'], 'STRING')
        self.assertEqual(conn_url_attributes['description'],
                         'The JDBC driver connection URL')
        self.assertTrue(conn_url_attributes['expressions-allowed'])
        self.assertFalse(conn_url_attributes['nillable'])
        self.assertEqual(conn_url_attributes['min-length'], 1)
        self.assertEqual(conn_url_attributes['max-length'], 2147483647)
        self.assertEqual(conn_url_attributes['access-type'], 'read-write')
        self.assertEqual(conn_url_attributes['storage'], 'configuration')
        self.assertEqual(conn_url_attributes['restart-required'],
                         'no-services')
Exemple #20
0
    def test_parse_all_datatypes(self):
        text = '''{
            "outcome" => "success",
            "result" => {
                "allocation-retry" => undefined,
                "connection-url" => "jdbc:mysql://localhost:3306/appdb",
                "driver-name" => "mysql",
                "enabled" => false,
                "jta" => true
            },
            "response-headers" => {"process-state" => "reload-required"}
        }'''

        result = jboss7_cli._parse(text)

        self.assertEqual(result['outcome'], 'success')
        self.assertIsNone(result['result']['allocation-retry'])
        self.assertEqual(result['result']['connection-url'], 'jdbc:mysql://localhost:3306/appdb')
        self.assertEqual(result['result']['driver-name'], 'mysql')
        self.assertEqual(result['result']['enabled'], False)
        self.assertTrue(result['result']['jta'])
        self.assertEqual(result['response-headers']['process-state'], 'reload-required')
Exemple #21
0
    def test_parse_all_datatypes(self):
        text = '''{
            "outcome" => "success",
            "result" => {
                "allocation-retry" => undefined,
                "connection-url" => "jdbc:mysql://localhost:3306/appdb",
                "driver-name" => "mysql",
                "enabled" => false,
                "jta" => true
            },
            "response-headers" => {"process-state" => "reload-required"}
        }'''

        result = jboss7_cli._parse(text)

        self.assertEqual(result['outcome'], 'success')
        self.assertIsNone(result['result']['allocation-retry'])
        self.assertEqual(result['result']['connection-url'], 'jdbc:mysql://localhost:3306/appdb')
        self.assertEqual(result['result']['driver-name'], 'mysql')
        self.assertEqual(result['result']['enabled'], False)
        self.assertTrue(result['result']['jta'])
        self.assertEqual(result['response-headers']['process-state'], 'reload-required')
Exemple #22
0
    def test_datasource_complete_resource_description(self):
        cli_output = '''{
            "outcome" => "success",
            "result" => {
                "description" => "A JDBC data-source configuration",
                "head-comment-allowed" => true,
                "tail-comment-allowed" => true,
                "attributes" => {
                    "connection-url" => {
                        "type" => STRING,
                        "description" => "The JDBC driver connection URL",
                        "expressions-allowed" => true,
                        "nillable" => false,
                        "min-length" => 1L,
                        "max-length" => 2147483647L,
                        "access-type" => "read-write",
                        "storage" => "configuration",
                        "restart-required" => "no-services"
                    }
                },
                "children" => {"connection-properties" => {"description" => "The connection-properties element allows you to pass in arbitrary connection properties to the Driver.connect(url, props) method"}}
            }
        }
        '''

        result = jboss7_cli._parse(cli_output)

        self.assertEqual(result['outcome'], 'success')
        conn_url_attributes = result['result']['attributes']['connection-url']
        self.assertEqual(conn_url_attributes['type'], 'STRING')
        self.assertEqual(conn_url_attributes['description'], 'The JDBC driver connection URL')
        self.assertTrue(conn_url_attributes['expressions-allowed'])
        self.assertFalse(conn_url_attributes['nillable'])
        self.assertEqual(conn_url_attributes['min-length'], 1)
        self.assertEqual(conn_url_attributes['max-length'], 2147483647)
        self.assertEqual(conn_url_attributes['access-type'], 'read-write')
        self.assertEqual(conn_url_attributes['storage'], 'configuration')
        self.assertEqual(conn_url_attributes['restart-required'], 'no-services')
Exemple #23
0
    def test_parse_all_datatypes(self):
        text = """{
            "outcome" => "success",
            "result" => {
                "allocation-retry" => undefined,
                "connection-url" => "jdbc:mysql://localhost:3306/appdb",
                "driver-name" => "mysql",
                "enabled" => false,
                "jta" => true
            },
            "response-headers" => {"process-state" => "reload-required"}
        }"""

        result = jboss7_cli._parse(text)

        self.assertEqual(result["outcome"], "success")
        self.assertIsNone(result["result"]["allocation-retry"])
        self.assertEqual(result["result"]["connection-url"],
                         "jdbc:mysql://localhost:3306/appdb")
        self.assertEqual(result["result"]["driver-name"], "mysql")
        self.assertEqual(result["result"]["enabled"], False)
        self.assertTrue(result["result"]["jta"])
        self.assertEqual(result["response-headers"]["process-state"],
                         "reload-required")
Exemple #24
0
    def test_all_datasource_properties(self):
        text = r'''{
            "outcome" => "success",
            "result" => {
                "allocation-retry" => undefined,
                "allocation-retry-wait-millis" => undefined,
                "allow-multiple-users" => undefined,
                "background-validation" => undefined,
                "background-validation-millis" => undefined,
                "blocking-timeout-wait-millis" => undefined,
                "check-valid-connection-sql" => undefined,
                "connection-properties" => undefined,
                "connection-url" => "jdbc:mysql:thin:@db.example.com",
                "datasource-class" => undefined,
                "driver-class" => undefined,
                "driver-name" => "mysql",
                "enabled" => true,
                "exception-sorter-class-name" => undefined,
                "exception-sorter-properties" => undefined,
                "flush-strategy" => "FailingConnectionOnly",
                "idle-timeout-minutes" => undefined,
                "jndi-name" => "java:/appDS",
                "jta" => true,
                "max-pool-size" => 20,
                "min-pool-size" => 3,
                "new-connection-sql" => undefined,
                "password" => "Password4321",
                "pool-prefill" => undefined,
                "pool-use-strict-min" => undefined,
                "prepared-statements-cache-size" => undefined,
                "query-timeout" => undefined,
                "reauth-plugin-class-name" => undefined,
                "reauth-plugin-properties" => undefined,
                "security-domain" => undefined,
                "set-tx-query-timeout" => false,
                "share-prepared-statements" => false,
                "spy" => false,
                "stale-connection-checker-class-name" => undefined,
                "stale-connection-checker-properties" => undefined,
                "track-statements" => "NOWARN",
                "transaction-isolation" => undefined,
                "url-delimiter" => undefined,
                "url-selector-strategy-class-name" => undefined,
                "use-ccm" => "true",
                "use-fast-fail" => false,
                "use-java-context" => "false",
                "use-try-lock" => undefined,
                "user-name" => "user1",
                "valid-connection-checker-class-name" => undefined,
                "valid-connection-checker-properties" => undefined,
                "validate-on-match" => false,
                "statistics" => {
                    "jdbc" => undefined,
                    "pool" => undefined
                }
            },
            "response-headers" => {"process-state" => "reload-required"}
        }'''

        result = jboss7_cli._parse(text)

        self.assertEqual(result['outcome'], 'success')
        self.assertEqual(result['result']['max-pool-size'], 20)
        self.assertIsNone(result['result']['new-connection-sql'])
        self.assertIsNone(result['result']['url-delimiter'])
        self.assertFalse(result['result']['validate-on-match'])
Exemple #25
0
    def test_all_datasource_properties(self):
        text = r'''{
            "outcome" => "success",
            "result" => {
                "allocation-retry" => undefined,
                "allocation-retry-wait-millis" => undefined,
                "allow-multiple-users" => undefined,
                "background-validation" => undefined,
                "background-validation-millis" => undefined,
                "blocking-timeout-wait-millis" => undefined,
                "check-valid-connection-sql" => undefined,
                "connection-properties" => undefined,
                "connection-url" => "jdbc:mysql:thin:@db.company.com",
                "datasource-class" => undefined,
                "driver-class" => undefined,
                "driver-name" => "mysql",
                "enabled" => true,
                "exception-sorter-class-name" => undefined,
                "exception-sorter-properties" => undefined,
                "flush-strategy" => "FailingConnectionOnly",
                "idle-timeout-minutes" => undefined,
                "jndi-name" => "java:/appDS",
                "jta" => true,
                "max-pool-size" => 20,
                "min-pool-size" => 3,
                "new-connection-sql" => undefined,
                "password" => "Password4321",
                "pool-prefill" => undefined,
                "pool-use-strict-min" => undefined,
                "prepared-statements-cache-size" => undefined,
                "query-timeout" => undefined,
                "reauth-plugin-class-name" => undefined,
                "reauth-plugin-properties" => undefined,
                "security-domain" => undefined,
                "set-tx-query-timeout" => false,
                "share-prepared-statements" => false,
                "spy" => false,
                "stale-connection-checker-class-name" => undefined,
                "stale-connection-checker-properties" => undefined,
                "track-statements" => "NOWARN",
                "transaction-isolation" => undefined,
                "url-delimiter" => undefined,
                "url-selector-strategy-class-name" => undefined,
                "use-ccm" => "true",
                "use-fast-fail" => false,
                "use-java-context" => "false",
                "use-try-lock" => undefined,
                "user-name" => "user1",
                "valid-connection-checker-class-name" => undefined,
                "valid-connection-checker-properties" => undefined,
                "validate-on-match" => false,
                "statistics" => {
                    "jdbc" => undefined,
                    "pool" => undefined
                }
            },
            "response-headers" => {"process-state" => "reload-required"}
        }'''

        result = jboss7_cli._parse(text)

        self.assertEqual(result['outcome'], 'success')
        self.assertEqual(result['result']['max-pool-size'], 20)
        self.assertIsNone(result['result']['new-connection-sql'])
        self.assertIsNone(result['result']['url-delimiter'])
        self.assertFalse(result['result']['validate-on-match'])