本文整理汇总了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());
}
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
}
}
示例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);
}
示例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);
}
}
示例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);
}
示例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());
}
示例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);
}
}
示例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());
}
示例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);
}
示例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());
}
示例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);
}