-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3127 from Multiverse/ben/mv5/testssss
More testsss
- Loading branch information
Showing
9 changed files
with
358 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 8 additions & 4 deletions
12
src/test/java/org/mvplugins/multiverse/core/TestWithMockBukkit.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/test/java/org/mvplugins/multiverse/core/commands/VersionCommandTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/test/java/org/mvplugins/multiverse/core/mock/MVServerMock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package org.mvplugins.multiverse.core.mock; | ||
|
||
import org.bukkit.World; | ||
import org.bukkit.WorldCreator; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.mockbukkit.mockbukkit.ServerMock; | ||
import org.mockbukkit.mockbukkit.command.CommandMapMock; | ||
import org.mockbukkit.mockbukkit.world.WorldMock; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
|
||
public class MVServerMock extends ServerMock { | ||
|
||
private final File worldContainer; | ||
|
||
public MVServerMock() throws IOException { | ||
super(); | ||
this.worldContainer = Files.createTempDirectory("world-container").toFile(); | ||
this.worldContainer.deleteOnExit(); | ||
System.out.println("Created test world folder: " + this.worldContainer.getAbsolutePath()); | ||
} | ||
|
||
// This is required for acf reflection to work | ||
@Override | ||
public @NotNull CommandMapMock getCommandMap() { | ||
return super.getCommandMap(); | ||
} | ||
|
||
@Override | ||
public @NotNull File getWorldContainer() { | ||
return this.worldContainer; | ||
} | ||
|
||
@Override | ||
public World createWorld(@NotNull WorldCreator creator) { | ||
WorldMock world = new MVWorldMock(creator); | ||
world.getWorldFolder().mkdirs(); | ||
createFile(new File(world.getWorldFolder(), "uid.dat")); | ||
createFile(new File(world.getWorldFolder(), "level.dat")); | ||
addWorld(world); | ||
return world; | ||
} | ||
|
||
private void createFile(File file) { | ||
try { | ||
file.createNewFile(); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/test/java/org/mvplugins/multiverse/core/mock/MVWorldMock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.mvplugins.multiverse.core.mock; | ||
|
||
import org.bukkit.WorldCreator; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.mockbukkit.mockbukkit.MockBukkit; | ||
import org.mockbukkit.mockbukkit.world.WorldMock; | ||
|
||
import java.io.File; | ||
|
||
public class MVWorldMock extends WorldMock { | ||
|
||
private final File worldFolder; | ||
private final boolean generateStructures; | ||
|
||
public MVWorldMock(@NotNull WorldCreator creator) { | ||
super(creator); | ||
this.worldFolder = new File(MockBukkit.getMock().getWorldContainer(), getName()); | ||
this.generateStructures = creator.generateStructures(); | ||
} | ||
|
||
@Override | ||
public @NotNull File getWorldFolder() { | ||
return this.worldFolder; | ||
} | ||
|
||
@Override | ||
public boolean canGenerateStructures() { | ||
return this.generateStructures; | ||
} | ||
} |
Oops, something went wrong.