[+] 优化
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package com.acgist.taoyao.boot.utils;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class FileUtilsTest {
|
||||
|
||||
@Test
|
||||
void test() {
|
||||
assertEquals("0B", FileUtils.formatSize(0L));
|
||||
assertEquals("0B", FileUtils.formatSize(-10L));
|
||||
assertEquals("1.00KB", FileUtils.formatSize(1024L));
|
||||
log.info("{}", FileUtils.formatSize(1025L));
|
||||
log.info("{}", FileUtils.formatSize(2025L));
|
||||
log.info("{}", FileUtils.formatSize(Long.MAX_VALUE));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.acgist.taoyao.boot.utils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class HTTPUtilsTest {
|
||||
|
||||
@Test
|
||||
void test() throws IOException, InterruptedException {
|
||||
HTTPUtils.init(5000, Executors.newCachedThreadPool());
|
||||
final HttpClient client = HTTPUtils.newClient();
|
||||
final HttpResponse<String> response = client.send(
|
||||
HttpRequest.newBuilder(URI.create("https://www.acgist.com")).GET().build(),
|
||||
BodyHandlers.ofString()
|
||||
);
|
||||
log.info("{}", response.body());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.acgist.taoyao.boot.utils;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class ScriptUtilsTest {
|
||||
|
||||
@Test
|
||||
void test() {
|
||||
ScriptUtils.execute("ls");
|
||||
ScriptUtils.execute("netstat -ano");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user