mirror of
https://e.coding.net/circlecloud/YumCore.git
synced 2025-09-03 11:46:58 +00:00
146
src/test/java/pw/yumc/YumCore/plugin/FakePlugin.java
Normal file
146
src/test/java/pw/yumc/YumCore/plugin/FakePlugin.java
Normal file
@ -0,0 +1,146 @@
|
||||
package pw.yumc.YumCore.plugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.PluginLoader;
|
||||
|
||||
import com.avaje.ebean.EbeanServer;
|
||||
|
||||
/**
|
||||
* @author 喵♂呜
|
||||
* @since 2017/6/2
|
||||
*/
|
||||
public class FakePlugin implements Plugin {
|
||||
private String name;
|
||||
private String version;
|
||||
private String mainclass;
|
||||
private PluginDescriptionFile descriptionFile;
|
||||
|
||||
public FakePlugin(String name, String version) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.version = version;
|
||||
this.mainclass = getClass().getName();
|
||||
this.descriptionFile = new PluginDescriptionFile(name, version, mainclass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getDataFolder() {
|
||||
return new File(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginDescriptionFile getDescription() {
|
||||
return descriptionFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileConfiguration getConfig() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getResource(String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveConfig() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveDefaultConfig() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveResource(String s, boolean b) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginLoader getPluginLoader() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Server getServer() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNaggable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNaggable(boolean b) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public EbeanServer getDatabase() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkGenerator getDefaultWorldGenerator(String s, String s1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Logger getLogger() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender commandSender, Command command, String s, String[] strings) {
|
||||
return null;
|
||||
}
|
||||
}
|
32
src/test/java/pw/yumc/YumCore/update/SubscribeTaskTest.java
Normal file
32
src/test/java/pw/yumc/YumCore/update/SubscribeTaskTest.java
Normal file
@ -0,0 +1,32 @@
|
||||
package pw.yumc.YumCore.update;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.junit.Test;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import pw.yumc.YumCore.bukkit.Log;
|
||||
import pw.yumc.YumCore.plugin.FakePlugin;
|
||||
|
||||
/**
|
||||
* @author 喵♂呜
|
||||
* @since 2017/6/1
|
||||
*/
|
||||
public class SubscribeTaskTest {
|
||||
private Plugin plugin = new FakePlugin("YumCore", "1.0");
|
||||
|
||||
@Test
|
||||
public void test() throws IOException, SAXException, ParserConfigurationException {
|
||||
SubscribeTask.VersionInfo info = new SubscribeTask.VersionInfo(plugin, "master", true);
|
||||
info.update();
|
||||
Log.d("Currect Version: %s", info.getVersion());
|
||||
Log.d("New Version: %s", info.getNewVersion());
|
||||
boolean nu = info.needUpdate(info.getNewVersion(), plugin.getDescription().getVersion());
|
||||
Log.d("Need Update: %s", nu);
|
||||
Log.d("File URL: %s", SubscribeTask.UpdateType.WS.getDownloadUrl(plugin, info.getNewVersion()));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user