From b9fca3c04d3561ffa1430724e5fb5ab8e024dd2c Mon Sep 17 00:00:00 2001 From: Erik Broes Date: Sun, 25 Dec 2011 16:02:30 +0100 Subject: Generic cleanup of warnings, whitespace and style. --- .../configuration/ConfigurationSectionTest.java | 206 ++++++++++----------- 1 file changed, 100 insertions(+), 106 deletions(-) (limited to 'src/test/java/org') diff --git a/src/test/java/org/bukkit/configuration/ConfigurationSectionTest.java b/src/test/java/org/bukkit/configuration/ConfigurationSectionTest.java index d45a4c31..4e3478fd 100644 --- a/src/test/java/org/bukkit/configuration/ConfigurationSectionTest.java +++ b/src/test/java/org/bukkit/configuration/ConfigurationSectionTest.java @@ -25,25 +25,25 @@ public abstract class ConfigurationSectionTest { section.set("key2", true); section.set("42", true); - assertArrayEquals(new String[] {"key", "subsection", "key2", "42"}, section.getKeys(false).toArray()); - assertArrayEquals(new String[] {"key", "subsection", "subsection.subkey", "subsection.subkey2", "subsection.subsubsection", "subsection.subsubsection.key", "key2", "42"}, section.getKeys(true).toArray()); - assertArrayEquals(new String[] {"subkey", "subkey2", "subsubsection", "subsubsection.key"}, section.getConfigurationSection("subsection").getKeys(true).toArray()); + assertArrayEquals(new String[] { "key", "subsection", "key2", "42" }, section.getKeys(false).toArray()); + assertArrayEquals(new String[] { "key", "subsection", "subsection.subkey", "subsection.subkey2", "subsection.subsubsection", "subsection.subsubsection.key", "key2", "42" }, section.getKeys(true).toArray()); + assertArrayEquals(new String[] { "subkey", "subkey2", "subsubsection", "subsubsection.key" }, section.getConfigurationSection("subsection").getKeys(true).toArray()); } @Test public void testGetKeysWithDefaults() { ConfigurationSection section = getConfigurationSection(); section.getRoot().options().copyDefaults(true); - + section.set("key", true); section.addDefault("subsection.subkey", true); section.addDefault("subsection.subkey2", true); section.addDefault("subsection.subsubsection.key", true); section.addDefault("key2", true); - assertArrayEquals(new String[] {"subsection", "key2", "key"}, section.getKeys(false).toArray()); - assertArrayEquals(new String[] {"subsection", "subsection.subkey", "subsection.subkey2", "subsection.subsubsection", "subsection.subsubsection.key", "key2", "key"}, section.getKeys(true).toArray()); - assertArrayEquals(new String[] {"subkey", "subkey2", "subsubsection", "subsubsection.key"}, section.getConfigurationSection("subsection").getKeys(true).toArray()); + assertArrayEquals(new String[] { "subsection", "key2", "key" }, section.getKeys(false).toArray()); + assertArrayEquals(new String[] { "subsection", "subsection.subkey", "subsection.subkey2", "subsection.subsubsection", "subsection.subsubsection.key", "key2", "key" }, section.getKeys(true).toArray()); + assertArrayEquals(new String[] { "subkey", "subkey2", "subsubsection", "subsubsection.key" }, section.getConfigurationSection("subsection").getKeys(true).toArray()); } @Test @@ -56,12 +56,12 @@ public abstract class ConfigurationSectionTest { section.set("int", 42); Map shallowValues = section.getValues(false); - assertArrayEquals(new String[] {"bool", "subsection", "int"}, shallowValues.keySet().toArray()); - assertArrayEquals(new Object[] {true, section.getConfigurationSection("subsection"), 42}, shallowValues.values().toArray()); + assertArrayEquals(new String[] { "bool", "subsection", "int" }, shallowValues.keySet().toArray()); + assertArrayEquals(new Object[] { true, section.getConfigurationSection("subsection"), 42 }, shallowValues.values().toArray()); Map deepValues = section.getValues(true); - assertArrayEquals(new String[] {"bool", "subsection", "subsection.string", "subsection.long", "int"}, deepValues.keySet().toArray()); - assertArrayEquals(new Object[] {true, section.getConfigurationSection("subsection"), "test", Long.MAX_VALUE, 42}, deepValues.values().toArray()); + assertArrayEquals(new String[] { "bool", "subsection", "subsection.string", "subsection.long", "int" }, deepValues.keySet().toArray()); + assertArrayEquals(new Object[] { true, section.getConfigurationSection("subsection"), "test", Long.MAX_VALUE, 42 }, deepValues.values().toArray()); } @Test @@ -75,12 +75,12 @@ public abstract class ConfigurationSectionTest { section.addDefault("int", 42); Map shallowValues = section.getValues(false); - assertArrayEquals(new String[] {"subsection", "int", "bool"}, shallowValues.keySet().toArray()); - assertArrayEquals(new Object[] {section.getConfigurationSection("subsection"), 42, true}, shallowValues.values().toArray()); + assertArrayEquals(new String[] { "subsection", "int", "bool" }, shallowValues.keySet().toArray()); + assertArrayEquals(new Object[] { section.getConfigurationSection("subsection"), 42, true }, shallowValues.values().toArray()); Map deepValues = section.getValues(true); - assertArrayEquals(new String[] {"subsection", "subsection.long", "int", "bool", "subsection.string"}, deepValues.keySet().toArray()); - assertArrayEquals(new Object[] {section.getConfigurationSection("subsection"), Long.MAX_VALUE, 42, true, "test"}, deepValues.values().toArray()); + assertArrayEquals(new String[] { "subsection", "subsection.long", "int", "bool", "subsection.string" }, deepValues.keySet().toArray()); + assertArrayEquals(new Object[] { section.getConfigurationSection("subsection"), Long.MAX_VALUE, 42, true, "test" }, deepValues.values().toArray()); } @Test @@ -110,14 +110,14 @@ public abstract class ConfigurationSectionTest { @Test public void testGetCurrentPath() { ConfigurationSection section = getConfigurationSection(); - + assertEquals(section.getName(), section.getCurrentPath()); } @Test public void testGetName() { ConfigurationSection section = getConfigurationSection().createSection("subsection"); - + assertEquals("subsection", section.getName()); assertEquals("", section.getRoot().getName()); } @@ -125,7 +125,7 @@ public abstract class ConfigurationSectionTest { @Test public void testGetRoot() { ConfigurationSection section = getConfigurationSection(); - + assertNotNull(section.getRoot()); assertTrue(section.getRoot().contains(section.getCurrentPath())); } @@ -134,7 +134,7 @@ public abstract class ConfigurationSectionTest { public void testGetParent() { ConfigurationSection section = getConfigurationSection(); ConfigurationSection subsection = section.createSection("subsection"); - + assertEquals(section.getRoot(), section.getParent()); assertEquals(section, subsection.getParent()); } @@ -142,9 +142,9 @@ public abstract class ConfigurationSectionTest { @Test public void testGet_String() { ConfigurationSection section = getConfigurationSection(); - + section.set("exists", "hello world"); - + assertEquals("hello world", section.getString("exists")); assertNull(section.getString("doesntExist")); } @@ -152,9 +152,9 @@ public abstract class ConfigurationSectionTest { @Test public void testGet_String_Object() { ConfigurationSection section = getConfigurationSection(); - + section.set("exists", "Set Value"); - + assertEquals("Set Value", section.get("exists", "Default Value")); assertEquals("Default Value", section.get("doesntExist", "Default Value")); } @@ -162,15 +162,15 @@ public abstract class ConfigurationSectionTest { @Test public void testSet() { ConfigurationSection section = getConfigurationSection(); - + section.set("exists", "hello world"); - + assertTrue(section.contains("exists")); assertTrue(section.isSet("exists")); assertEquals("hello world", section.get("exists")); - + section.set("exists", null); - + assertFalse(section.contains("exists")); assertFalse(section.isSet("exists")); } @@ -179,7 +179,7 @@ public abstract class ConfigurationSectionTest { public void testCreateSection() { ConfigurationSection section = getConfigurationSection(); ConfigurationSection subsection = section.createSection("subsection"); - + assertEquals("subsection", subsection.getName()); } @@ -187,12 +187,12 @@ public abstract class ConfigurationSectionTest { public void testSectionMap() { ConfigurationSection config = getConfigurationSection(); Map testMap = new LinkedHashMap(); - + testMap.put("string", "Hello World"); testMap.put("integer", 15); - + config.createSection("test.path", testMap); - + assertEquals(testMap, config.getConfigurationSection("test.path").getValues(false)); } @@ -201,9 +201,9 @@ public abstract class ConfigurationSectionTest { ConfigurationSection section = getConfigurationSection(); String key = "exists"; String value = "Hello World"; - + section.set(key, value); - + assertEquals(value, section.getString(key)); assertNull(section.getString("doesntExist")); } @@ -214,9 +214,9 @@ public abstract class ConfigurationSectionTest { String key = "exists"; String value = "Hello World"; String def = "Default Value"; - + section.set(key, value); - + assertEquals(value, section.getString(key, def)); assertEquals(def, section.getString("doesntExist", def)); } @@ -226,22 +226,21 @@ public abstract class ConfigurationSectionTest { ConfigurationSection section = getConfigurationSection(); String key = "exists"; String value = "Hello World"; - + section.set(key, value); - + assertTrue(section.isString(key)); assertFalse(section.isString("doesntExist")); } - @Test public void testGetInt_String() { ConfigurationSection section = getConfigurationSection(); String key = "exists"; int value = Integer.MAX_VALUE; - + section.set(key, value); - + assertEquals(value, section.getInt(key)); assertNull(section.getString("doesntExist")); } @@ -252,9 +251,9 @@ public abstract class ConfigurationSectionTest { String key = "exists"; int value = Integer.MAX_VALUE; int def = Integer.MIN_VALUE; - + section.set(key, value); - + assertEquals(value, section.getInt(key, def)); assertEquals(def, section.getInt("doesntExist", def)); } @@ -264,22 +263,21 @@ public abstract class ConfigurationSectionTest { ConfigurationSection section = getConfigurationSection(); String key = "exists"; int value = Integer.MAX_VALUE; - + section.set(key, value); - + assertTrue(section.isInt(key)); assertFalse(section.isInt("doesntExist")); } - @Test public void testGetBoolean_String() { ConfigurationSection section = getConfigurationSection(); String key = "exists"; boolean value = true; - + section.set(key, value); - + assertEquals(value, section.getBoolean(key)); assertNull(section.getString("doesntExist")); } @@ -290,9 +288,9 @@ public abstract class ConfigurationSectionTest { String key = "exists"; boolean value = true; boolean def = false; - + section.set(key, value); - + assertEquals(value, section.getBoolean(key, def)); assertEquals(def, section.getBoolean("doesntExist", def)); } @@ -302,14 +300,13 @@ public abstract class ConfigurationSectionTest { ConfigurationSection section = getConfigurationSection(); String key = "exists"; boolean value = true; - + section.set(key, value); - + assertTrue(section.isBoolean(key)); assertFalse(section.isBoolean("doesntExist")); } - @Test public void testGetDouble_String() { ConfigurationSection section = getConfigurationSection(); @@ -328,7 +325,7 @@ public abstract class ConfigurationSectionTest { String key = "exists"; double value = 123; - section.set(key, (int)value); + section.set(key, (int) value); assertEquals(value, section.getDouble(key), 1); assertNull(section.getString("doesntExist")); @@ -340,9 +337,9 @@ public abstract class ConfigurationSectionTest { String key = "exists"; double value = Double.MAX_VALUE; double def = Double.MIN_VALUE; - + section.set(key, value); - + assertEquals(value, section.getDouble(key, def), 1); assertEquals(def, section.getDouble("doesntExist", def), 1); } @@ -352,22 +349,21 @@ public abstract class ConfigurationSectionTest { ConfigurationSection section = getConfigurationSection(); String key = "exists"; double value = Double.MAX_VALUE; - + section.set(key, value); - + assertTrue(section.isDouble(key)); assertFalse(section.isDouble("doesntExist")); } - @Test public void testGetLong_String() { ConfigurationSection section = getConfigurationSection(); String key = "exists"; long value = Long.MAX_VALUE; - + section.set(key, value); - + assertEquals(value, section.getLong(key)); assertNull(section.getString("doesntExist")); } @@ -378,9 +374,9 @@ public abstract class ConfigurationSectionTest { String key = "exists"; long value = Long.MAX_VALUE; long def = Long.MIN_VALUE; - + section.set(key, value); - + assertEquals(value, section.getLong(key, def)); assertEquals(def, section.getLong("doesntExist", def)); } @@ -390,37 +386,36 @@ public abstract class ConfigurationSectionTest { ConfigurationSection section = getConfigurationSection(); String key = "exists"; long value = Long.MAX_VALUE; - + section.set(key, value); - + assertTrue(section.isLong(key)); assertFalse(section.isLong("doesntExist")); } - @Test public void testGetList_String() { ConfigurationSection section = getConfigurationSection(); String key = "exists"; Map map = new HashMap(); - + map.put("one", 1); map.put("two", "two"); map.put("three", 3.14); - - List value = Arrays.asList((Object)"One", "Two", "Three", 4, "5", 6.0, true, "false", map); - + + List value = Arrays.asList((Object) "One", "Two", "Three", 4, "5", 6.0, true, "false", map); + section.set(key, value); - + assertEquals(value, section.getList(key)); - assertEquals(Arrays.asList((Object)"One", "Two", "Three", "4", "5", "6.0", "true", "false"), section.getStringList(key)); - assertEquals(Arrays.asList((Object)4, 5, 6), section.getIntegerList(key)); - assertEquals(Arrays.asList((Object)true, false), section.getBooleanList(key)); - assertEquals(Arrays.asList((Object)4.0, 5.0, 6.0), section.getDoubleList(key)); - assertEquals(Arrays.asList((Object)4.0f, 5.0f, 6.0f), section.getFloatList(key)); - assertEquals(Arrays.asList((Object)4l, 5l, 6l), section.getLongList(key)); - assertEquals(Arrays.asList((Object)(byte)4, (byte)5, (byte)6), section.getByteList(key)); - assertEquals(Arrays.asList((Object)(short)4, (short)5, (short)6), section.getShortList(key)); + assertEquals(Arrays.asList((Object) "One", "Two", "Three", "4", "5", "6.0", "true", "false"), section.getStringList(key)); + assertEquals(Arrays.asList((Object) 4, 5, 6), section.getIntegerList(key)); + assertEquals(Arrays.asList((Object) true, false), section.getBooleanList(key)); + assertEquals(Arrays.asList((Object) 4.0, 5.0, 6.0), section.getDoubleList(key)); + assertEquals(Arrays.asList((Object) 4.0f, 5.0f, 6.0f), section.getFloatList(key)); + assertEquals(Arrays.asList((Object) 4l, 5l, 6l), section.getLongList(key)); + assertEquals(Arrays.asList((Object) (byte) 4, (byte) 5, (byte) 6), section.getByteList(key)); + assertEquals(Arrays.asList((Object) (short) 4, (short) 5, (short) 6), section.getShortList(key)); assertEquals(map, section.getMapList(key).get(0)); assertNull(section.getString("doesntExist")); } @@ -429,11 +424,11 @@ public abstract class ConfigurationSectionTest { public void testGetList_String_List() { ConfigurationSection section = getConfigurationSection(); String key = "exists"; - List value = Arrays.asList("One", "Two", "Three"); - List def = Arrays.asList("A", "B", "C"); - + List value = Arrays.asList("One", "Two", "Three"); + List def = Arrays.asList("A", "B", "C"); + section.set(key, value); - + assertEquals(value, section.getList(key, def)); assertEquals(def, section.getList("doesntExist", def)); } @@ -442,23 +437,22 @@ public abstract class ConfigurationSectionTest { public void testIsList() { ConfigurationSection section = getConfigurationSection(); String key = "exists"; - List value = Arrays.asList("One", "Two", "Three"); - + List value = Arrays.asList("One", "Two", "Three"); + section.set(key, value); - + assertTrue(section.isList(key)); assertFalse(section.isList("doesntExist")); } - @Test public void testGetVector_String() { ConfigurationSection section = getConfigurationSection(); String key = "exists"; Vector value = new Vector(Double.MIN_VALUE, Double.MAX_VALUE, 5); - + section.set(key, value); - + assertEquals(value, section.getVector(key)); assertNull(section.getString("doesntExist")); } @@ -469,9 +463,9 @@ public abstract class ConfigurationSectionTest { String key = "exists"; Vector value = new Vector(Double.MIN_VALUE, Double.MAX_VALUE, 5); Vector def = new Vector(100, Double.MIN_VALUE, Double.MAX_VALUE); - + section.set(key, value); - + assertEquals(value, section.getVector(key, def)); assertEquals(def, section.getVector("doesntExist", def)); } @@ -481,9 +475,9 @@ public abstract class ConfigurationSectionTest { ConfigurationSection section = getConfigurationSection(); String key = "exists"; Vector value = new Vector(Double.MIN_VALUE, Double.MAX_VALUE, 5); - + section.set(key, value); - + assertTrue(section.isVector(key)); assertFalse(section.isVector("doesntExist")); } @@ -492,10 +486,10 @@ public abstract class ConfigurationSectionTest { public void testGetItemStack_String() { ConfigurationSection section = getConfigurationSection(); String key = "exists"; - ItemStack value = new ItemStack(Material.WOOD, 50, (short)2); - + ItemStack value = new ItemStack(Material.WOOD, 50, (short) 2); + section.set(key, value); - + assertEquals(value, section.getItemStack(key)); assertNull(section.getString("doesntExist")); } @@ -504,11 +498,11 @@ public abstract class ConfigurationSectionTest { public void testGetItemStack_String_ItemStack() { ConfigurationSection section = getConfigurationSection(); String key = "exists"; - ItemStack value = new ItemStack(Material.WOOD, 50, (short)2); + ItemStack value = new ItemStack(Material.WOOD, 50, (short) 2); ItemStack def = new ItemStack(Material.STONE, 1); - + section.set(key, value); - + assertEquals(value, section.getItemStack(key, def)); assertEquals(def, section.getItemStack("doesntExist", def)); } @@ -517,10 +511,10 @@ public abstract class ConfigurationSectionTest { public void testIsItemStack() { ConfigurationSection section = getConfigurationSection(); String key = "exists"; - ItemStack value = new ItemStack(Material.WOOD, 50, (short)2); - + ItemStack value = new ItemStack(Material.WOOD, 50, (short) 2); + section.set(key, value); - + assertTrue(section.isItemStack(key)); assertFalse(section.isItemStack("doesntExist")); } @@ -529,9 +523,9 @@ public abstract class ConfigurationSectionTest { public void testGetConfigurationSection() { ConfigurationSection section = getConfigurationSection(); String key = "exists"; - + ConfigurationSection subsection = section.createSection(key); - + assertEquals(subsection, section.getConfigurationSection(key)); } @@ -539,9 +533,9 @@ public abstract class ConfigurationSectionTest { public void testIsConfigurationSection() { ConfigurationSection section = getConfigurationSection(); String key = "exists"; - - ConfigurationSection subsection = section.createSection(key); - + + section.createSection(key); + assertTrue(section.isConfigurationSection(key)); assertFalse(section.isConfigurationSection("doesntExist")); } -- cgit v1.2.3