Files
MineGeo/tests/java/ServerAddressSmoke.java

18 lines
913 B
Java

import dev.minegeo.plugin.ServerAddress;
public class ServerAddressSmoke {
public static void main(String[] args) throws Exception {
ServerAddress.requireMatch(" PLAY.EXAMPLE.COM.:25565 ","play.example.com");
ServerAddress.requireMatch("[2001:DB8::1]","[2001:db8::1]:25565");
ServerAddress.requireMatch(null,"other.example.com");
for(String capture:new String[]{"other.example.com","play.example.com:25566",""}) {
try {ServerAddress.requireMatch("play.example.com",capture);throw new AssertionError("Wrong server accepted");}
catch(java.io.IOException expected) {}
}
for(String invalid:new String[]{"https://host","host:0","host:65536","a..b","[:::]"}) {
try {ServerAddress.normalize(invalid);throw new AssertionError("Invalid address accepted");}
catch(IllegalArgumentException expected) {}
}
System.out.println("Server address checks passed for the shared mod/plugin client");
}
}