當前位置: 首頁>>代碼示例>>Java>>正文


Java Assume類代碼示例

本文整理匯總了Java中org.junit.Assume的典型用法代碼示例。如果您正苦於以下問題:Java Assume類的具體用法?Java Assume怎麽用?Java Assume使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Assume類屬於org.junit包,在下文中一共展示了Assume類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: test3

import org.junit.Assume; //導入依賴的package包/類
@Test
public void test3() {
    Assume.assumeTrue("Only works on jdk8 right now", Java8OrEarlier);
    ResolvedJavaMethod method = getResolvedJavaMethod("test3Snippet");

    for (int i = 0; i < 2; i++) {
        Result actual;
        boolean expectedCompiledCode = (method.getProfilingInfo().getDeoptimizationCount(DeoptimizationReason.NotCompiledExceptionHandler) != 0);
        InstalledCode code = getCode(method, null, false, true, new OptionValues(getInitialOptions(), HighTier.Options.Inline, false));
        assertTrue(code.isValid());

        try {
            actual = new Result(code.executeVarargs(false), null);
        } catch (Exception e) {
            actual = new Result(null, e);
        }

        assertTrue(i > 0 == expectedCompiledCode, "expect compiled code to stay around after the first iteration");
        assertEquals(new Result(expectedCompiledCode, null), actual);
        assertTrue(expectedCompiledCode == code.isValid());
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:23,代碼來源:DeoptimizeOnExceptionTest.java

示例2: basicScenarioListShardMapsWithSqlAuthentication

import org.junit.Assume; //導入依賴的package包/類
@Test
@Category(value = ExcludeFromGatedCheckin.class)
public void basicScenarioListShardMapsWithSqlAuthentication() {
    // Try to create a test login
    Assume.assumeTrue("Failed to create sql login, test skipped", createTestLogin());

    SqlConnectionStringBuilder gsmSb = new SqlConnectionStringBuilder(Globals.SHARD_MAP_MANAGER_CONN_STRING);
    gsmSb.setIntegratedSecurity(false);
    gsmSb.setUser(testUser);
    gsmSb.setPassword(testPassword);

    SqlConnectionStringBuilder lsmSb = new SqlConnectionStringBuilder(Globals.SHARD_USER_CONN_STRING);
    lsmSb.setIntegratedSecurity(false);
    lsmSb.setUser(testUser);
    lsmSb.setPassword(testPassword);

    basicScenarioListShardMapsInternal(gsmSb.getConnectionString(), lsmSb.getConnectionString());

    // Drop test login
    dropTestLogin();
}
 
開發者ID:Microsoft,項目名稱:elastic-db-tools-for-java,代碼行數:22,代碼來源:ScenarioTests.java

示例3: testNonSecureRunAsSubmitter

import org.junit.Assume; //導入依賴的package包/類
@Test
public void testNonSecureRunAsSubmitter() throws Exception {
  Assume.assumeTrue(shouldRun());
  Assume.assumeFalse(UserGroupInformation.isSecurityEnabled());
  String expectedRunAsUser = appSubmitter;
  conf.set(YarnConfiguration.NM_NONSECURE_MODE_LIMIT_USERS, "false");
  exec.setConf(conf);
  File touchFile = new File(workSpace, "touch-file");
  int ret = runAndBlock("touch", touchFile.getAbsolutePath());

  assertEquals(0, ret);
  FileStatus fileStatus =
      FileContext.getLocalFSFileContext().getFileStatus(
        new Path(touchFile.getAbsolutePath()));
  assertEquals(expectedRunAsUser, fileStatus.getOwner());
  cleanupAppFiles(expectedRunAsUser);
  // reset conf
  conf.unset(YarnConfiguration.NM_NONSECURE_MODE_LIMIT_USERS);
  exec.setConf(conf);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:21,代碼來源:TestLinuxContainerExecutor.java

示例4: setup

import org.junit.Assume; //導入依賴的package包/類
@Before
public void setup() throws IllegalAccessException, NoSuchFieldException {

	Assume.assumeTrue(System.getProperty("skip.long") == null);
	TestUtils.disableSslCertChecking();

	amazonS3Client = AmazonS3ClientBuilder.standard()
			.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(
					LocalstackTestRunner.getEndpointS3(),
					LocalstackTestRunner.getDefaultRegion()))
			.withChunkedEncodingDisabled(true)
			.withPathStyleAccessEnabled(true).build();
	amazonS3Client.createBucket(bucketName);

	S3Config config = new S3Config();

	Field field = StorageServiceImpl.class.getDeclaredField("s3TransferManager");
	field.setAccessible(true);
	field.set(underTest, config.s3TransferManager(amazonS3Client));

	field = StorageServiceImpl.class.getDeclaredField("environment");
	field.setAccessible(true);
	field.set(underTest, environment);
}
 
開發者ID:CMSgov,項目名稱:qpp-conversion-tool,代碼行數:25,代碼來源:StorageServiceImplIntegration.java

示例5: testImplicit

import org.junit.Assume; //導入依賴的package包/類
@SuppressWarnings("try")
private void testImplicit(Integer i) {
    Assume.assumeTrue(runtime().getVMConfig().useCompressedOops);

    Container c = new Container();
    c.i = i;

    ResolvedJavaMethod method = getResolvedJavaMethod("testSnippet");
    Result expect = executeExpected(method, null, c);

    // make sure we don't get a profile that removes the implicit null check
    method.reprofile();

    OptionValues options = new OptionValues(getInitialOptions(), OptImplicitNullChecks, true);
    Result actual = executeActual(options, method, null, c);
    assertEquals(expect, actual);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:18,代碼來源:CompressedNullCheckTest.java

示例6: runGitHubJsonVMTest

import org.junit.Assume; //導入依賴的package包/類
public static void runGitHubJsonVMTest(String json) throws ParseException {
    Assume.assumeFalse("Online test is not available", json.equals(""));

    JSONParser parser = new JSONParser();
    JSONObject testSuiteObj = (JSONObject) parser.parse(json);

    TestSuite testSuite = new TestSuite(testSuiteObj);
    Iterator<TestCase> testIterator = testSuite.iterator();

    while (testIterator.hasNext()) {

        TestCase testCase = testIterator.next();

        TestRunner runner = new TestRunner();
        List<String> result = runner.runTestCase(testCase);
        try {
            Assert.assertTrue(result.isEmpty());
        } catch (AssertionError e) {
            System.out.println(String.format("Error on running testcase %s : %s", testCase.getName(), result.get(0)));
            throw e;
        }
    }
}
 
開發者ID:Aptoide,項目名稱:AppCoins-ethereumj,代碼行數:24,代碼來源:GitHubJSONTestSuite.java

示例7: testStat

import org.junit.Assume; //導入依賴的package包/類
@Test(timeout=10000)
public void testStat() throws Exception {
  Assume.assumeTrue(Stat.isAvailable());
  FileSystem fs = FileSystem.getLocal(new Configuration());
  Path testDir = new Path(getTestRootPath(fs), "teststat");
  fs.mkdirs(testDir);
  Path sub1 = new Path(testDir, "sub1");
  Path sub2 = new Path(testDir, "sub2");
  fs.mkdirs(sub1);
  fs.createSymlink(sub1, sub2, false);
  FileStatus stat1 = new Stat(sub1, 4096l, false, fs).getFileStatus();
  FileStatus stat2 = new Stat(sub2, 0, false, fs).getFileStatus();
  assertTrue(stat1.isDirectory());
  assertFalse(stat2.isDirectory());
  fs.delete(testDir, true);
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:17,代碼來源:TestStat.java

示例8: testDoFinalArguments

import org.junit.Assume; //導入依賴的package包/類
@Test(timeout=120000)
public void testDoFinalArguments() throws Exception {
  Assume.assumeTrue(OpensslCipher.getLoadingFailureReason() == null);
  OpensslCipher cipher = OpensslCipher.getInstance("AES/CTR/NoPadding");
  Assert.assertTrue(cipher != null);
  
  cipher.init(OpensslCipher.ENCRYPT_MODE, key, iv);
  
  // Require direct buffer
  ByteBuffer output = ByteBuffer.allocate(1024);
  
  try {
    cipher.doFinal(output);
    Assert.fail("Output buffer should be direct buffer.");
  } catch (IllegalArgumentException e) {
    GenericTestUtils.assertExceptionContains(
        "Direct buffer is required", e);
  }
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:20,代碼來源:TestOpensslCipher.java

示例9: testJceAesCtrCryptoCodec

import org.junit.Assume; //導入依賴的package包/類
@Test(timeout=120000)
public void testJceAesCtrCryptoCodec() throws Exception {
  if (!"true".equalsIgnoreCase(System.getProperty("runningWithNative"))) {
    LOG.warn("Skipping since test was not run with -Pnative flag");
    Assume.assumeTrue(false);
  }
  if (!NativeCodeLoader.buildSupportsOpenssl()) {
    LOG.warn("Skipping test since openSSL library not loaded");
    Assume.assumeTrue(false);
  }
  Assert.assertEquals(null, OpensslCipher.getLoadingFailureReason());
  cryptoCodecTest(conf, seed, 0, jceCodecClass, jceCodecClass, iv);
  cryptoCodecTest(conf, seed, count, jceCodecClass, jceCodecClass, iv);
  cryptoCodecTest(conf, seed, count, jceCodecClass, opensslCodecClass, iv);
  // Overflow test, IV: xx xx xx xx xx xx xx xx ff ff ff ff ff ff ff ff 
  for(int i = 0; i < 8; i++) {
    iv[8 + i] = (byte) 0xff;
  }
  cryptoCodecTest(conf, seed, count, jceCodecClass, jceCodecClass, iv);
  cryptoCodecTest(conf, seed, count, jceCodecClass, opensslCodecClass, iv);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:22,代碼來源:TestCryptoCodec.java

示例10: testSearchSameDirectory

import org.junit.Assume; //導入依賴的package包/類
@Test
public void testSearchSameDirectory() throws Exception {
    Assume.assumeTrue(session.getClient().existsAndIsAccessible(testPathPrefix.getAbsolute()));

    final String newDirectoryName = new AlphanumericRandomStringService().random();
    final Path newDirectory = new Path(testPathPrefix, newDirectoryName, TYPE_DIRECTORY);
    final String newFileName = new AlphanumericRandomStringService().random();
    new MantaDirectoryFeature(session).mkdir(newDirectory, null, null);
    new MantaTouchFeature(session).touch(new Path(newDirectory, newFileName, TYPE_FILE), null);

    final MantaSearchFeature s = new MantaSearchFeature(session);
    final AttributedList<Path> search = s.search(newDirectory, new NullFilter<>(), new DisabledListProgressListener());

    assertEquals(1, search.size());
    assertEquals(newFileName, search.get(0).getName());
}
 
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:17,代碼來源:MantaSearchFeatureTest.java

示例11: spyOnNameService

import org.junit.Assume; //導入依賴的package包/類
/**
 * Spy on the Java DNS infrastructure.
 * This likely only works on Sun-derived JDKs, but uses JUnit's
 * Assume functionality so that any tests using it are skipped on
 * incompatible JDKs.
 */
private NameService spyOnNameService() {
  try {
    Field f = InetAddress.class.getDeclaredField("nameServices");
    f.setAccessible(true);
    Assume.assumeNotNull(f);
    @SuppressWarnings("unchecked")
    List<NameService> nsList = (List<NameService>) f.get(null);

    NameService ns = nsList.get(0);
    Log log = LogFactory.getLog("NameServiceSpy");
    
    ns = Mockito.mock(NameService.class,
        new GenericTestUtils.DelegateAnswer(log, ns));
    nsList.set(0, ns);
    return ns;
  } catch (Throwable t) {
    LOG.info("Unable to spy on DNS. Skipping test.", t);
    // In case the JDK we're testing on doesn't work like Sun's, just
    // skip the test.
    Assume.assumeNoException(t);
    throw new RuntimeException(t);
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:30,代碼來源:TestDFSClientFailover.java

示例12: testDeleteLastBytes

import org.junit.Assume; //導入依賴的package包/類
/**
 * Test of setDeleteLastBytes method, of class ModifiableByteArray.
 */
@Test
public void testDeleteLastBytes() {
    LOGGER.info("testDeleteLastBytes");
    // Löscht modification lenght viele bytes
    Assume.assumeTrue(modification1.length < originalValue.length);
    int len = originalValue.length - modification1.length;
    byte[] expResult = new byte[len];
    System.arraycopy(originalValue, 0, expResult, 0, len);
    VariableModification<byte[]> modifier = ByteArrayModificationFactory.delete(len, modification1.length);
    start.setModification(modifier);

    LOGGER.debug("Expected: " + ArrayConverter.bytesToHexString(expResult));
    LOGGER.debug("Computed: " + ArrayConverter.bytesToHexString(start.getValue()));
    assertArrayEquals(expResult, start.getValue());

}
 
開發者ID:RUB-NDS,項目名稱:ModifiableVariable,代碼行數:20,代碼來源:ModifiableByteArrayTest.java

示例13: testReadWriteMessageSlicing

import org.junit.Assume; //導入依賴的package包/類
@Test
public void testReadWriteMessageSlicing() throws Exception {
    // The slicing is only implemented for tell-based protocol
    Assume.assumeTrue(testParameter.equals(ClientBackedDataStore.class));

    leaderDatastoreContextBuilder.maximumMessageSliceSize(100);
    followerDatastoreContextBuilder.maximumMessageSliceSize(100);
    initDatastoresWithCars("testLargeReadReplySlicing");

    final DOMStoreReadWriteTransaction rwTx = followerDistributedDataStore.newReadWriteTransaction();

    final NormalizedNode<?, ?> carsNode = CarsModel.create();
    rwTx.write(CarsModel.BASE_PATH, carsNode);

    verifyNode(rwTx, CarsModel.BASE_PATH, carsNode);
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:17,代碼來源:DistributedDataStoreRemotingIntegrationTest.java

示例14: failSupport

import org.junit.Assume; //導入依賴的package包/類
@Test
@Ignore("DX-4093")
public void failSupport() throws Exception {
  Assume.assumeTrue(!BaseTestServer.isMultinode());

  String badFileName = "fake_file_one";
  final Invocation invocation = getBuilder(
      getAPIv2()
          .path("datasets/new_untitled_sql")
          .queryParam("newVersion", newVersion())
  ).buildPost(Entity.entity(new CreateFromSQL("select * from " + badFileName, null), MediaType.APPLICATION_JSON_TYPE));
  expectError(FamilyExpectation.CLIENT_ERROR, invocation, Object.class);

  List<Job> jobs = ImmutableList.copyOf(l(JobsService.class).getAllJobs("*=contains=" + badFileName, null, null, 0, 1, null));
  assertEquals(1, jobs.size());
  Job job = jobs.get(0);
  String url = "/support/" + job.getJobId().getId();
  SupportResponse response = expectSuccess(getBuilder(url).buildPost(null), SupportResponse.class);
  assertTrue(response.getUrl().contains("Unable to upload diagnostics"));
  assertTrue("Failure including logs.", response.isIncludesLogs());
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:22,代碼來源:TestSupportService.java

示例15: testOpensslAesCtrCryptoCodec

import org.junit.Assume; //導入依賴的package包/類
@Test(timeout=120000)
public void testOpensslAesCtrCryptoCodec() throws Exception {
  if (!"true".equalsIgnoreCase(System.getProperty("runningWithNative"))) {
    LOG.warn("Skipping since test was not run with -Pnative flag");
    Assume.assumeTrue(false);
  }
  if (!NativeCodeLoader.buildSupportsOpenssl()) {
    LOG.warn("Skipping test since openSSL library not loaded");
    Assume.assumeTrue(false);
  }
  Assert.assertEquals(null, OpensslCipher.getLoadingFailureReason());
  cryptoCodecTest(conf, seed, 0, opensslCodecClass, opensslCodecClass, iv);
  cryptoCodecTest(conf, seed, count, opensslCodecClass, opensslCodecClass, iv);
  cryptoCodecTest(conf, seed, count, opensslCodecClass, jceCodecClass, iv);
  // Overflow test, IV: xx xx xx xx xx xx xx xx ff ff ff ff ff ff ff ff 
  for(int i = 0; i < 8; i++) {
    iv[8 + i] = (byte) 0xff;
  }
  cryptoCodecTest(conf, seed, count, opensslCodecClass, opensslCodecClass, iv);
  cryptoCodecTest(conf, seed, count, opensslCodecClass, jceCodecClass, iv);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:22,代碼來源:TestCryptoCodec.java


注:本文中的org.junit.Assume類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。