mirror of
https://github.com/ReaJason/MemShellParty.git
synced 2026-09-21 22:50:42 +08:00
fix: supportedShellTools not right
This commit is contained in:
@@ -235,7 +235,10 @@ public class ServerFactory {
|
||||
}
|
||||
toolMappingBuilder.addShellClass(shellType, shellClass);
|
||||
}
|
||||
server.addToolMapping(shellTool, toolMappingBuilder.build());
|
||||
ToolMapping mapping = toolMappingBuilder.build();
|
||||
if (mapping.isNotEmpty()) {
|
||||
server.addToolMapping(shellTool, mapping);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,10 @@ public class ToolMapping {
|
||||
this.shellClassMap = new LinkedHashMap<>(shellClassMap);
|
||||
}
|
||||
|
||||
public boolean isNotEmpty() {
|
||||
return !shellClassMap.isEmpty();
|
||||
}
|
||||
|
||||
public Set<String> getSupportedShellTypes() {
|
||||
return shellClassMap.keySet();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.reajason.javaweb.memshell;
|
||||
|
||||
import com.reajason.javaweb.Server;
|
||||
import com.reajason.javaweb.memshell.server.AbstractServer;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* @author ReaJason
|
||||
* @since 2025/8/25
|
||||
*/
|
||||
class ServerFactoryTest {
|
||||
|
||||
@Test
|
||||
void testSupportedTools() {
|
||||
AbstractServer server = ServerFactory.getServer(Server.XXLJOB);
|
||||
Set<String> supportedShellTools = server.getSupportedShellTools();
|
||||
assertEquals(2, supportedShellTools.size());
|
||||
assertTrue(supportedShellTools.contains(ShellTool.Command));
|
||||
assertTrue(supportedShellTools.contains(ShellTool.Godzilla));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user