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

The following examples show how to use org.junit.Assume#assumeNotNull() . 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: BenchmarkTest.java    From AVM with MIT License 6 votes vote down vote up
/**
 * 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);
}
 
Example 2
Source File: TestAppBundleGenerator.java    From dremio-oss with Apache License 2.0 6 votes vote down vote up
@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);
    }
  }));
}
 
Example 3
Source File: ObjectStoreFileSystemTest.java    From stocator with Apache License 2.0 6 votes vote down vote up
@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));
}
 
Example 4
Source File: ObjectStoreFileSystemTest.java    From stocator with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example 5
Source File: TestConfigSetsAPI.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@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");

}
 
Example 6
Source File: SmartlingClientTest.java    From mojito with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 7
Source File: MantaPublicKeyAuthenticationTest.java    From cyberduck with GNU General Public License v3.0 5 votes vote down vote up
@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();
    }
}
 
Example 8
Source File: GoogleIdTokenAuthTest.java    From styx with Apache License 2.0 5 votes vote down vote up
@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));
}
 
Example 9
Source File: ObjectStoreFileSystemTest.java    From stocator with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 10
Source File: ScriptEngineTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
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());
}
 
Example 11
Source File: ScriptEngineTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@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"));
}
 
Example 12
Source File: ReadWriteTest.java    From jcifs-ng with GNU Lesser General Public License v2.1 4 votes vote down vote up
private String getCallPipeUrl () {
    String testCallPipe = getProperties().get(TestProperties.TEST_CALL_PIPE);
    Assume.assumeNotNull(testCallPipe);
    return "smb://" + getTestServer() + "/IPC$/" + testCallPipe;
}
 
Example 13
Source File: BaseCIFSTest.java    From jcifs with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected String getTestDomain () {
    String testDomain = getProperties().get(TestProperties.TEST_DOMAIN);
    Assume.assumeNotNull(testDomain);
    return testDomain;
}
 
Example 14
Source File: BaseCIFSTest.java    From jcifs with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected String getRequiredProperty ( String prop ) {
    String val = this.properties.get(prop);
    Assume.assumeNotNull(val);
    return val;
}
 
Example 15
Source File: SwiftBaseTest.java    From stocator with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() throws Exception {
  Assume.assumeNotNull(sFileSystem);
}
 
Example 16
Source File: IntegrationTestSettings.java    From line-bot-sdk-java with Apache License 2.0 4 votes vote down vote up
public String getUserId() {
    Assume.assumeNotNull(userId);
    return userId;
}
 
Example 17
Source File: StatelessScriptUpdateProcessorFactoryTest.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void beforeClass() throws Exception {
  Assume.assumeNotNull((new ScriptEngineManager()).getEngineByExtension("js"));
  initCore("solrconfig-script-updateprocessor.xml", "schema12.xml");
}
 
Example 18
Source File: BaseCIFSTest.java    From jcifs with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected String getTestShareGuestURL () {
    String testGuestShare = getProperties().get(TestProperties.TEST_SHARE_GUEST);
    Assume.assumeNotNull(testGuestShare);
    return "smb://" + getTestServer() + "/" + testGuestShare + "/";
}
 
Example 19
Source File: IntegrationTestSettings.java    From line-bot-sdk-java with Apache License 2.0 4 votes vote down vote up
public String getRetargetingRequestId() {
    Assume.assumeNotNull(retargetingRequestId);
    return retargetingRequestId;
}
 
Example 20
Source File: ThirdPartyTMSSmartlingTest.java    From mojito with Apache License 2.0 4 votes vote down vote up
@Before
public void init() {
    Assume.assumeNotNull(smartlingClient);
}