Search in sources :

Example 6 with World

use of mudmap2.backend.World in project mudmap2 by Neop.

the class WorldFileDefaultTest method testReadWorldName.

/**
 * Test of readWorldName method, of class WorldFileDefault.
 */
@Test
public void testReadWorldName() throws Exception {
    System.out.println("readWorldName");
    String worldName = "foobar";
    World world = new World(worldName);
    String wfjFile = folder.getRoot() + "/wfj";
    String wfmm1File = folder.getRoot() + "/wfmm1";
    try {
        WorldFileJSON wfj = new WorldFileJSON(wfjFile);
        wfj.writeFile(world);
        WorldFileJSON wfmm1 = new WorldFileJSON(wfmm1File);
        wfmm1.writeFile(world);
    } catch (IOException ex) {
        Logger.getLogger(WorldFileJSONTest.class.getName()).log(Level.SEVERE, null, ex);
        fail("Could not create files for test");
    }
    try {
        WorldFileDefault instance1 = new WorldFileDefault(wfjFile);
        String result1 = instance1.readWorldName();
        assertEquals(worldName, result1);
        WorldFileDefault instance2 = new WorldFileDefault(wfmm1File);
        String result2 = instance2.readWorldName();
        assertEquals(worldName, result2);
    } catch (Exception ex) {
        Logger.getLogger(WorldFileJSONTest.class.getName()).log(Level.SEVERE, null, ex);
        fail();
    }
}
Also used : IOException(java.io.IOException) World(mudmap2.backend.World) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) Test(org.junit.Test)

Example 7 with World

use of mudmap2.backend.World in project mudmap2 by Neop.

the class WorldFileDefaultTest method testBackup.

/**
 * Test of backup method, of class WorldFileDefault.
 */
@Test
public void testBackup() throws Exception {
    System.out.println("backup");
    try {
        String wfFile = folder.getRoot() + "/wfj";
        WorldFileDefault instance = new WorldFileDefault(wfFile);
        // don't write world
        // instance.writeFile(new World("Foo Bar"));
        instance.backup();
        File f1 = new File(wfFile);
        File f2 = new File(wfFile + ".bak");
        assertTrue(FileUtils.contentEquals(f1, f2));
    } catch (FileNotFoundException ex) {
        Logger.getLogger(WorldFileJSONTest.class.getName()).log(Level.SEVERE, null, ex);
        fail();
    }
    try {
        String wfFile = folder.getRoot() + "/wfj";
        WorldFileDefault instance = new WorldFileDefault(wfFile);
        // write world
        instance.writeFile(new World("Foo Bar"));
        instance.backup();
        File f1 = new File(wfFile);
        File f2 = new File(wfFile + ".bak");
        assertTrue(FileUtils.contentEquals(f1, f2));
    } catch (FileNotFoundException ex) {
        Logger.getLogger(WorldFileJSONTest.class.getName()).log(Level.SEVERE, null, ex);
        fail();
    }
}
Also used : FileNotFoundException(java.io.FileNotFoundException) World(mudmap2.backend.World) WorldFile(mudmap2.backend.WorldFileReader.WorldFile) File(java.io.File) Test(org.junit.Test)

Example 8 with World

use of mudmap2.backend.World in project mudmap2 by Neop.

the class WorldFileJSONTest method testCanRead.

/**
 * Test of canRead method, of class WorldFileJSON.
 */
@Test
public void testCanRead() {
    System.out.println("canRead");
    World world = new World("foobar");
    String wfjFile = folder.getRoot() + "/wfj";
    try {
        WorldFileJSON wfj = new WorldFileJSON(wfjFile);
        wfj.writeFile(world);
    } catch (IOException ex) {
        Logger.getLogger(WorldFileJSONTest.class.getName()).log(Level.SEVERE, null, ex);
        fail("Could not create files for test");
    }
    WorldFileJSON instancewfj = new WorldFileJSON(wfjFile);
    Boolean result = instancewfj.canRead();
    assertTrue(result);
}
Also used : IOException(java.io.IOException) World(mudmap2.backend.World) Test(org.junit.Test)

Example 9 with World

use of mudmap2.backend.World in project mudmap2 by Neop.

the class WorldFileJSONTest method testBackup.

/**
 * Test of backup method, of class WorldFileJSON.
 * @throws java.io.IOException
 */
@Test
public void testBackup() throws IOException {
    System.out.println("backup");
    try {
        String wfjFile = folder.getRoot() + "/wfj";
        WorldFileJSON instance = new WorldFileJSON(wfjFile);
        // don't write world
        // instance.writeFile(new World("Foo Bar"));
        instance.backup();
        File f1 = new File(wfjFile);
        File f2 = new File(wfjFile + ".bak");
        assertTrue(FileUtils.contentEquals(f1, f2));
    } catch (FileNotFoundException ex) {
        Logger.getLogger(WorldFileJSONTest.class.getName()).log(Level.SEVERE, null, ex);
        fail();
    }
    try {
        String wfjFile = folder.getRoot() + "/wfj";
        WorldFileJSON instance = new WorldFileJSON(wfjFile);
        // write world
        instance.writeFile(new World("Foo Bar"));
        instance.backup();
        File f1 = new File(wfjFile);
        File f2 = new File(wfjFile + ".bak");
        assertTrue(FileUtils.contentEquals(f1, f2));
    } catch (FileNotFoundException ex) {
        Logger.getLogger(WorldFileJSONTest.class.getName()).log(Level.SEVERE, null, ex);
        fail();
    }
}
Also used : FileNotFoundException(java.io.FileNotFoundException) World(mudmap2.backend.World) File(java.io.File) Test(org.junit.Test)

Example 10 with World

use of mudmap2.backend.World in project mudmap2 by Neop.

the class WorldPanelTest method testGetWorld.

/**
 * Test of getWorld method, of class WorldPanel.
 */
@Test
public void testGetWorld() {
    System.out.println("getWorld");
    World world = new World();
    WorldPanel instance = new WorldPanel(null, world, false);
    assertEquals(world, instance.getWorld());
}
Also used : World(mudmap2.backend.World) Test(org.junit.Test)

Aggregations

World (mudmap2.backend.World)31 Test (org.junit.Test)27 IOException (java.io.IOException)11 FileNotFoundException (java.io.FileNotFoundException)9 Place (mudmap2.backend.Place)9 File (java.io.File)7 WorldFileDefault (mudmap2.backend.WorldFileReader.current.WorldFileDefault)7 Layer (mudmap2.backend.Layer)6 Path (mudmap2.backend.Path)6 WorldCoordinate (mudmap2.backend.WorldCoordinate)6 Color (java.awt.Color)5 HashMap (java.util.HashMap)5 WorldFile (mudmap2.backend.WorldFileReader.WorldFile)5 PlaceGroup (mudmap2.backend.PlaceGroup)4 ActionEvent (java.awt.event.ActionEvent)3 ActionListener (java.awt.event.ActionListener)3 Map (java.util.Map)3 JLabel (javax.swing.JLabel)3 RiskLevel (mudmap2.backend.RiskLevel)3 BorderLayout (java.awt.BorderLayout)2