org.junit.Assume#assumeThat ( )源码实例Demo

下面列出了org.junit.Assume#assumeThat ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: hadoop   文件: TestShortCircuitCache.java
private static Configuration createShortCircuitConf(String testName,
    TemporarySocketDirectory sockDir) {
  Configuration conf = new Configuration();
  conf.set(DFS_CLIENT_CONTEXT, testName);
  conf.setLong(DFS_BLOCK_SIZE_KEY, 4096);
  conf.set(DFS_DOMAIN_SOCKET_PATH_KEY, new File(sockDir.getDir(),
      testName).getAbsolutePath());
  conf.setBoolean(DFS_CLIENT_READ_SHORTCIRCUIT_KEY, true);
  conf.setBoolean(DFS_CLIENT_READ_SHORTCIRCUIT_SKIP_CHECKSUM_KEY,
      false);
  conf.setBoolean(DFS_CLIENT_DOMAIN_SOCKET_DATA_TRAFFIC, false);
  DFSInputStream.tcpReadsDisabledForTesting = true;
  DomainSocket.disableBindPathValidation();
  Assume.assumeThat(DomainSocket.getLoadingFailureReason(), equalTo(null));
  return conf;
}
 
源代码2 项目: big-c   文件: TestScrLazyPersistFiles.java
@Test
public void testShortCircuitReadAfterEviction()
    throws IOException, InterruptedException {
  Assume.assumeThat(DomainSocket.getLoadingFailureReason(), equalTo(null));
  startUpCluster(true, 1 + EVICTION_LOW_WATERMARK, true, false);
  doShortCircuitReadAfterEvictionTest();
}
 
源代码3 项目: big-c   文件: TestScrLazyPersistFiles.java
@Test
public void testShortCircuitReadMetaFileCorruption() throws IOException,
    InterruptedException {
  Assume.assumeThat(DomainSocket.getLoadingFailureReason(), equalTo(null));
  startUpCluster(true, 1 + EVICTION_LOW_WATERMARK, true, false);
  doShortCircuitReadMetaFileCorruptionTest();
}
 
源代码4 项目: big-c   文件: TestScrLazyPersistFiles.java
@Test
public void testShortCircuitReadBlockFileCorruption() throws IOException,
    InterruptedException {
  Assume.assumeThat(DomainSocket.getLoadingFailureReason(), equalTo(null));
  startUpCluster(true, 1 + EVICTION_LOW_WATERMARK, true, false);
  doShortCircuitReadBlockFileCorruptionTest();
}
 
源代码5 项目: hadoop   文件: TestScrLazyPersistFiles.java
@Test
public void testShortCircuitReadBlockFileCorruption() throws IOException,
    InterruptedException {
  Assume.assumeThat(DomainSocket.getLoadingFailureReason(), equalTo(null));
  startUpCluster(true, 1 + EVICTION_LOW_WATERMARK, true, false);
  doShortCircuitReadBlockFileCorruptionTest();
}
 
源代码6 项目: hadoop   文件: TestScrLazyPersistFiles.java
@Test
public void testShortCircuitReadMetaFileCorruption() throws IOException,
    InterruptedException {
  Assume.assumeThat(DomainSocket.getLoadingFailureReason(), equalTo(null));
  startUpCluster(true, 1 + EVICTION_LOW_WATERMARK, true, false);
  doShortCircuitReadMetaFileCorruptionTest();
}
 
@Test
public void test() throws InterruptedException {
	Assume.assumeThat("Skipping this test which is time dependent in travis", System.getenv("TRAVIS"),
			CoreMatchers.nullValue());
	Thread.sleep(5000);
	assertThat(messageCollector.forChannel(timeSource.output()).size(), Matchers.greaterThanOrEqualTo(500));
}
 
源代码8 项目: jcredstash   文件: JavaxCryptoTest.java
@Override
public Statement apply(Statement statement, Description description) {
    try {
        int maxAllowedKeyLength = Cipher.getMaxAllowedKeyLength("AES");
        Assume.assumeThat("Unlimited Strength policy files installed", maxAllowedKeyLength, Matchers.greaterThanOrEqualTo(256));
    } catch (NoSuchAlgorithmException e) {
        throw new RuntimeException(e);
    }

    return statement;
}
 
源代码9 项目: styx   文件: GoogleIdTokenAuthTest.java
@Test
public void testMockUserCredentials() throws IOException, GeneralSecurityException, InterruptedException {
  final MockResponse tokenResponse = new MockResponse()
      .setBody(Utils.getDefaultJsonFactory().toString(ImmutableMap.of("id_token", "test-id-token")));
  metadataServer.enqueue(tokenResponse);
  metadataServer.start();

  final AccessToken accessToken = new AccessToken("test-access-token",
      Date.from(Instant.now().plus(Duration.ofDays(1))));
  final GoogleCredentials credentials = UserCredentials.newBuilder()
      .setTokenServerUri(URI.create("http://localhost:" + metadataServer.getPort() + "/get-test-token"))
      .setAccessToken(accessToken)
      .setRefreshToken("user-refresh-token")
      .setClientId("user-id")
      .setClientSecret("user-secret")
      .build();
  Assume.assumeThat(credentials, is(instanceOf(UserCredentials.class)));
  final GoogleIdTokenAuth idTokenAuth = GoogleIdTokenAuth.of(credentials);
  final Optional<String> token = idTokenAuth.getToken("http://styx.foo.bar");
  assertThat(token, is(Optional.of("test-id-token")));

  final RecordedRequest recordedRequest = metadataServer.takeRequest();
  final Map<String, String> requestBody = Splitter.on('&').withKeyValueSeparator('=')
      .split(recordedRequest.getBody().readUtf8());
  assertThat(requestBody, is(ImmutableMap.of(
      "grant_type", "refresh_token",
      "refresh_token", "user-refresh-token",
      "client_id", "user-id",
      "client_secret", "user-secret")));
  assertThat(recordedRequest.getPath(), is("/get-test-token"));
  assertThat(recordedRequest.getHeader("Authorization"), is("Bearer test-access-token"));
}
 
