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

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

源代码1 项目: AVM   文件: BenchmarkTest.java
/**
 * Note that this "test" method only exists as a convenient way to capture test resources to deploy into other environments.
 * Set the "TEST_RESOURCES" env var in order to write these resources out.
 */
@Test
public void outputTestResources() throws Exception {
    String outputPath = System.getenv("TEST_RESOURCES");
    // Ignore this is not set.
    Assume.assumeNotNull(outputPath);
    
    // For both of these, capture the optimized JAR and ABI.
    System.out.println("Outputing test resources to: \"" + outputPath + "\"");
    outputResourcesForTestClass(outputPath, CallContract.class);
    outputResourcesForTestClass(outputPath, CPUIntensiveOperations.class);
    outputResourcesForTestClass(outputPath, MemoryUsage.class);
    outputResourcesForTestClass(outputPath, SimpleContractWithABI.class);
    outputResourcesForTestClass(outputPath, SimpleContractWithoutABI.class);
    outputResourcesForTestClass(outputPath, SimpleStorageStatic.class);
    outputResourcesForTestClass(outputPath, StorageLargeDataContract.class);
}
 
源代码2 项目: dremio-oss   文件: TestAppBundleGenerator.java
@Test
public void testSkipJDKClassLoaders() throws MalformedURLException, IOException {
  ClassLoader classLoader = ClassLoader.getSystemClassLoader();
  ClassLoader parent = classLoader.getParent();

  // This test is only meaningful if parent classloader exists (most likely the extension classloader
  // and is also a URLClassLoader
  Assume.assumeNotNull(parent);
  Assume.assumeTrue(parent instanceof URLClassLoader);

  URL[] parentURLs = ((URLClassLoader) parent).getURLs();

  Stream<Path> stream = AppBundleGenerator.toPathStream(classLoader);

  assertFalse("Stream contains a jar from the parent classloader", stream.anyMatch(path -> {
    try {
      return Arrays.asList(parentURLs).contains(path.toUri().toURL());
    } catch (MalformedURLException e) {
      throw new IllegalArgumentException(e);
    }
  }));
}
 
源代码3 项目: stocator   文件: ObjectStoreFileSystemTest.java
@Test
public void deleteTest() throws Exception {
  Assume.assumeNotNull(getFs());

  Path testFile = new Path(getBaseURI() + "/testFile");
  createFile(testFile, data);
  Path input = new Path(getBaseURI() + "/a/b/c/m.data/_temporary/"
          + "0/_temporary/attempt_201603141928_0000_m_000099_102/part-00099");
  Whitebox.setInternalState(mMockObjectStoreFileSystem, "hostNameScheme", getBaseURI());
  String result = Whitebox.invokeMethod(mMockStocatorPath, "parseHadoopFOutputCommitterV1", input,
      true, getBaseURI());
  Path modifiedInput = new Path(getBaseURI() + result);
  createFile(input, data);
  Assert.assertTrue(getFs().exists(modifiedInput));
  Assert.assertTrue(getFs().exists(testFile));

  getFs().delete(testFile, false);
  Assert.assertFalse(getFs().exists(testFile));

  getFs().delete(modifiedInput, false);
  Assert.assertFalse(getFs().exists(modifiedInput));
}
 
源代码4 项目: lucene-solr   文件: ScriptEngineTest.java
public void testJRuby() throws ScriptException, NoSuchMethodException {  
  // Simply adding jruby.jar to Solr's lib/ directory gets this test passing
  ScriptEngine engine = manager.getEngineByName("jruby");

  Assume.assumeNotNull(engine);

  assertNotNull(engine);
  engine.eval("def add(a,b); a + b; end");
  Number result = (Number) ((Invocable)engine).invokeFunction("add", 1, 2);
  assertNotNull(result);
  assertEquals(3, result.intValue());
}
 
源代码5 项目: stocator   文件: ObjectStoreFileSystemTest.java
@Test
public void openCreateTest() throws Exception {
  Assume.assumeNotNull(getFs());
  Path testFile = new Path(getBaseURI() + "/testFile");
  createFile(testFile, data);
  FSDataInputStream inputStream = getFs().open(testFile);
  String uri = (Whitebox.getInternalState(inputStream.getWrappedStream(), "uri"));
  Path path = new Path(uri);
  Assert.assertEquals(testFile.getName(), path.getName());
}
 
源代码6 项目: lucene-solr   文件: TestConfigSetsAPI.java
@Test
public void testUploadWithScriptUpdateProcessor() throws Exception {
  Assume.assumeNotNull((new ScriptEngineManager()).getEngineByExtension("js"));
  Assume.assumeNotNull((new ScriptEngineManager()).getEngineByName("JavaScript"));
  
    // Authorization off
    // unprotectConfigsHandler(); // TODO Enable this back when testUploadWithLibDirective() is re-enabled
    final String untrustedSuffix = "-untrusted";
    uploadConfigSetWithAssertions("with-script-processor", untrustedSuffix, null, null);
    // try to create a collection with the uploaded configset
    Throwable thrown = expectThrows(BaseHttpSolrClient.RemoteSolrException.class, () -> {
      createCollection("newcollection2", "with-script-processor" + untrustedSuffix,
    1, 1, solrCluster.getSolrClient());
    });

  assertThat(thrown.getMessage(), containsString("Underlying core creation failed"));

  // Authorization on
  final String trustedSuffix = "-trusted";
  protectConfigsHandler();
  uploadConfigSetWithAssertions("with-script-processor", trustedSuffix, "solr", "SolrRocks");
  // try to create a collection with the uploaded configset
  CollectionAdminResponse resp = createCollection("newcollection2", "with-script-processor" + trustedSuffix,
  1, 1, solrCluster.getSolrClient());
  scriptRequest("newcollection2");

}
 
