@Test(groups = "AllEnv") public void checkPortNumberが呼び出されたらポート番号が範囲内かどうか調べるよ() { assertFalse(ServerProperties.checkPortNumber(Integer.MIN_VALUE), "一番小さい数のパターン"); assertFalse(ServerProperties.checkPortNumber(49512), "下限値を1下回るパターン"); assertTrue(ServerProperties.checkPortNumber(49513), "下限値のパターン"); assertTrue(ServerProperties.checkPortNumber(65535), "上限値のパターン"); assertFalse(ServerProperties.checkPortNumber(65536), "上限を1上回るパターン"); assertFalse(ServerProperties.checkPortNumber(Integer.MAX_VALUE), "一番大きい数のパターン"); }
public void run() throws InterruptedException { long start = System.currentTimeMillis(); // LoggingService.init(); // MapleInfos.printAllInfos(); this.rankTime = Integer.parseInt(ServerProperties.getProperty("rankTime", "120")); this.ivCheck = Boolean.parseBoolean(ServerProperties.getProperty("ivCheck", "false")); if ((ServerProperties.getProperty("admin", false)) || (ServerConstants.USE_LOCALHOST)) { ServerConstants.USE_FIXED_IV = false; System.out.println("[!!! 已开启只能管理员登录模式 !!!]"); } try (PreparedStatement ps = DatabaseConnection.getConnection() .prepareStatement("UPDATE `accounts` SET `loggedin` = 0")) { ps.executeUpdate(); ps.close(); } catch (SQLException ex) { throw new RuntimeException("运行时错误: 无法连接到MySQL数据库伺服器"); } System.out.println("正在加载服务端..."); System.out.println("当前操作系统: " + System.getProperty("sun.desktop")); World.init(); System.out.println( "服务器地址: " + ServerProperties.getProperty("channel.interface", ServerConstants.IP) + ":" + LoginServer.DEFAULT_PORT); System.out.println( "游戏版本: " + ServerConstants.MAPLE_TYPE + " v." + ServerConstants.MAPLE_VERSION + "." + ServerConstants.MAPLE_PATCH); System.out.println("主服务器: " + WorldConstants.getMainWorld().name()); System.out.println(""); runThread(); loadData(false); System.out.print("加载\"登入\"服务..."); LoginServer.run_startup_configurations(); System.out.println("正在加载频道..."); ChannelServer.startChannel_Main(); System.out.println("频道加载完成!\r\n"); System.out.print("正在加载商城..."); CashShopServer.run_startup_configurations(); Runtime.getRuntime().addShutdownHook(new Thread(new Shutdown())); printSection("刷怪线程"); WorldRespawnService.getInstance(); if (ServerProperties.getProperty("RandDrop", false)) { ChannelServer.getInstance(1).getMapFactory().getMap(910000000).spawnRandDrop(); } ShutdownServer.registerMBean(); ServerConstants.registerMBean(); PlayerNPC.loadAll(); // printSection("定时活动"); // MessengerRankingWorker.getInstance(); LoginServer.setOn(); // Server.run_startup_configurations(); // Server.setGameRunning(true); // // if (this.rankTime > 0) { // printSection("刷新排名"); // RankingWorker.start(); // } // // if (Boolean.parseBoolean(ServerProperties.getProperty("world.AccCheck", "false"))) { // printSection("启动检测"); // startCheck(); // } // printSection("在线统计"); // 在线统计(Integer.parseInt(ServerProperties.getProperty("world.showUserCountTime", // "30"))); // MessengerRankingWorker.getInstance(); // // if (Boolean.parseBoolean(ServerProperties.getProperty("world.checkCopyItem", // "false"))) { // checkCopyItemFromSql(); // } long now = System.currentTimeMillis() - start; long seconds = now / 1000; long ms = now % 1000; if (ServerProperties.getProperty("aotoSave", false)) { DatabaseBackup.getInstance().startTasking(); System.out.println("启动数据库自动备份!"); } // ManagerSin.main(ServerConstants.GUI); System.out.println("加载完成, 耗时: " + seconds + "秒" + ms + "毫秒\r\n"); }