Java Code Examples for codechicken.lib.config.ConfigTag#copy()

The following examples show how to use codechicken.lib.config.ConfigTag#copy() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConfigTests.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testCopy() throws Throwable {
    Path dir = Files.createTempDirectory("copy_test");
    Path testFile = dir.resolve("test.cfg");
    copyTestFile(testFile);
    ConfigTag configA = new StandardConfigFile(testFile).load();
    ConfigTag configB = configA.copy();
    ensureSame(configA, configB);
}
 
Example 2
Source File: ConfigTests.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test (expected = ConfigTestException.class)
public void testCopyFail() throws Throwable {
    Path dir = Files.createTempDirectory("copy_test_fail");
    Path testFile = dir.resolve("test.cfg");
    copyTestFile(testFile);
    ConfigTag configA = new StandardConfigFile(testFile).load();
    ConfigTag configB = configA.copy();
    configB.setTagVersion("boop");
    ConfigTag tag1 = configB.getTag("Tag1");
    tag1.getTag("string").setString("nope");
    tag1.getTag("boolean_array").getBooleanList().clear();
    ensureSame(configA, configB);
}
 
Example 3
Source File: ConfigTests.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testCopyFrom() throws Throwable {
    Path dir = Files.createTempDirectory("copy_from_test");
    Path testFile = dir.resolve("test.cfg");
    copyTestFile(testFile);
    ConfigTag configA = new StandardConfigFile(testFile).load();
    ConfigTag configB = configA.copy();
    ConfigTag tag1 = configB.getTag("Tag1");
    tag1.getTag("string").setString("nope");
    tag1.getTag("boolean_array").getBooleanList().clear();
    configB.copyFrom(configA);
    ensureSame(configA, configB);
}
 
Example 4
Source File: ConfigTests.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test (expected = IllegalArgumentException.class)
public void testCopyFromFail() throws Throwable {
    Path dir = Files.createTempDirectory("copy_from_fail_test");
    Path testFile = dir.resolve("test.cfg");
    copyTestFile(testFile);
    ConfigTag configA = new StandardConfigFile(testFile).load();
    ConfigTag configB = configA.copy();
    configA.deleteTag("Tag1");
    configB.copyFrom(configA);
    ensureSame(configA, configB);
}
 
Example 5
Source File: ConfigTests.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testWriteReadStream() throws Throwable {
    Path dir = Files.createTempDirectory("write_read_stream_test");
    Path testFile = dir.resolve("test.cfg");
    copyTestFile(testFile);
    ConfigTag configA = new StandardConfigFile(testFile).load();
    ConfigTag configB = configA.copy();
    MCDataByteBuf byteStream = new MCDataByteBuf(Unpooled.buffer());
    configA.write(byteStream);
    ConfigTag tag1 = configB.getTag("Tag1");
    tag1.getTag("string").setString("nope");
    tag1.getTag("boolean_array").getBooleanList().clear();
    configB.read(byteStream);
    ensureSame(configA, configB);
}
 
Example 6
Source File: ConfigTests.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test (expected = IllegalArgumentException.class)
public void testWriteReadStreamFail() throws Throwable {
    Path dir = Files.createTempDirectory("write_read_stream_test_fail");
    Path testFile = dir.resolve("test.cfg");
    copyTestFile(testFile);
    ConfigTag configA = new StandardConfigFile(testFile).load();
    ConfigTag configB = configA.copy();
    MCDataByteBuf byteStream = new MCDataByteBuf(Unpooled.buffer());
    configA.write(byteStream);
    configB.deleteTag("Tag1");
    configB.read(byteStream);
    ensureSame(configA, configB);
}