下面列出了怎么用org.junit.jupiter.api.condition.EnabledIfSystemProperty的API类实例代码及写法,或者点击链接到github查看源代码。
@Test
@Order(0)
@EnabledIfSystemProperty(named = PROPERTY_JDBC, matches = ".*")
public void testReceiveInitCompany() {
//receive first record (operation r) for the init company - using larger timeout
Response response = receiveResponse("/receiveAsRecord");
response.then()
.statusCode(200);
Record record = response.getBody().as(Record.class);
Assert.assertEquals("r", record.getOperation());
Assert.assertEquals("Struct{NAME=init,CITY=init}", record.getValue());
}
@Test
@Order(0)
@EnabledIfSystemProperty(named = PROPERTY_JDBC, matches = ".*")
public void testReceiveEmptyMessages() {
//receive all empty messages before other tests
receiveResponse("/receiveEmptyMessages")
.then()
.statusCode(204);
}
@Test
@EnabledIfSystemProperty(named = "PLATFORM_TYPE", matches = "cloudfoundry")
@DisabledIfSystemProperty(named = "SKIP_CLOUD_CONFIG", matches = "true")
public void streamWithConfigServer() {
logger.info("stream-server-config-test");
try (Stream stream = Stream.builder(dataFlowOperations)
.name("TICKTOCK-config-server")
.definition("time | log")
.create()
.deploy(new DeploymentPropertiesBuilder()
.putAll(testDeploymentProperties())
.put("app.log.spring.profiles.active", "test")
.put("deployer.log.cloudfoundry.services", "cloud-config-server")
.put("app.log.spring.cloud.config.name", "MY_CONFIG_TICKTOCK_LOG_NAME")
.build())) {
Awaitility.await(stream.getName() + " failed to deploy!")
.until(() -> stream.getStatus().equals(DEPLOYED));
Awaitility.await().await("Source not started")
.until(() -> runtimeApps.getFirstInstanceLog(stream, "time")
.contains("Started TimeSource"));
Awaitility.await().await("Sink not started")
.until(() -> runtimeApps.getFirstInstanceLog(stream, "log")
.contains("Started LogSink"));
Awaitility.await().await("No output found")
.until(() -> runtimeApps.getFirstInstanceLog(stream, "log")
.contains("TICKTOCK CLOUD CONFIG - TIMESTAMP:"));
}
}
@Test
@Order(1)
@EnabledIfSystemProperty(named = PROPERTY_JDBC, matches = ".*")
public void testInsert() throws SQLException {
super.testInsert();
}
@Test
@Order(2)
@EnabledIfSystemProperty(named = PROPERTY_JDBC, matches = ".*")
public void testUpdate() throws SQLException {
super.testUpdate();
}
@Test
@Order(3)
@EnabledIfSystemProperty(named = PROPERTY_JDBC, matches = ".*")
public void testDelete() throws SQLException {
super.testDelete();
}
@Test
@Order(1)
@EnabledIfSystemProperty(named = PROPERTY_JDBC, matches = ".*")
public void testInsert() throws SQLException {
super.testInsert();
}
@Test
@Order(2)
@EnabledIfSystemProperty(named = PROPERTY_JDBC, matches = ".*")
public void testUpdate() throws SQLException {
super.testUpdate();
}
@Test
@Order(3)
@EnabledIfSystemProperty(named = PROPERTY_JDBC, matches = ".*")
public void testDelete() throws SQLException {
super.testDelete();
}
@Test
@EnabledIfSystemProperty(named = "os.arch", matches = ".*64.*")
void onlyOn64BitArchitectures() {
// ...
}
@Test
@EnabledIfSystemProperty(named = "os.arch", matches = ".*32.*")
void loadLib32() {
// throws on java 64 bit (win32-x86-64/EDSDK\Dll\EDSDK.dll), not tested with 32 bit runtime
loadLibraryBasics(DEFAULT_LIB_32_PATH);
}
@Test
@EnabledIfSystemProperty(named = "os.arch", matches = ".*64.*")
void loadLib64() {
// might throw on 32 bit, not tested
loadLibraryBasics(DEFAULT_LIB_64_PATH);
}
@Test
// My System Properties "user.name" value is "pankaj"
@EnabledIfSystemProperty(named = "user.name", matches = "pankaj")
void test9() {
assertTrue("pankaj".equals(System.getProperty("user.name")));
}
@Test
@EnabledIfSystemProperty(named = "com.linecorp.armeria.useJdkDnsResolver", matches = "true")
void useDefaultAddressResolverGroup() {
final DefaultClientFactory clientFactory = (DefaultClientFactory) ClientFactory.ofDefault();
assertThat(clientFactory.addressResolverGroup()).isSameAs(DefaultAddressResolverGroup.INSTANCE);
}