斗鱼录播初步完成

This commit is contained in:
suifeng
2023-08-04 11:47:59 +08:00
parent 7d8f566804
commit 4d4a4a6727
43 changed files with 877 additions and 296 deletions

View File

@@ -51,5 +51,10 @@
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.akamai.edgegrid</groupId>
<artifactId>edgegrid-signer-core</artifactId>
<version>5.0.0</version>
</dependency>
</dependencies>
</project>

View File

@@ -1,123 +1,123 @@
package org.example.cache;
import org.example.constpool.GlobalFileCache;
import org.example.pojo.Student;
import org.example.pojo.configfile.ChopperBotConfigFile;
import org.example.exception.FileCacheException;
import org.junit.jupiter.api.Test;
import java.util.List;
import java.util.concurrent.ConcurrentLinkedQueue;
/**
* @author Genius
* @date 2023/04/24 03:30
**/
public class FileCacheTest {
static FileCache cache;
static{
try {
cache = new FileCache<>(
new CommonConfigFile(
"E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\",
"test.json",
new ConcurrentLinkedQueue<Student>()
)
);
FileCacheManagerInstance.getInstance().addFileCache(cache);
} catch (FileCacheException e) {
throw new RuntimeException(e);
}
}
@Test
public void TestFileCache() throws FileCacheException, InterruptedException {
ChopperBotConfigFile chopperBotConfigFile = new ChopperBotConfigFile();
FileCache fileCache = new FileCache(chopperBotConfigFile);
FileCacheManager manager = new FileCacheManager(List.of(fileCache));
manager.start();
Thread.sleep(500000);
}
@Test
public void TestFileCacheManager() throws FileCacheException, InterruptedException {
ChopperBotConfigFile chopperBotConfigFile = new ChopperBotConfigFile();
FileCache fileCache = new FileCache(chopperBotConfigFile);
FileCacheManager manager = new FileCacheManager(List.of(fileCache));
manager.start();
Thread.sleep(500000);
}
@Test
public void TestGet() throws FileCacheException, InterruptedException {
ChopperBotConfigFile chopperBotConfigFile = new ChopperBotConfigFile();
FileCache fileCache = new FileCache(chopperBotConfigFile);
FileCacheManager manager = new FileCacheManager(List.of(fileCache));
manager.start();
fileCache.append(1,"barrage","src");
}
@Test
public void TestAppend() throws FileCacheException, InterruptedException {
FileCacheManagerInstance.getInstance().start();
//追加数组的某个元素
for(int i=0;i<10;i++){
GlobalFileCache.ModuleSrcConfigFile.append(i,"sectionwork","src","0");
}
//追加数组
for(int i=0;i<10;i++){
GlobalFileCache.ModuleSrcConfigFile.append(i,"sectionwork","src","-1");
}
//追加类中的元素
for(int i=0;i<10;i++){
GlobalFileCache.ModuleSrcConfigFile.append(i,"barrage","src");
}
Thread.sleep(500000);
}
@Test
public void TestWrite() throws FileCacheException,InterruptedException{
FileCacheManagerInstance.getInstance().start();
//更改数组元素
for(int i=0;i<10;i++){
GlobalFileCache.ModuleSrcConfigFile.writeKeys(i,"sectionwork","src","0");
}
//追加数组
for(int i=0;i<10;i++){
GlobalFileCache.ModuleSrcConfigFile.writeKeys(i,"sectionwork","src","-1");
}
//更改类中的元素
for(int i=0;i<10;i++){
GlobalFileCache.ModuleSrcConfigFile.writeKeys(i,"barrage","src");
}
Thread.sleep(500000);
}
@Test
public void TestArrayAdd() throws InterruptedException, FileCacheException {
ChopperBotConfigFile chopperBotConfigFile = new ChopperBotConfigFile();
FileCache fileCache = new FileCache(chopperBotConfigFile);
FileCacheManager manager = new FileCacheManager(List.of(fileCache));
manager.start();
}
@Test
public void TestAddCache() throws FileCacheException, InterruptedException {
FileCacheManagerInstance.getInstance().start();
for(int i=0;i<10;i++){
Student student = new Student(Integer.toString(i),i,"jsu"+i,"major"+i,null,null);
cache.writeKeys(student,"-1");
}
Thread.sleep(500000);
}
}
//package org.example.cache;
//
//import org.example.constpool.GlobalFileCache;
//import org.example.pojo.Student;
//import org.example.pojo.configfile.ChopperBotConfigFile;
//import org.example.exception.FileCacheException;
//import org.junit.jupiter.api.Test;
//
//import java.util.List;
//import java.util.concurrent.ConcurrentLinkedQueue;
//
///**
// * @author Genius
// * @date 2023/04/24 03:30
// **/
//
//public class FileCacheTest {
// static FileCache cache;
//
// static{
//
// try {
// cache = new FileCache<>(
// new CommonConfigFile(
// "E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\",
// "test.json",
// new ConcurrentLinkedQueue<Student>()
// )
// );
// FileCacheManagerInstance.getInstance().addFileCache(cache);
// } catch (FileCacheException e) {
// throw new RuntimeException(e);
// }
// }
//
// @Test
// public void TestFileCache() throws FileCacheException, InterruptedException {
// ChopperBotConfigFile chopperBotConfigFile = new ChopperBotConfigFile();
// FileCache fileCache = new FileCache(chopperBotConfigFile);
//
// FileCacheManager manager = new FileCacheManager(List.of(fileCache));
// manager.start();
// Thread.sleep(500000);
// }
//
// @Test
// public void TestFileCacheManager() throws FileCacheException, InterruptedException {
// ChopperBotConfigFile chopperBotConfigFile = new ChopperBotConfigFile();
// FileCache fileCache = new FileCache(chopperBotConfigFile);
// FileCacheManager manager = new FileCacheManager(List.of(fileCache));
// manager.start();
// Thread.sleep(500000);
// }
//
// @Test
// public void TestGet() throws FileCacheException, InterruptedException {
// ChopperBotConfigFile chopperBotConfigFile = new ChopperBotConfigFile();
// FileCache fileCache = new FileCache(chopperBotConfigFile);
//
// FileCacheManager manager = new FileCacheManager(List.of(fileCache));
// manager.start();
//
// fileCache.append(1,"barrage","src");
// }
//
// @Test
// public void TestAppend() throws FileCacheException, InterruptedException {
// FileCacheManagerInstance.getInstance().start();
// //追加数组的某个元素
// for(int i=0;i<10;i++){
// GlobalFileCache.ModuleSrcConfigFile.append(i,"sectionwork","src","0");
// }
// //追加数组
// for(int i=0;i<10;i++){
// GlobalFileCache.ModuleSrcConfigFile.append(i,"sectionwork","src","-1");
// }
// //追加类中的元素
// for(int i=0;i<10;i++){
// GlobalFileCache.ModuleSrcConfigFile.append(i,"barrage","src");
// }
// Thread.sleep(500000);
// }
//
// @Test
// public void TestWrite() throws FileCacheException,InterruptedException{
// FileCacheManagerInstance.getInstance().start();
// //更改数组元素
// for(int i=0;i<10;i++){
// GlobalFileCache.ModuleSrcConfigFile.writeKeys(i,"sectionwork","src","0");
// }
// //追加数组
// for(int i=0;i<10;i++){
// GlobalFileCache.ModuleSrcConfigFile.writeKeys(i,"sectionwork","src","-1");
// }
// //更改类中的元素
// for(int i=0;i<10;i++){
// GlobalFileCache.ModuleSrcConfigFile.writeKeys(i,"barrage","src");
// }
// Thread.sleep(500000);
// }
//
// @Test
// public void TestArrayAdd() throws InterruptedException, FileCacheException {
// ChopperBotConfigFile chopperBotConfigFile = new ChopperBotConfigFile();
// FileCache fileCache = new FileCache(chopperBotConfigFile);
//
// FileCacheManager manager = new FileCacheManager(List.of(fileCache));
// manager.start();
//
// }
//
// @Test
// public void TestAddCache() throws FileCacheException, InterruptedException {
// FileCacheManagerInstance.getInstance().start();
//
// for(int i=0;i<10;i++){
// Student student = new Student(Integer.toString(i),i,"jsu"+i,"major"+i,null,null);
// cache.writeKeys(student,"-1");
// }
// Thread.sleep(500000);
// }
//
//}

