diff --git a/util/src/test/org/apollo/util/TestBufferUtil.java b/util/src/test/org/apollo/util/BufferUtilTests.java similarity index 50% rename from util/src/test/org/apollo/util/TestBufferUtil.java rename to util/src/test/org/apollo/util/BufferUtilTests.java index ffbe5491..8f001282 100644 --- a/util/src/test/org/apollo/util/TestBufferUtil.java +++ b/util/src/test/org/apollo/util/BufferUtilTests.java @@ -1,17 +1,65 @@ package org.apollo.util; -import static org.junit.Assert.assertEquals; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; +import org.junit.Test; import java.nio.ByteBuffer; -import org.junit.Test; +import static org.junit.Assert.assertEquals; /** - * Contains tests for {@link BufferUtil}. + * Contains unit tests for {@link BufferUtil}s. * * @author Graham */ -public class TestBufferUtil { +public final class BufferUtilTests { + + /** + * Test the {@link BufferUtil#readString(ByteBuf)} method. + */ + @Test + public void readByteBufString() { + ByteBuf buf = Unpooled.buffer(6); + buf.writeBytes(new byte[]{ 'H', 'e', 'l', 'l', 'o', 10 }); + String str = BufferUtil.readString(buf); + assertEquals("Hello", str); + + buf = Unpooled.buffer(5); + buf.writeBytes(new byte[]{ 'W', 'o', 'r', 'l', 'd' }); + str = BufferUtil.readString(buf); + assertEquals("World", str); + + buf = Unpooled.buffer(3); + buf.writeByte('!'); + buf.writeByte(10); + buf.writeByte('.'); + + str = BufferUtil.readString(buf); + assertEquals("!", str); + + str = BufferUtil.readString(buf); + assertEquals(".", str); + } + + /** + * Tests the {@link BufferUtil#readString(ByteBuffer)} method. + */ + @Test + public void readByteBufferString() { + ByteBuffer buf = ByteBuffer.allocate(8); + buf.put((byte) 'h'); + buf.put((byte) 'e'); + buf.put((byte) 'l'); + buf.put((byte) 'l'); + buf.put((byte) 'o'); + buf.put((byte) BufferUtil.STRING_TERMINATOR); + buf.put((byte) 66); + buf.put((byte) 6); + buf.flip(); + + assertEquals("hello", BufferUtil.readString(buf)); + } /** * Tests the {@link BufferUtil#readUnsignedMedium} method. @@ -27,23 +75,4 @@ public class TestBufferUtil { assertEquals(8072515, BufferUtil.readUnsignedMedium(buf)); } - /** - * Tests the {@link BufferUtil#readString(ByteBuffer)} method. - */ - @Test - public void testReadString() { - ByteBuffer buf = ByteBuffer.allocate(8); - buf.put((byte) 'h'); - buf.put((byte) 'e'); - buf.put((byte) 'l'); - buf.put((byte) 'l'); - buf.put((byte) 'o'); - buf.put((byte) BufferUtil.STRING_TERMINATOR); - buf.put((byte) 66); - buf.put((byte) 6); - buf.flip(); - - assertEquals("hello", BufferUtil.readString(buf)); - } - } \ No newline at end of file diff --git a/util/src/test/org/apollo/util/TestCompressionUtil.java b/util/src/test/org/apollo/util/CompressionUtilTests.java similarity index 91% rename from util/src/test/org/apollo/util/TestCompressionUtil.java rename to util/src/test/org/apollo/util/CompressionUtilTests.java index a164cd20..68fd83ff 100644 --- a/util/src/test/org/apollo/util/TestCompressionUtil.java +++ b/util/src/test/org/apollo/util/CompressionUtilTests.java @@ -1,17 +1,17 @@ package org.apollo.util; -import static org.junit.Assert.assertEquals; - -import java.io.IOException; - import org.junit.Test; +import java.io.IOException; + +import static org.junit.Assert.assertEquals; + /** - * Contains tests for {@link CompressionUtil}. + * Contains unit tests for {@link CompressionUtil}s. * * @author Graham */ -public class TestCompressionUtil { +public class CompressionUtilTests { /** * Tests the {@link CompressionUtil#bzip2(byte[])} and {@link CompressionUtil#debzip2} methods. diff --git a/util/src/test/org/apollo/util/TestLanguageUtil.java b/util/src/test/org/apollo/util/LanguageUtilTests.java similarity index 85% rename from util/src/test/org/apollo/util/TestLanguageUtil.java rename to util/src/test/org/apollo/util/LanguageUtilTests.java index 7178da0b..8c3219e6 100644 --- a/util/src/test/org/apollo/util/TestLanguageUtil.java +++ b/util/src/test/org/apollo/util/LanguageUtilTests.java @@ -1,15 +1,15 @@ package org.apollo.util; -import static org.junit.Assert.assertEquals; - import org.junit.Test; +import static org.junit.Assert.assertEquals; + /** - * Contains tests for {@link LanguageUtil}. + * Contains unit tests for {@link LanguageUtil}s. * * @author Graham */ -public class TestLanguageUtil { +public class LanguageUtilTests { /** * Tests the {@link LanguageUtil#getIndefiniteArticle} method. diff --git a/util/src/test/org/apollo/util/TestByteBufUtil.java b/util/src/test/org/apollo/util/TestByteBufUtil.java deleted file mode 100644 index 675ece76..00000000 --- a/util/src/test/org/apollo/util/TestByteBufUtil.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.apollo.util; - -import static org.junit.Assert.assertEquals; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; - -import org.junit.Test; - -/** - * Contains tests for {@link ByteBuf} methods in {@link BufferUtil}. - * - * @author Graham - */ -public final class TestByteBufUtil { - - /** - * Test the {@link BufferUtil#readString(ByteBuf)} method. - */ - @Test - public void testReadString() { - ByteBuf buf = Unpooled.buffer(6); - buf.writeBytes(new byte[] { 'H', 'e', 'l', 'l', 'o', 10 }); - String str = BufferUtil.readString(buf); - assertEquals("Hello", str); - - buf = Unpooled.buffer(5); - buf.writeBytes(new byte[] { 'W', 'o', 'r', 'l', 'd' }); - str = BufferUtil.readString(buf); - assertEquals("World", str); - - buf = Unpooled.buffer(3); - buf.writeByte('!'); - buf.writeByte(10); - buf.writeByte('.'); - - str = BufferUtil.readString(buf); - assertEquals("!", str); - - str = BufferUtil.readString(buf); - assertEquals(".", str); - } - -} \ No newline at end of file diff --git a/util/src/test/org/apollo/util/TestTextUtil.java b/util/src/test/org/apollo/util/TextUtilTests.java similarity index 93% rename from util/src/test/org/apollo/util/TestTextUtil.java rename to util/src/test/org/apollo/util/TextUtilTests.java index 7a664a9b..b7b637dc 100644 --- a/util/src/test/org/apollo/util/TestTextUtil.java +++ b/util/src/test/org/apollo/util/TextUtilTests.java @@ -1,15 +1,15 @@ package org.apollo.util; -import static org.junit.Assert.assertEquals; - import org.junit.Test; +import static org.junit.Assert.assertEquals; + /** - * A test for the {@link TextUtil} class. + * Contains unit tests for {@link TextUtil}s. * * @author Graham */ -public class TestTextUtil { +public class TextUtilTests { /** * Tests the {@link TextUtil#capitalize} method. diff --git a/util/src/test/org/apollo/util/xml/TestXmlParser.java b/util/src/test/org/apollo/util/xml/XmlParserTests.java similarity index 79% rename from util/src/test/org/apollo/util/xml/TestXmlParser.java rename to util/src/test/org/apollo/util/xml/XmlParserTests.java index 0d9bc370..bbc59fb3 100644 --- a/util/src/test/org/apollo/util/xml/TestXmlParser.java +++ b/util/src/test/org/apollo/util/xml/XmlParserTests.java @@ -1,9 +1,7 @@ package org.apollo.util.xml; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import org.junit.Test; +import org.xml.sax.SAXException; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -12,15 +10,17 @@ import java.io.Reader; import java.io.StringReader; import java.util.Set; -import org.junit.Test; -import org.xml.sax.SAXException; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; /** - * A test for the {@link XmlParser} class. + * Contains unit tests for {@link XmlParser}s. * * @author Graham */ -public final class TestXmlParser { +public final class XmlParserTests { /** * A test for the {@link XmlParser#parse} method. @@ -34,9 +34,9 @@ public final class TestXmlParser { InputStream input = new ByteArrayInputStream("".getBytes()); XmlNode root = parser.parse(input); - assertEquals(root.getName(), "root"); - assertEquals(root.getAttributeCount(), 3); - assertEquals(root.getChildCount(), 1); + assertEquals("root", root.getName()); + assertEquals(3, root.getAttributeCount()); + assertEquals(1, root.getChildCount()); assertFalse(root.hasValue()); Set names = root.getAttributeNames(); @@ -81,24 +81,24 @@ public final class TestXmlParser { Reader reader = new StringReader("123"); XmlNode root = parser.parse(reader); - assertEquals(root.getName(), "alphabet"); - assertEquals(root.getAttributeCount(), 0); - assertEquals(root.getChildCount(), 3); + assertEquals("alphabet", root.getName()); + assertEquals(0, root.getAttributeCount()); + assertEquals(3, root.getChildCount()); assertFalse(root.hasValue()); XmlNode[] children = root.getChildren().toArray(new XmlNode[3]); - assertEquals(children[0].getName(), "a"); - assertEquals(children[1].getName(), "b"); - assertEquals(children[2].getName(), "c"); + assertEquals("a", children[0].getName()); + assertEquals("b", children[1].getName()); + assertEquals("c", children[2].getName()); - assertEquals(children[0].getValue(), "1"); - assertEquals(children[1].getValue(), "2"); - assertEquals(children[2].getValue(), "3"); + assertEquals("1", children[0].getValue()); + assertEquals("2", children[1].getValue()); + assertEquals("3", children[2].getValue()); for (int index = 0; index < 3; index++) { assertTrue(children[index].hasValue()); - assertEquals(children[index].getAttributeCount(), 0); + assertEquals(0, children[index].getAttributeCount()); } }