下面列出了怎么用org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable的API类实例代码及写法,或者点击链接到github查看源代码。
@Test
@EnabledIfEnvironmentVariable(named = "ENV", matches = "SigningRequiredKeysTest")
void test() {
Assertions.assertDoesNotThrow(() -> {
String transaction = "{\"actions\":[{\"name\":\"newdomain\"," + "\"data"
+ "\":\"4710f541def7681843650c062d0000000002c8f031561c4758c9551cff47246f2c347189fe684c04da35cf88e813f810e3c2000000008052e74c0100000001010002c8f031561c4758c9551cff47246f2c347189fe684c04da35cf88e813f810e3c20100000000b298e982a40100000001000001000000000094135c680100000001010002c8f031561c4758c9551cff47246f2c347189fe684c04da35cf88e813f810e3c20100\",\"domain\":\"feitestdomainame9\",\"key\":\".create\"}],\"expiration\":\"2019-01-30T22:12:20\",\"ref_block_num\":53647,\"ref_block_prefix\":1474724499,\"max_charge\":1000000,\"payer\":\"EVT6Qz3wuRjyN6gaU3P3XRxpnEZnM4oPxortemaWDwFRvsv2FxgND\"}";
String[] publicKeys = new String[] { "EVT6Qz3wuRjyN6gaU3P3XRxpnEZnM4oPxortemaWDwFRvsv2FxgND" };
NetParams netParams = new TestNetNetParams();
SigningRequiredKeys signingRequiredKeys = new SigningRequiredKeys();
List<String> res = signingRequiredKeys.request(RequestParams.of(netParams, () -> {
JSONObject json = new JSONObject();
json.put("transaction", JSONObject.parseObject(transaction));
json.put("available_keys", publicKeys);
return json.toString();
}));
Assertions.assertEquals("EVT6Qz3wuRjyN6gaU3P3XRxpnEZnM4oPxortemaWDwFRvsv2FxgND", res.get(0));
});
}
@Test
@EnabledIfEnvironmentVariable(named = "ENV", matches = "TransactionEstimatedCharge")
void test() {
Assertions.assertDoesNotThrow(() -> {
String transaction = "{\"actions\":[{\"name\":\"newdomain\"," + "\"data"
+ "\":\"4710f541def7681843650c062d0000000002c8f031561c4758c9551cff47246f2c347189fe684c04da35cf88e813f810e3c2000000008052e74c0100000001010002c8f031561c4758c9551cff47246f2c347189fe684c04da35cf88e813f810e3c20100000000b298e982a40100000001000001000000000094135c680100000001010002c8f031561c4758c9551cff47246f2c347189fe684c04da35cf88e813f810e3c20100\",\"domain\":\"feitestdomainame9\",\"key\":\".create\"}],\"expiration\":\"2019-01-30T22:12:20\",\"ref_block_num\":53647,\"ref_block_prefix\":1474724499,\"max_charge\":1000000,\"payer\":\"EVT6Qz3wuRjyN6gaU3P3XRxpnEZnM4oPxortemaWDwFRvsv2FxgND\"}";
NetParams netParams = new TestNetNetParams();
TransactionEstimatedCharge transactionEstimatedCharge = new TransactionEstimatedCharge();
Charge res = transactionEstimatedCharge.request(RequestParams.of(netParams, () -> {
JSONObject json = new JSONObject();
json.put("transaction", JSONObject.parseObject(transaction));
json.put("sign_num", 1);
return json.toString();
}));
Assertions.assertTrue(res.getCharge() > 0);
});
}
@Test
@Tag("Integration")
@EnabledIfEnvironmentVariable(named = "ENV", matches = "INTEGRATION")
@DisplayName("Serialize Abi via node")
void serializeViaAbi() {
String data = "{\"action\":\"newgroup\",\"args\":{\"name\":\"testgroupcreationfei\",\"group\":{\"name\":"
+ "\"testgroupcreationfei\",\"key\":\"EVT6Qz3wuRjyN6gaU3P3XRxpnEZnM4oPxortemaWDwFRvsv2FxgND\","
+ "\"root\":{\"threshold\":6,\"weight\":0,\"nodes\":[{\"threshold\":1,\"weight\":3,\"nodes\":"
+ "[{\"key\":\"EVT6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV\",\"weight\":1},{\"key\""
+ ":\"EVT8MGU4aKiVzqMtWi9zLpu8KuTHZWjQQrX475ycSxEkLd6aBpraX\",\"weight\":1}]},{\"key\":"
+ "\"EVT8MGU4aKiVzqMtWi9zLpu8KuTHZWjQQrX475ycSxEkLd6aBpraX\",\"weight\":3},{\"threshold\":"
+ "1,\"weight\":3,\"nodes\":[{\"key\":\"EVT6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV\","
+ "\"weight\":"
+ "1},{\"key\":\"EVT8MGU4aKiVzqMtWi9zLpu8KuTHZWjQQrX475ycSxEkLd6aBpraX\",\"weight\":1}]}]}}}}";
String newDomain = "{\"args\":\"{\"name\":\"testingTmpData\","
+ "\"creator\":\"EVT6Qz3wuRjyN6gaU3P3XRxpnEZnM4oPxortemaWDwFRvsv2FxgND\","
+ "\"issue\":{\"name\":\"issue\",\"threshold\":1,"
+ "\"authorizers\":[{\"ref\":\"[A] EVT6Qz3wuRjyN6gaU3P3XRxpnEZnM4oPxortemaWDwFRvsv2FxgND\","
+ "\"weight\":1}]},\"transfer\":{\"name\":\"transfer\",\"threshold\":1,"
+ "\"authorizers\":[{\"ref\":\"[G] .OWNER\",\"weight\":1}]},"
+ "\"manage\":{\"name\":\"manage\",\"threshold\":1," + "\"authorizers\":[{\"ref\":\"[A] "
+ "EVT6Qz3wuRjyN6gaU3P3XRxpnEZnM4oPxortemaWDwFRvsv2FxgNDy\",\"weight\":1}]}}\","
+ "\"action\":\"newdomain\"}";
Assertions.assertDoesNotThrow(() -> {
NetParams netParams = new TestNetNetParams();
RemoteAbiSerialisationProvider provider = new RemoteAbiSerialisationProvider(netParams);
JSONObject.parseObject(provider.serialize(data));
});
}
/**
* Test initialize InfluxDBImpl with MessagePack format for InfluxDB versions before 1.4 will throw exception
*/
@Test
@EnabledIfEnvironmentVariable(named = "INFLUXDB_VERSION", matches = "1\\.3|1\\.2|1\\.1")
public void testMessagePackOnOldDbVersion() {
Assertions.assertThrows(UnsupportedOperationException.class, () -> {
InfluxDB influxDB = TestUtils.connectToInfluxDB(ResponseFormat.MSGPACK);
influxDB.describeDatabases();
});
}
@Test
@EnabledIfEnvironmentVariable(named = "USER", matches = "pankaj")
void test7() {
assertTrue("pankaj".equals(System.getenv("USER")));
}
@EnabledIfEnvironmentVariable(named = "RedisMiniServerEnabled", matches = "true")
@Test void redisServerMiniTest() {
}