源代码7 项目: mojito   文件: SmartlingClientTest.java
@Test
public void testUploadContextPNGUpperCase() throws IOException {
    Assume.assumeNotNull(smartlingTestConfig.projectId);
    ClassPathResource classPathResource = new ClassPathResource("/com/box/l10n/mojito/img/1.png");
    byte[] content = ByteStreams.toByteArray(classPathResource.getInputStream());
    smartlingClient.uploadContext(smartlingTestConfig.projectId, "caseissuewithpng.PNG", content);
}
 
@Test
public void testAuthenticateOpenSSHKeyWithoutPassphrase() throws Exception {
    Assume.assumeNotNull(System.getProperty("manta.url"), System.getProperty("manta.key_id"), System.getProperty("manta.key_path"));

    final Credentials credentials = new Credentials(System.getProperty("manta.user"), "");
    final Local key = new Local(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString());
    credentials.setIdentity(key);

    try {
        new DefaultLocalTouchFeature().touch(key);
        IOUtils.copy(
            new FileReader(System.getProperty("manta.key_path")),
            key.getOutputStream(false),
            StandardCharsets.UTF_8
        );
        final String hostname = new URL(System.getProperty("manta.url")).getHost();
        final Host host = new Host(new MantaProtocol(), hostname, credentials);
        final MantaSession session = new MantaSession(host, new DisabledX509TrustManager(), new DefaultX509KeyManager());
        session.open(Proxy.DIRECT, new DisabledHostKeyCallback(), new DisabledLoginCallback());
        session.login(Proxy.DIRECT,
            new DisabledLoginCallback() {
                @Override
                public Credentials prompt(final Host bookmark, final String title, final String reason, final LoginOptions options) throws LoginCanceledException {
                    throw new LoginCanceledException();
                }
            },
            new DisabledCancelCallback()
        );
        assertEquals(session.getClient().getContext().getMantaKeyId(), System.getProperty("manta.key_id"));
        session.close();
    }
    finally {
        key.delete();
    }
}
 
源代码9 项目: stocator   文件: ObjectStoreFileSystemTest.java
@Test(expected = FileNotFoundException.class)
public void listLocatedStatusTestNotFound1() throws Exception {
  Assume.assumeNotNull(getFs());
  int count = 0;
  RemoteIterator<LocatedFileStatus> stats = getFs().listLocatedStatus(new Path(fileName));
  while (stats.hasNext()) {
    LocatedFileStatus stat = stats.next();
    Assert.assertTrue(stat.getPath().getName().startsWith("testFile"));
    count++;
  }
  Assert.assertEquals(iterNum * 0, count);
}
 
源代码10 项目: lucene-solr   文件: ScriptEngineTest.java
@BeforeClass
public static void beforeClass() throws Exception {
  assumeFalse("https://twitter.com/UweSays/status/260487231880433664 / SOLR-4233: OS X bogusly starts AWT!",
      Constants.MAC_OS_X);
  Assume.assumeNotNull((new ScriptEngineManager()).getEngineByExtension("js"));
  Assume.assumeNotNull((new ScriptEngineManager()).getEngineByName("JavaScript"));
}
 
源代码11 项目: styx   文件: GoogleIdTokenAuthTest.java
@Test
public void testServiceAccountCredentials() throws IOException, GeneralSecurityException {
  Assume.assumeNotNull(credentials);
  final GoogleCredentials serviceAccountCredentials;
  final URI keyUri = URI.create("gs://styx-oss-test/styx-test-user.json");
  try (InputStream is = Files.newInputStream(Paths.get(keyUri))) {
    serviceAccountCredentials = GoogleCredentials.fromStream(is);
  }
  assertThat(canAcquireIdToken(serviceAccountCredentials), is(true));
}
 
源代码12 项目: mojito   文件: ThirdPartyTMSSmartlingTest.java
@Before
public void init() {
    Assume.assumeNotNull(smartlingClient);
}
 
public String getRetargetingRequestId() {
    Assume.assumeNotNull(retargetingRequestId);
    return retargetingRequestId;
}
 
源代码14 项目: jcifs   文件: BaseCIFSTest.java
protected String getTestShareGuestURL () {
    String testGuestShare = getProperties().get(TestProperties.TEST_SHARE_GUEST);
    Assume.assumeNotNull(testGuestShare);
    return "smb://" + getTestServer() + "/" + testGuestShare + "/";
}
 
源代码15 项目: jcifs-ng   文件: ReadWriteTest.java
private String getCallPipeUrl () {
    String testCallPipe = getProperties().get(TestProperties.TEST_CALL_PIPE);
    Assume.assumeNotNull(testCallPipe);
    return "smb://" + getTestServer() + "/IPC$/" + testCallPipe;
}
 
@BeforeClass
public static void beforeClass() throws Exception {
  Assume.assumeNotNull((new ScriptEngineManager()).getEngineByExtension("js"));
  initCore("solrconfig-script-updateprocessor.xml", "schema12.xml");
}
 
public String getUserId() {
    Assume.assumeNotNull(userId);
    return userId;
}
 
源代码18 项目: stocator   文件: SwiftBaseTest.java
@Before
public void setUp() throws Exception {
  Assume.assumeNotNull(sFileSystem);
}
 
源代码19 项目: jcifs   文件: BaseCIFSTest.java
protected String getRequiredProperty ( String prop ) {
    String val = this.properties.get(prop);
    Assume.assumeNotNull(val);
    return val;
}
 
源代码20 项目: jcifs   文件: BaseCIFSTest.java
protected String getTestDomain () {
    String testDomain = getProperties().get(TestProperties.TEST_DOMAIN);
    Assume.assumeNotNull(testDomain);
    return testDomain;
}