View File

@@ -1,24 +1,24 @@
package org.example.util;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
/**
* @author Genius
* @date 2023/04/20 14:15
**/
public class FileUtilTest {
@Test
public void testDelete() throws IOException {
FileUtil.deleteDirectory("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\trash");
}
@Test
public void testCreate() throws IOException {
Files.createDirectories(Paths.get("./Hello"));
}
}
//package org.example.util;
//
//import org.junit.jupiter.api.Test;
//
//import java.io.IOException;
//import java.nio.file.Files;
//import java.nio.file.Paths;
//
///**
// * @author Genius
// * @date 2023/04/20 14:15
// **/
//public class FileUtilTest {
//
// @Test
// public void testDelete() throws IOException {
// FileUtil.deleteDirectory("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\trash");
// }
//
// @Test
// public void testCreate() throws IOException {
// Files.createDirectories(Paths.get("./Hello"));
// }
//}

View File

@@ -1,82 +1,82 @@
package org.example.util;
import org.example.pojo.Student;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.Map;
/**
* @author Genius
* @date 2023/04/20 11:43
**/
public class JsonFileUtilTest {
@Test
public void writeMapObj() throws IOException {
Student student = new Student(
"Genius",
18,
"HUST",
"CS",
List.of("Coding", "Reading", "Playing"),
Map.of("QQ", "123456789", "WeChat", "987654321")
);
JsonFileUtil.writeJsonFile("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\student2.json",
Map.of("Student", student,"hello","11234"));
Map<String, Object> stringObjectMap = JsonFileUtil.readJsonFile("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\student2.json");
stringObjectMap.forEach(
(k,v)->{
System.out.println(k);
System.out.println(v.getClass());
}
);
}
@Test
public void writeClassInJsonFile() {
Student student = new Student(
"Genius",
18,
"HUST",
"CS",
List.of("Coding", "Reading", "Playing"),
Map.of("QQ", "123456789", "WeChat", "987654321")
);
JsonFileUtil.writeJsonFile("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\", "student.json", student);
JsonFileUtil.writeBigJsonFile("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\student2.json", List.of(student));
JsonFileUtil.writeJsonFileIsExist("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\student3.json", student);
System.out.println(JsonFileUtil.readJsonFileToObject("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\student.json", Student.class));
System.out.println(JsonFileUtil.readJsonFileToObject("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\student2.json",List.class));
}
@Test
public void readJsonFile() {
Map maps = JsonFileUtil.readJsonFile("../config/", "moduleConfig.json");
Object test = maps.get("module");
System.out.println(test);
System.out.println(maps);
}
@Test
public void writeJsonFile() {
Map maps = JsonFileUtil.readJsonFile("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\", "test.json");
JsonFileUtil.writeJsonFile("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\", "test2.json", maps);
JsonFileUtil.writeJsonFileIsExist("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\test2.json", maps);
}
@Test
public void writeJsonFileByJsonWriter() throws IOException {
Map maps = JsonFileUtil.readJsonFile("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\", "test.json");
Path dir = Paths.get("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\test2.json");
JsonFileUtil.writeBigJsonFile(dir.toString(),maps);
}
}
//package org.example.util;
//
//import org.example.pojo.Student;
//import org.junit.jupiter.api.Test;
//
//import java.io.IOException;
//import java.nio.file.Path;
//import java.nio.file.Paths;
//import java.util.List;
//import java.util.Map;
//
///**
// * @author Genius
// * @date 2023/04/20 11:43
// **/
//
//public class JsonFileUtilTest {
//
// @Test
// public void writeMapObj() throws IOException {
// Student student = new Student(
// "Genius",
// 18,
// "HUST",
// "CS",
// List.of("Coding", "Reading", "Playing"),
// Map.of("QQ", "123456789", "WeChat", "987654321")
// );
// JsonFileUtil.writeJsonFile("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\student2.json",
// Map.of("Student", student,"hello","11234"));
// Map<String, Object> stringObjectMap = JsonFileUtil.readJsonFile("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\student2.json");
// stringObjectMap.forEach(
// (k,v)->{
// System.out.println(k);
// System.out.println(v.getClass());
// }
// );
// }
//
//
// @Test
// public void writeClassInJsonFile() {
// Student student = new Student(
// "Genius",
// 18,
// "HUST",
// "CS",
// List.of("Coding", "Reading", "Playing"),
// Map.of("QQ", "123456789", "WeChat", "987654321")
// );
// JsonFileUtil.writeJsonFile("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\", "student.json", student);
// JsonFileUtil.writeBigJsonFile("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\student2.json", List.of(student));
// JsonFileUtil.writeJsonFileIsExist("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\student3.json", student);
//
// System.out.println(JsonFileUtil.readJsonFileToObject("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\student.json", Student.class));
// System.out.println(JsonFileUtil.readJsonFileToObject("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\student2.json",List.class));
// }
//
// @Test
// public void readJsonFile() {
// Map maps = JsonFileUtil.readJsonFile("../config/", "moduleConfig.json");
// Object test = maps.get("module");
// System.out.println(test);
// System.out.println(maps);
// }
//
// @Test
// public void writeJsonFile() {
// Map maps = JsonFileUtil.readJsonFile("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\", "test.json");
// JsonFileUtil.writeJsonFile("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\", "test2.json", maps);
// JsonFileUtil.writeJsonFileIsExist("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\test2.json", maps);
// }
//
// @Test
// public void writeJsonFileByJsonWriter() throws IOException {
// Map maps = JsonFileUtil.readJsonFile("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\", "test.json");
// Path dir = Paths.get("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\test2.json");
// JsonFileUtil.writeBigJsonFile(dir.toString(),maps);
// }
//
//
//}