@Test public void testPropertiesList() throws Exception { defaults.setProperty("a", "b"); props.setProperty("x", "y"); StringWriter wr = new StringWriter(); props.list(new PrintWriter(wr)); }
@Test public void testGetProperty() throws Exception { String property = props.getProperty("a"); assertNull(property); defaults.put("a", "x"); assertEquals("x", props.getProperty("a")); }
@Test @Ignore public void testPropertiesSaveXml() throws Exception { props.setProperty("x", "y"); props.setProperty("a", "b"); ByteArrayOutputStream bos = new ByteArrayOutputStream(); props.storeToXML(bos, "comment"); System.out.println(bos.toString()); }
@Test public void testPropertiesSave() throws Exception { props.setProperty("x", "y"); props.setProperty("a", "b"); StringWriter writer = new StringWriter(); props.store(writer, "no-comment"); // System.out.println(writer.toString()); }
@Test public void testStringPropertyNames() throws Exception { String key1 = "foo"; String key2 = "x"; String key3 = "d"; String val = "o"; defaults.setProperty(key3, val); props.setProperty(key1, val); props.setProperty(key2, val); Set<String> keys = props.stringPropertyNames(); assertTrue(keys.contains(key1)); assertTrue(keys.contains(key2)); assertTrue(keys.contains(key3)); }
@Test public void testPropertyNames() throws Exception { String key1 = "foo"; String key2 = "x"; String key3 = "d"; String val = "o"; defaults.setProperty(key3, val); props.setProperty(key1, val); props.setProperty(key2, val); Enumeration<?> names = props.propertyNames(); Set<Object> keys = new LinkedHashSet<Object>(); keys.add(names.nextElement()); keys.add(names.nextElement()); keys.add(names.nextElement()); assertFalse(names.hasMoreElements()); }
@Test public void testPropertiesLoad() throws Exception { InputStream stream = getClass() .getResourceAsStream( "/org/springframework/data/redis/support/collections/props.properties"); assertNotNull(stream); int size = props.size(); try { props.load(stream); } finally { stream.close(); } assertEquals("bar", props.get("foo")); assertEquals("head", props.get("bucket")); assertEquals("island", props.get("lotus")); assertEquals(size + 3, props.size()); }
@Test public void testDefaultInit() throws Exception { RedisProperties redisProperties = new RedisProperties("foo", template); redisProperties.propertyNames(); }
@Test public void testSetProperty() throws Exception { assertNull(props.getProperty("a")); defaults.setProperty("a", "x"); assertEquals("x", props.getProperty("a")); }
@Test public void testGetPropertyDefault() throws Exception { assertEquals("x", props.getProperty("a", "x")); }