源代码10 项目: big-c   文件: TestBlockReaderFactory.java
@Before
public void init() {
  DomainSocket.disableBindPathValidation();
  Assume.assumeThat(DomainSocket.getLoadingFailureReason(), equalTo(null));
}
 
@Before
public void before() {
  Assume.assumeThat(DomainSocket.getLoadingFailureReason(), equalTo(null));
}
 
@Before
public void before() {
  Assume.assumeThat(DomainSocket.getLoadingFailureReason(), equalTo(null));
}
 
源代码13 项目: espresso-macchiato   文件: EspressoTestBase.java
public void skipTestIfBelowAndroidMarshmallow() {
    Assume.assumeThat(Build.VERSION.SDK_INT, Matchers.greaterThanOrEqualTo(Build.VERSION_CODES.M));
}
 
源代码14 项目: big-c   文件: TestParallelShortCircuitRead.java
@Before
public void before() {
  Assume.assumeThat(DomainSocket.getLoadingFailureReason(), equalTo(null));
}
 
源代码15 项目: big-c   文件: TestScrLazyPersistFiles.java
@Before
public void before() {
  Assume.assumeThat(NativeCodeLoader.isNativeCodeLoaded() && !Path.WINDOWS,
      equalTo(true));
  Assume.assumeThat(DomainSocket.getLoadingFailureReason(), equalTo(null));
}
 
public static void assumeMiniKube() throws Exception {
    Assume.assumeThat("MiniKube working", miniKubeIp(), not(isEmptyOrNullString()));
}
 
源代码17 项目: big-c   文件: TestParallelUnixDomainRead.java
@Before
public void before() {
  Assume.assumeThat(DomainSocket.getLoadingFailureReason(), equalTo(null));
}
 
源代码18 项目: hadoop   文件: TestParallelUnixDomainRead.java
@Before
public void before() {
  Assume.assumeThat(DomainSocket.getLoadingFailureReason(), equalTo(null));
}
 
@Test public void testAuthenticatedClientsAllowed() throws Exception {
  Assume.assumeThat("Test disabled on Windows", File.separatorChar, is('/'));

  // Create the subject for the client
  final Subject clientSubject = AvaticaJaasKrbUtil.loginUsingKeytab(
      SpnegoTestUtil.CLIENT_PRINCIPAL, clientKeytab);
  final Set<Principal> clientPrincipals = clientSubject.getPrincipals();
  // Make sure the subject has a principal
  assertFalse(clientPrincipals.isEmpty());

  // Get a TGT for the subject (might have many, different encryption types). The first should
  // be the default encryption type.
  Set<KerberosTicket> privateCredentials =
          clientSubject.getPrivateCredentials(KerberosTicket.class);
  assertFalse(privateCredentials.isEmpty());
  KerberosTicket tgt = privateCredentials.iterator().next();
  assertNotNull(tgt);
  LOG.info("Using TGT with etype: {}", tgt.getSessionKey().getAlgorithm());

  // The name of the principal
  final String principalName = clientPrincipals.iterator().next().getName();

  // Run this code, logged in as the subject (the client)
  byte[] response = Subject.doAs(clientSubject, new PrivilegedExceptionAction<byte[]>() {
    @Override public byte[] run() throws Exception {
      // Logs in with Kerberos via GSS
      GSSManager gssManager = GSSManager.getInstance();
      Oid oid = new Oid(SpnegoTestUtil.JGSS_KERBEROS_TICKET_OID);
      GSSName gssClient = gssManager.createName(principalName, GSSName.NT_USER_NAME);
      GSSCredential credential = gssManager.createCredential(gssClient,
          GSSCredential.DEFAULT_LIFETIME, oid, GSSCredential.INITIATE_ONLY);

      // Passes the GSSCredential into the HTTP client implementation
      final AvaticaCommonsHttpClientSpnegoImpl httpClient =
          new AvaticaCommonsHttpClientSpnegoImpl(httpServerUrl, credential);

      return httpClient.send(new byte[0]);
    }
  });

  // We should get a response which is "OK" with our client's name
  assertNotNull(response);
  assertEquals("OK " + SpnegoTestUtil.CLIENT_PRINCIPAL,
      new String(response, StandardCharsets.UTF_8));
}
 
源代码20 项目: styx   文件: GoogleIdTokenAuthTest.java
@Test
public void testUserCredentials() throws IOException, GeneralSecurityException {
  Assume.assumeThat(credentials, is(instanceOf(UserCredentials.class)));
  assertThat(canAcquireIdToken(credentials), is(true));
}