当前位置: 首页>>代码示例>>Java>>正文


Java Assume.assumeNotNull方法代码示例

本文整理汇总了Java中org.junit.Assume.assumeNotNull方法的典型用法代码示例。如果您正苦于以下问题:Java Assume.assumeNotNull方法的具体用法?Java Assume.assumeNotNull怎么用?Java Assume.assumeNotNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.junit.Assume的用法示例。


在下文中一共展示了Assume.assumeNotNull方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: compileDependencyClass

import org.junit.Assume; //导入方法依赖的package包/类
@BeforeClass
public static void compileDependencyClass() throws IOException, ClassNotFoundException {
  JavaCompiler javaCompiler = ToolProvider.getSystemJavaCompiler();
  Assume.assumeNotNull(javaCompiler);

  classes = temporaryFolder.newFolder("classes");;

  StandardJavaFileManager fileManager = javaCompiler.getStandardFileManager(null, Locale.ROOT, UTF_8);
  fileManager.setLocation(StandardLocation.CLASS_OUTPUT, ImmutableList.of(classes));

  SimpleJavaFileObject compilationUnit = new SimpleJavaFileObject(URI.create("FooTest.java"), Kind.SOURCE) {
    String fooTestSource = Resources.toString(Resources.getResource("com/dremio/exec/compile/FooTest.java"), UTF_8);
    @Override
    public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
      return fooTestSource;
    }
  };

  CompilationTask task = javaCompiler.getTask(null, fileManager, null, Collections.<String>emptyList(), null, ImmutableList.of(compilationUnit));
  assertTrue(task.call());
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:22,代码来源:TestClassCompilers.java

示例3: setUp

import org.junit.Assume; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() {
  try {
    Assume.assumeNotNull(InetAddress.getByName("stream.twitter.com"));
  } catch (UnknownHostException e) {
    Assume.assumeTrue(false); // ignore Test if twitter is unreachable
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:9,代码来源:TestTwitterSource.java

示例4: testAuthenticateOpenSSHKeyWithoutPassphrase

import org.junit.Assume; //导入方法依赖的package包/类
@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(new DisabledHostKeyCallback(), new DisabledLoginCallback());
        session.login(new DisabledPasswordStore(),
            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();
    }
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:36,代码来源:MantaPublicKeyAuthenticationTest.java

示例5: assumeMatchingQuickstartIsFound

import org.junit.Assume; //导入方法依赖的package包/类
private void assumeMatchingQuickstartIsFound() {
    if (this.index == null) {
        Assume.assumeNotNull(this.defaultConfiguration);
        this.configuration = defaultConfiguration;
        logger.info("Using default InstanceConfiguration provided (URL: {}, runmode: {}) for test {}",
                configuration.getUrl(), configuration.getRunmode(), description);
    }
}
 
开发者ID:apache,项目名称:sling-org-apache-sling-testing-rules,代码行数:9,代码来源:ExistingInstanceStatement.java

示例6: assume

import org.junit.Assume; //导入方法依赖的package包/类
public static void assume(Object... objects) {
  for (Object object : objects) {
    Assume.assumeNotNull(
        String.format("Test has been skipped. Required object \"%s\" is null.", object),
        object);
  }
}
 
开发者ID:FelixGail,项目名称:gplaymusic,代码行数:8,代码来源:TestUtil.java

示例7: testBasic

import org.junit.Assume; //导入方法依赖的package包/类
@Test
public void testBasic() throws Exception {
  String consumerKey = System.getProperty("twitter.consumerKey");
  Assume.assumeNotNull(consumerKey);

  String consumerSecret = System.getProperty("twitter.consumerSecret");
  Assume.assumeNotNull(consumerSecret);

  String accessToken = System.getProperty("twitter.accessToken");
  Assume.assumeNotNull(accessToken);

  String accessTokenSecret = System.getProperty("twitter.accessTokenSecret");
  Assume.assumeNotNull(accessTokenSecret);

  Context context = new Context();
  context.put("consumerKey", consumerKey);
  context.put("consumerSecret", consumerSecret);
  context.put("accessToken", accessToken);
  context.put("accessTokenSecret", accessTokenSecret);
  context.put("maxBatchDurationMillis", "1000");

  TwitterSource source = new TwitterSource();
  source.configure(context);

  Map<String, String> channelContext = new HashMap();
  channelContext.put("capacity", "1000000");
  channelContext.put("keep-alive", "0"); // for faster tests
  Channel channel = new MemoryChannel();
  Configurables.configure(channel, new Context(channelContext));

  Sink sink = new LoggerSink();
  sink.setChannel(channel);
  sink.start();
  DefaultSinkProcessor proc = new DefaultSinkProcessor();
  proc.setSinks(Collections.singletonList(sink));
  SinkRunner sinkRunner = new SinkRunner(proc);
  sinkRunner.start();

  ChannelSelector rcs = new ReplicatingChannelSelector();
  rcs.setChannels(Collections.singletonList(channel));
  ChannelProcessor chp = new ChannelProcessor(rcs);
  source.setChannelProcessor(chp);
  source.start();

  Thread.sleep(5000);
  source.stop();
  sinkRunner.stop();
  sink.stop();
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:50,代码来源:TestTwitterSource.java

示例8: testAuthenticateOpenSSHKeyWithPassphrase

import org.junit.Assume; //导入方法依赖的package包/类
@Test
public void testAuthenticateOpenSSHKeyWithPassphrase() throws Exception {
    Assume.assumeNotNull(System.getProperty("manta.url"), System.getProperty("manta.passphrase.key_id"), System.getProperty("manta.passphrase.key_path"), System.getProperty("manta.passphrase.password"));

    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);
    final String passphraseKeyPassword = System.getProperty("manta.passphrase.password");
    final String passphraseKeyPath = System.getProperty("manta.passphrase.key_path");
    if(passphraseKeyPassword == null || passphraseKeyPath == null) {
        Assert.fail("No passphrase key configured, please set 'manta.passphrase.key_path' and 'manta.passphrase.password' to a key path and passphrase respectively");
    }

    try {

        new DefaultLocalTouchFeature().touch(key);
        IOUtils.copy(
            new FileReader(passphraseKeyPath),
            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(new DisabledHostKeyCallback(), new DisabledLoginCallback());
        session.login(new DisabledPasswordStore(),
            new DisabledLoginCallback() {
                @Override
                public Credentials prompt(final Host bookmark, final String title, final String reason, final LoginOptions options) throws LoginCanceledException {
                    return new VaultCredentials(passphraseKeyPassword);
                }
            },
            new DisabledCancelCallback()
        );
        assertEquals(System.getProperty("manta.passphrase.key_id"), session.getClient().getContext().getMantaKeyId());
        session.close();
    }
    finally {
        key.delete();
    }

}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:43,代码来源:MantaPublicKeyAuthenticationTest.java


注:本文中的org.junit.Assume.assumeNotNull方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。