Java Code Examples for org.junit.Assume#assumeThat()

The following examples show how to use org.junit.Assume#assumeThat() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestShortCircuitCache.java    From hadoop with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 2
Source File: GoogleIdTokenAuthTest.java    From styx with Apache License 2.0 5 votes vote down vote up
@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"));
}
 
Example 3
Source File: JavaxCryptoTest.java    From jcredstash with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 4
Source File: TestScrLazyPersistFiles.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test
public void testShortCircuitReadMetaFileCorruption() throws IOException,
    InterruptedException {
  Assume.assumeThat(DomainSocket.getLoadingFailureReason(), equalTo(null));
  startUpCluster(true, 1 + EVICTION_LOW_WATERMARK, true, false);
  doShortCircuitReadMetaFileCorruptionTest();
}
 
Example 5
Source File: TestScrLazyPersistFiles.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test
public void testShortCircuitReadBlockFileCorruption() throws IOException,
    InterruptedException {
  Assume.assumeThat(DomainSocket.getLoadingFailureReason(), equalTo(null));
  startUpCluster(true, 1 + EVICTION_LOW_WATERMARK, true, false);
  doShortCircuitReadBlockFileCorruptionTest();
}
 
Example 6
Source File: TimeSourceIntegrationTests.java    From spring-cloud-stream-app-starters with Apache License 2.0 5 votes vote down vote up
@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));
}
 
Example 7
Source File: TestScrLazyPersistFiles.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test
public void testShortCircuitReadAfterEviction()
    throws IOException, InterruptedException {
  Assume.assumeThat(DomainSocket.getLoadingFailureReason(), equalTo(null));
  startUpCluster(true, 1 + EVICTION_LOW_WATERMARK, true, false);
  doShortCircuitReadAfterEvictionTest();
}
 
Example 8
Source File: TestScrLazyPersistFiles.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Test
public void testShortCircuitReadMetaFileCorruption() throws IOException,
    InterruptedException {
  Assume.assumeThat(DomainSocket.getLoadingFailureReason(), equalTo(null));
  startUpCluster(true, 1 + EVICTION_LOW_WATERMARK, true, false);
  doShortCircuitReadMetaFileCorruptionTest();
}
 
Example 9
Source File: TestScrLazyPersistFiles.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Test
public void testShortCircuitReadBlockFileCorruption() throws IOException,
    InterruptedException {
  Assume.assumeThat(DomainSocket.getLoadingFailureReason(), equalTo(null));
  startUpCluster(true, 1 + EVICTION_LOW_WATERMARK, true, false);
  doShortCircuitReadBlockFileCorruptionTest();
}
 
Example 10
Source File: KubernetesTestUtil.java    From kubernetes-pipeline-plugin with Apache License 2.0 4 votes vote down vote up
public static void assumeMiniKube() throws Exception {
    Assume.assumeThat("MiniKube working", miniKubeIp(), not(isEmptyOrNullString()));
}
 
Example 11
Source File: GoogleIdTokenAuthTest.java    From styx with Apache License 2.0 4 votes vote down vote up
@Test
public void testUserCredentials() throws IOException, GeneralSecurityException {
  Assume.assumeThat(credentials, is(instanceOf(UserCredentials.class)));
  assertThat(canAcquireIdToken(credentials), is(true));
}
 
Example 12
Source File: HttpServerSpnegoWithJaasTest.java    From calcite-avatica with Apache License 2.0 4 votes vote down vote up
@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));
}
 
Example 13
Source File: TestParallelUnixDomainRead.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Before
public void before() {
  Assume.assumeThat(DomainSocket.getLoadingFailureReason(), equalTo(null));
}
 
Example 14
Source File: TestParallelUnixDomainRead.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Before
public void before() {
  Assume.assumeThat(DomainSocket.getLoadingFailureReason(), equalTo(null));
}
 
Example 15
Source File: TestScrLazyPersistFiles.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Before
public void before() {
  Assume.assumeThat(NativeCodeLoader.isNativeCodeLoaded() && !Path.WINDOWS,
      equalTo(true));
  Assume.assumeThat(DomainSocket.getLoadingFailureReason(), equalTo(null));
}
 
Example 16
Source File: TestParallelShortCircuitRead.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Before
public void before() {
  Assume.assumeThat(DomainSocket.getLoadingFailureReason(), equalTo(null));
}
 
Example 17
Source File: EspressoTestBase.java    From espresso-macchiato with MIT License 4 votes vote down vote up
public void skipTestIfBelowAndroidMarshmallow() {
    Assume.assumeThat(Build.VERSION.SDK_INT, Matchers.greaterThanOrEqualTo(Build.VERSION_CODES.M));
}
 
Example 18
Source File: TestParallelShortCircuitReadUnCached.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Before
public void before() {
  Assume.assumeThat(DomainSocket.getLoadingFailureReason(), equalTo(null));
}
 
Example 19
Source File: TestParallelShortCircuitReadNoChecksum.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Before
public void before() {
  Assume.assumeThat(DomainSocket.getLoadingFailureReason(), equalTo(null));
}
 
Example 20
Source File: TestBlockReaderFactory.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Before
public void init() {
  DomainSocket.disableBindPathValidation();
  Assume.assumeThat(DomainSocket.getLoadingFailureReason(), equalTo(null));
}