assertThat(creatingDataSource).isTrue(); assertThat(jndiConfig.getJndiName()).isEqualTo("name"); assertThat(jndiConfig.getConfigProperties().get(0).getName()).isEqualTo("name1"); assertThat(targetMembers.getValue()).isEqualTo(members);
@Test public void configPropertyIsProperlyParsed() { GfshParseResult result = gfsh.parse(COMMAND + " --type=SIMPLE --name=name --jdbc-driver-class=driver --connection-url=url " + "--datasource-config-properties={'name':'name1','type':'type1','value':'value1'},{'name':'name2','type':'type2','value':'value2'}"); JndiBindingsType.JndiBinding.ConfigProperty[] configProperties = (JndiBindingsType.JndiBinding.ConfigProperty[]) result .getParamValue("datasource-config-properties"); assertThat(configProperties).hasSize(2); assertThat(configProperties[0].getValue()).isEqualTo("value1"); assertThat(configProperties[1].getValue()).isEqualTo("value2"); }
@Test public void validWhenTypeMissing() { JndiBindingsType.JndiBinding.ConfigProperty configProperty = converter.convertFromText("{'name':'name','value':'value'}", null, null); assertThat(configProperty.getName()).isEqualTo("name"); assertThat(configProperty.getType()).isNull(); assertThat(configProperty.getValue()).isEqualTo("value"); }
String propName = dataSourceProperty.getName(); String propValue = dataSourceProperty.getValue(); configProperties.add(new ConfigProperty(propName, "type", propValue));
assertThat(creatingDataSource).isFalse(); assertThat(jndiConfig.getJndiName()).isEqualTo("name"); assertThat(jndiConfig.getConfigProperties().get(0).getName()).isEqualTo("name1"); assertThat(targetMembers.getValue()).isEqualTo(members);
assertThat(creatingDataSource).isTrue(); assertThat(jndiConfig.getJndiName()).isEqualTo("name"); assertThat(jndiConfig.getConfigProperties().get(0).getName()).isEqualTo("name1"); assertThat(targetMembers.getValue()).isEqualTo(members);
assertThat(creatingDataSource).isFalse(); assertThat(jndiConfig.getJndiName()).isEqualTo("name"); assertThat(jndiConfig.getConfigProperties().get(0).getName()).isEqualTo("name1"); assertThat(targetMembers.getValue()).isEqualTo(members);
@Test public void jndiBindings() { service.updateCacheConfig("cluster", cacheConfig -> { JndiBindingsType.JndiBinding jndiBinding = new JndiBindingsType.JndiBinding(); jndiBinding.setJndiName("jndiOne"); jndiBinding.setJdbcDriverClass("com.sun.ABC"); jndiBinding.setType("SimpleDataSource"); jndiBinding.getConfigProperties() .add(new JndiBindingsType.JndiBinding.ConfigProperty("test", "test", "test")); cacheConfig.getJndiBindings().add(jndiBinding); return cacheConfig; }); assertThat(configuration.getCacheXmlContent()).containsOnlyOnce("</jndi-bindings>"); assertThat(configuration.getCacheXmlContent()).contains( "<jndi-binding jdbc-driver-class=\"com.sun.ABC\" jndi-name=\"jndiOne\" type=\"SimpleDataSource\">"); assertThat(configuration.getCacheXmlContent()) .contains("config-property-name>test</config-property-name>"); }
@Test public void describeDataSourceWithPoolPropertiesDoesNotShowsItInTheResult() { binding.setType(DATASOURCE_TYPE.SIMPLE.getType()); List<ConfigProperty> configProperties = binding.getConfigProperties(); configProperties.add(new ConfigProperty("name1", "value1")); ResultModel result = command.describeDataSource(DATA_SOURCE_NAME); assertThat(result.toString()).doesNotContain("name1"); assertThat(result.toString()).doesNotContain("value1"); }
@Test public void describeDataSourceWithPoolPropertiesShowsItInTheResult() { binding.setType(DATASOURCE_TYPE.POOLED.getType()); List<ConfigProperty> configProperties = binding.getConfigProperties(); configProperties.add(new ConfigProperty("name1", "value1")); configProperties.add(new ConfigProperty("name2", "value2")); ResultModel result = command.describeDataSource(DATA_SOURCE_NAME); TabularResultModel section = result.getTableSection(DescribeDataSourceCommand.DATA_SOURCE_PROPERTIES_SECTION); assertThat(section.getValuesInRow(5)).isEqualTo(Arrays.asList("name1", "value1")); assertThat(section.getValuesInRow(6)).isEqualTo(Arrays.asList("name2", "value2")); }
/** * Get the id of the element. The id is the same as the name. * * @return the id of the element */ @Override public String getId() { return getName(); }
@Test public void validJson() { JndiBindingsType.JndiBinding.ConfigProperty configProperty = converter.convertFromText("{'name':'name','type':'type','value':'value'}", null, null); assertThat(configProperty.getName()).isEqualTo("name"); assertThat(configProperty.getType()).isEqualTo("type"); assertThat(configProperty.getValue()).isEqualTo("value"); }
static List<ConfigProperty> convert( List<JndiBindingsType.JndiBinding.ConfigProperty> properties) { return properties.stream().map(p -> { ConfigProperty prop = new ConfigProperty(); prop.setName(p.getName()); prop.setType(p.getType()); prop.setValue(p.getValue()); return prop; }).collect(Collectors.toList()); } }