mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2024-09-12 13:19:33 +00:00
35 lines
1.2 KiB
Java
35 lines
1.2 KiB
Java
package com.earth2me.essentials;
|
|
|
|
import junit.framework.TestCase;
|
|
import com.earth2me.essentials.settings.Settings;
|
|
import com.earth2me.essentials.storage.StorageObject;
|
|
import java.io.ByteArrayInputStream;
|
|
import java.io.ByteArrayOutputStream;
|
|
import java.io.InputStreamReader;
|
|
import java.io.PrintWriter;
|
|
import java.io.Reader;
|
|
import org.junit.Test;
|
|
|
|
|
|
public class StorageTest extends TestCase
|
|
{
|
|
@Test
|
|
public void testSettings()
|
|
{
|
|
assertTrue(StorageObject.class.isAssignableFrom(Settings.class));
|
|
final ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]);
|
|
final Reader reader = new InputStreamReader(bais);
|
|
final Settings settings = StorageObject.load(Settings.class, reader);
|
|
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
final PrintWriter writer = new PrintWriter(baos);
|
|
settings.save(writer);
|
|
writer.close();
|
|
byte[] written = baos.toByteArray();
|
|
System.out.println(new String(written));
|
|
final ByteArrayInputStream bais2 = new ByteArrayInputStream(written);
|
|
final Reader reader2 = new InputStreamReader(bais2);
|
|
final Settings settings2 = StorageObject.load(Settings.class, reader2);
|
|
assertEquals("Default and rewritten config should be equal", settings, settings2);
|
|
}
|
|
}
|