format code

Signed-off-by: Sola <dev@sola.love>
This commit is contained in:
Sola
2017-12-15 08:57:51 +08:00
parent 529b36d9e3
commit 0bdcf031b5
69 changed files with 1988 additions and 1988 deletions

View File

@@ -10,11 +10,11 @@ import java.util.Set;
*/
public class ReflectionTest {
@Test
public void test() {
Reflections reflections = new Reflections(getClass().getPackage().getName());
Set<Class<? extends API>> set = reflections.getSubTypesOf(API.class);
assert set.size() == 15;
}
@Test
public void test() {
Reflections reflections = new Reflections(getClass().getPackage().getName());
Set<Class<? extends API>> set = reflections.getSubTypesOf(API.class);
assert set.size() == 15;
}
}

View File

@@ -7,9 +7,9 @@ import org.junit.Test;
*/
public class CortanaTest {
@Test
public void load() throws Exception {
Cortana.load();
}
@Test
public void load() throws Exception {
Cortana.load();
}
}

View File

@@ -7,9 +7,9 @@ import org.junit.Test;
*/
public class ReflectionTest {
@Test
public void testLang() {
assert Lang.messages != null;
}
@Test
public void testLang() {
assert Lang.messages != null;
}
}

View File

@@ -7,19 +7,19 @@ import org.junit.Test;
*/
public class ReflectionTest {
@Test
public void testBlock() {
assert Block.inverseMap != null;
}
@Test
public void testBlock() {
assert Block.inverseMap != null;
}
@Test
public void testAccess() {
assert Access.inverseMap != null;
}
@Test
public void testAccess() {
assert Access.inverseMap != null;
}
@Test
public void testStatus() {
assert Status.inverseMap != null;
}
@Test
public void testStatus() {
assert Status.inverseMap != null;
}
}

View File

@@ -14,28 +14,28 @@ import java.security.spec.X509EncodedKeySpec;
*/
public class EncryptTest {
@Test
public void testBCrypt() {
String hash = BCrypt.hashpw("mypasswordhere", BCrypt.gensalt());
assert BCrypt.checkpw("mypasswordhere", hash);
}
@Test
public void testBCrypt() {
String hash = BCrypt.hashpw("mypasswordhere", BCrypt.gensalt());
assert BCrypt.checkpw("mypasswordhere", hash);
}
@Test
public void testRSA() {
assert "Hello World".equals(RSAUtil.decrypt(RSAUtil.encrypt("Hello World")));
assert "Encrypt".equals(RSAUtil.decrypt(RSAUtil.encrypt("Encrypt")));
}
@Test
public void testRSA() {
assert "Hello World".equals(RSAUtil.decrypt(RSAUtil.encrypt("Hello World")));
assert "Encrypt".equals(RSAUtil.decrypt(RSAUtil.encrypt("Encrypt")));
}
// @Test
public void testRSASpecKey() throws NoSuchAlgorithmException, InvalidKeySpecException {
System.out.println("RSAUtil.privateKey_s = " + RSAUtil.privateKey_s);
System.out.println("RSAUtil.publicKey_s = " + RSAUtil.publicKey_s);
// @Test
public void testRSASpecKey() throws NoSuchAlgorithmException, InvalidKeySpecException {
System.out.println("RSAUtil.privateKey_s = " + RSAUtil.privateKey_s);
System.out.println("RSAUtil.publicKey_s = " + RSAUtil.publicKey_s);
// String pkey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCA0qyARvHSCIUQ6YM6K+e/QgiZ+dc/MpVz5DIFwQab5iiifruQiaoA74ilHOOiq5i0ToR1VxNhCUZcAy2saHNifoYKTauMOUSV6IoP4X5jp691PlI9yxNx328mSlPNM9+7BgOzrUP1pR71d+T4LDn0o4J6Ad82vVIe7yWszzF4qQIDAQAB";
String pkey = RSAUtil.publicKey_s;
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
X509EncodedKeySpec keySpec = new X509EncodedKeySpec(Base64.decodeBase64(pkey));
RSAUtil.publicKey = keyFactory.generatePublic(keySpec);
System.out.println("RSAUtil.encrypt(\"233\") = " + RSAUtil.encrypt("233"));
}
String pkey = RSAUtil.publicKey_s;
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
X509EncodedKeySpec keySpec = new X509EncodedKeySpec(Base64.decodeBase64(pkey));
RSAUtil.publicKey = keyFactory.generatePublic(keySpec);
System.out.println("RSAUtil.encrypt(\"233\") = " + RSAUtil.encrypt("233"));
}
}

