Esempio n. 1
0
        public void Bind_ThrowsWithBadArguments()
        {
            var opt = new MySqlServiceOption();

            Assert.Throws <ArgumentNullException>(() => opt.Bind(null, "foobar"));
            Assert.Throws <ArgumentException>(() => opt.Bind(new ConfigurationBuilder().Build(), null));
            Assert.Throws <ArgumentException>(() => opt.Bind(new ConfigurationBuilder().Build(), string.Empty));
        }
Esempio n. 2
0
        public void Bind_DoesNotBindsConfiguration()
        {
            var configJson = @"
            {
                ""foo"": {
                    ""bar"" : {
                    }
                }
            }";
            var memStream  = CloudFoundryConfigurationProvider.GetMemoryStream(configJson);
            var jsonSource = new JsonStreamConfigurationSource(memStream);
            var builder    = new ConfigurationBuilder().Add(jsonSource);
            var config     = builder.Build();

            var opt = new MySqlServiceOption();

            opt.Bind(config, "mySql2");
            Assert.NotEqual("mySql2", opt.Name);
            Assert.NotEqual("p-mysql", opt.Label);
        }
Esempio n. 3
0
        public void Bind_BindsConfiguration()
        {
            // Arrange
            var configJson = @"
            {
                ""vcap"": {
                    ""services"" : {
                        ""p-mysql"": [{
                            ""name"": ""mySql1"",
                            ""label"": ""p-mysql"",
                            ""tags"": [
                                ""mysql"",
                                ""relational""
                            ],
                            ""plan"": ""100mb-dev"",
                            ""credentials"": {
                                ""hostname"": ""192.168.0.97"",
                                ""port"": 3306,
                                ""name"": ""cf_0f5dda44_e678_4727_993f_30e6d455cc31"",
                                ""username"": ""9vD0Mtk3wFFuaaaY"",
                                ""password"": ""Cjn4HsAiKV8sImst"",
                                ""uri"": ""mysql://*****:*****@192.168.0.97:3306/cf_0f5dda44_e678_4727_993f_30e6d455cc31?reconnect=true"",
                                ""jdbcUrl"": ""jdbc:mysql://192.168.0.97:3306/cf_0f5dda44_e678_4727_993f_30e6d455cc31?user=9vD0Mtk3wFFuaaaY&password=Cjn4HsAiKV8sImst""
                            }
                        },
                        {
                            ""name"": ""mySql2"",
                            ""label"": ""p-mysql"",
                            ""tags"": [
                                ""mysql"",
                                ""relational""
                            ],
                            ""plan"": ""100mb-dev"",
                            ""credentials"": {
                                ""hostname"": ""192.168.0.97"",
                                ""port"": 3306,
                                ""name"": ""cf_0f5dda44_e678_4727_993f_30e6d455cc31"",
                                ""username"": ""9vD0Mtk3wFFuaaaY"",
                                ""password"": ""Cjn4HsAiKV8sImst"",
                                ""uri"": ""mysql://*****:*****@192.168.0.97:3306/cf_0f5dda44_e678_4727_993f_30e6d455cc31?reconnect=true"",
                                ""jdbcUrl"": ""jdbc:mysql://192.168.0.97:3306/cf_0f5dda44_e678_4727_993f_30e6d455cc31?user=9vD0Mtk3wFFuaaaY&password=Cjn4HsAiKV8sImst""
                            }
                        }]
                    }
                }
            }";
            var memStream  = CloudFoundryConfigurationProvider.GetMemoryStream(configJson);
            var jsonSource = new JsonStreamConfigurationSource(memStream);
            var builder    = new ConfigurationBuilder().Add(jsonSource);
            var config     = builder.Build();

            var opt = new MySqlServiceOption();

            opt.Bind(config, "mySql2");
            Assert.Equal("mySql2", opt.Name);
            Assert.Equal("p-mysql", opt.Label);

            var opt2 = new MySqlServiceOption();

            opt2.Bind(config, "mySql1");
            Assert.Equal("mySql1", opt2.Name);
            Assert.Equal("p-mysql", opt2.Label);
        }
Esempio n. 4
0
        public void Bind_BindsConfiguration()
        {
            // Arrange
            var configJson = @"
{ 'vcap': {
    'services' : {
            'p-mysql': [
            {
                'name': 'mySql1',
                'label': 'p-mysql',
                'tags': [
                'mysql',
                'relational'
                ],
                'plan': '100mb-dev',
                'credentials': {
                    'hostname': '192.168.0.97',
                    'port': 3306,
                    'name': 'cf_0f5dda44_e678_4727_993f_30e6d455cc31',
                    'username': '******',
                    'password': '******',
                    'uri': 'mysql://*****:*****@192.168.0.97:3306/cf_0f5dda44_e678_4727_993f_30e6d455cc31?reconnect=true',
                    'jdbcUrl': 'jdbc:mysql://192.168.0.97:3306/cf_0f5dda44_e678_4727_993f_30e6d455cc31?user=9vD0Mtk3wFFuaaaY&password=Cjn4HsAiKV8sImst'
                }
            },
            {
                'name': 'mySql2',
                'label': 'p-mysql',
                'tags': [
                'mysql',
                'relational'
                ],
                'plan': '100mb-dev',
                'credentials': {
                    'hostname': '192.168.0.97',
                    'port': 3306,
                    'name': 'cf_0f5dda44_e678_4727_993f_30e6d455cc31',
                    'username': '******',
                    'password': '******',
                    'uri': 'mysql://*****:*****@192.168.0.97:3306/cf_0f5dda44_e678_4727_993f_30e6d455cc31?reconnect=true',
                    'jdbcUrl': 'jdbc:mysql://192.168.0.97:3306/cf_0f5dda44_e678_4727_993f_30e6d455cc31?user=9vD0Mtk3wFFuaaaY&password=Cjn4HsAiKV8sImst'
                }
            }
            ]
        }
    }
}";
            var memStream  = CloudFoundryConfigurationProvider.GetMemoryStream(configJson);
            var jsonSource = new JsonStreamConfigurationSource(memStream);
            var builder    = new ConfigurationBuilder().Add(jsonSource);
            var config     = builder.Build();

            var opt = new MySqlServiceOption();

            opt.Bind(config, "mySql2");
            Assert.Equal("mySql2", opt.Name);
            Assert.Equal("p-mysql", opt.Label);

            var opt2 = new MySqlServiceOption();

            opt2.Bind(config, "mySql1");
            Assert.Equal("mySql1", opt2.Name);
            Assert.Equal("p-mysql", opt2.Label);
        }