斗鱼录播初步完成

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

@@ -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);
// }
//
//}