View File

@@ -11,18 +11,18 @@ import java.util.Date;
*/
public class GsonTest {
@Test
public void testJsonDate() {
Gson gson = new GsonBuilder()
.registerTypeAdapter(Date.class, (JsonDeserializer<Date>) (json, typeOfT, context) -> new Date(json.getAsJsonPrimitive().getAsLong()))
.registerTypeAdapter(Date.class, (JsonSerializer<Date>) (src, typeOfSrc, context) -> new JsonPrimitive(src.getTime()))
.registerTypeAdapter(ISP.class, (JsonDeserializer<ISP>) (json, typeOfT, context) -> ISP.fromId(json.getAsJsonPrimitive().getAsInt()))
.registerTypeAdapter(ISP.class, (JsonSerializer<ISP>) (src, typeOfSrc, context) -> new JsonPrimitive(src.id))
.create();
Date date = new Date();
assert gson.fromJson(gson.toJson(date), Date.class).compareTo(date) == 0;
assert gson.fromJson(gson.toJson(ISP.TELECOM), ISP.class) == ISP.TELECOM;
assert gson.toJson(ISP.TELECOM).equals("1");
}
@Test
public void testJsonDate() {
Gson gson = new GsonBuilder()
.registerTypeAdapter(Date.class, (JsonDeserializer<Date>) (json, typeOfT, context) -> new Date(json.getAsJsonPrimitive().getAsLong()))
.registerTypeAdapter(Date.class, (JsonSerializer<Date>) (src, typeOfSrc, context) -> new JsonPrimitive(src.getTime()))
.registerTypeAdapter(ISP.class, (JsonDeserializer<ISP>) (json, typeOfT, context) -> ISP.fromId(json.getAsJsonPrimitive().getAsInt()))
.registerTypeAdapter(ISP.class, (JsonSerializer<ISP>) (src, typeOfSrc, context) -> new JsonPrimitive(src.id))
.create();
Date date = new Date();
assert gson.fromJson(gson.toJson(date), Date.class).compareTo(date) == 0;
assert gson.fromJson(gson.toJson(ISP.TELECOM), ISP.class) == ISP.TELECOM;
assert gson.toJson(ISP.TELECOM).equals("1");
}
}

View File

@@ -13,19 +13,19 @@ import static org.junit.Assert.assertThat;
*/
public class URLEncodeTest {
@Test
public void testEncode() throws UnsupportedEncodingException {
assertThat(
UrlEscapers.urlFragmentEscaper().escape("Test Title"),
equalTo("Test%20Title")
);
assertThat(
Redirect.success()
.title("Test Title")
.msg("Test Message")
.toString(),
equalTo("http://s.wts.sola.love/nm/v2/result.html?type=1&title=Test%20Title&msg=Test%20Message&")
);
}
@Test
public void testEncode() throws UnsupportedEncodingException {
assertThat(
UrlEscapers.urlFragmentEscaper().escape("Test Title"),
equalTo("Test%20Title")
);
assertThat(
Redirect.success()
.title("Test Title")
.msg("Test Message")
.toString(),
equalTo("http://s.wts.sola.love/nm/v2/result.html?type=1&title=Test%20Title&msg=Test%20Message&")
);
}
}