刘光辉
15 小时以前 34981c30a78e8bbd7791131059a9210f9928b62c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package jnpf.limsService.support;
 
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
 
public class LimsSxtRoutePrefixChecks {
 
    public static void main(String[] args) throws Exception {
        Path root = Paths.get("").toAbsolutePath().normalize();
        assertRoute(root,
                "jnpf-lims/jnpf-lims-controller/src/main/java/jnpf/limsController/LimsSxtQingyanXiangmuController.java",
                "/lims/biz/sxt");
        assertRoute(root,
                "jnpf-lims/jnpf-lims-controller/src/main/java/jnpf/limsController/LimsSxtFlowStatusController.java",
                "/lims/biz/sxt/flow-status");
    }
 
    private static void assertRoute(Path root, String relativePath, String expectedRoute) throws Exception {
        String source = new String(Files.readAllBytes(root.resolve(relativePath)));
        require(source, "@RequestMapping(\"" + expectedRoute + "\")", expectedRoute + " route missing");
        if (source.contains("@RequestMapping(\"/lims/sxt")) {
            throw new AssertionError("legacy /lims/sxt route must not remain in " + relativePath);
        }
    }
 
    private static void require(String source, String token, String message) {
        if (!source.contains(token)) {
            throw new AssertionError(message);
        }
    }
}