mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-16 23:55:23 +01:00
Added AttributeTest.
This commit is contained in:
parent
5bfb9e48f4
commit
a13f556c7b
@ -43,7 +43,7 @@
|
||||
* To create your own attributes, see the class documentation for
|
||||
* {@link DataValuedAttribute}.
|
||||
*/
|
||||
public abstract class Attribute {
|
||||
public class Attribute {
|
||||
|
||||
private String name;
|
||||
|
||||
|
83
src/test/java/com/sk89q/worldguard/region/AttributeTest.java
Normal file
83
src/test/java/com/sk89q/worldguard/region/AttributeTest.java
Normal file
@ -0,0 +1,83 @@
|
||||
// $Id$
|
||||
/*
|
||||
* This file is a part of WorldGuard.
|
||||
* Copyright (c) sk89q <http://www.sk89q.com>
|
||||
* Copyright (c) the WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY), without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.region;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class AttributeTest {
|
||||
|
||||
private static Attribute makeAttribute(String name) {
|
||||
Attribute attribute = new Attribute();
|
||||
attribute.setName(name);
|
||||
return attribute;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHashCode() {
|
||||
assertEquals(makeAttribute("testing").hashCode(), "testing".hashCode());
|
||||
assertFalse(makeAttribute("broken").hashCode() == "testing".hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAttribute() {
|
||||
makeAttribute("testing");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetName() {
|
||||
assertEquals(makeAttribute("testing").getName(), "testing");
|
||||
assertFalse(makeAttribute("testing").getName().equals("broken"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetName() {
|
||||
assertEquals(makeAttribute("testing").getName(), "testing");
|
||||
assertFalse(makeAttribute("testing").getName().equals("broken"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRead() throws IOException {
|
||||
Attribute attribute = makeAttribute("testing");
|
||||
byte[] data = new byte[] { 1, 2, 3, 4, 5, 6 };
|
||||
attribute.read(new DataInputStream(new ByteArrayInputStream(data)), data.length); // Do nothing
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWrite() throws IOException {
|
||||
Attribute attribute = makeAttribute("testing");
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream(100);
|
||||
attribute.write(new DataOutputStream(stream)); // Do nothing
|
||||
assertEquals(stream.size(), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsObject() {
|
||||
assertTrue(makeAttribute("testing").equals(makeAttribute("testing")));
|
||||
assertFalse(makeAttribute("testing").equals(makeAttribute("broken")));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user