本文整理了Java中com.segment.analytics.Analytics.shutdown()
方法的一些代码示例,展示了Analytics.shutdown()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Analytics.shutdown()
方法的具体详情如下:
包路径:com.segment.analytics.Analytics
类名称:Analytics
方法名:shutdown
[英]Stops this instance from accepting further requests.
[中]停止此实例接受进一步的请求。
代码示例来源:origin: segmentio/analytics-android
@Test
public void shutdownTwice() {
assertThat(analytics.shutdown).isFalse();
analytics.shutdown();
analytics.shutdown();
verify(stats).shutdown();
assertThat(analytics.shutdown).isTrue();
}
代码示例来源:origin: segmentio/analytics-android
@After
public void tearDown() {
analytics.shutdown();
}
代码示例来源:origin: segmentio/analytics-java
public static void main(String... args) throws Exception {
final BlockingFlush blockingFlush = BlockingFlush.create();
// https://segment.com/segment-engineering/sources/test-java/debugger
final Analytics analytics =
Analytics.builder("xemyw6oe3n")
.plugin(blockingFlush.plugin())
.plugin(new LoggingPlugin())
.client(createClient())
.build();
final String userId = System.getProperty("user.name");
final String anonymousId = UUID.randomUUID().toString();
final AtomicInteger count = new AtomicInteger();
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) {
Map<String, Object> properties = new LinkedHashMap<>();
properties.put("count", count.incrementAndGet());
analytics.enqueue(
TrackMessage.builder("Java Test")
.properties(properties)
.anonymousId(anonymousId)
.userId(userId));
}
}
analytics.flush();
blockingFlush.block();
analytics.shutdown();
}
代码示例来源:origin: segmentio/analytics-android
@Test
public void shutdown() {
assertThat(analytics.shutdown).isFalse();
analytics.shutdown();
verify(application).unregisterActivityLifecycleCallbacks(analytics.activityLifecycleCallback);
verify(stats).shutdown();
verify(networkExecutor).shutdown();
assertThat(analytics.shutdown).isTrue();
try {
analytics.track("foo");
fail("Enqueuing a message after shutdown should throw.");
} catch (IllegalStateException e) {
assertThat(e).hasMessage("Cannot enqueue messages after client is shutdown.");
}
try {
analytics.flush();
fail("Enqueuing a message after shutdown should throw.");
} catch (IllegalStateException e) {
assertThat(e).hasMessage("Cannot enqueue messages after client is shutdown.");
}
}
代码示例来源:origin: segmentio/analytics-android
analytics.shutdown();
代码示例来源:origin: segmentio/analytics-android
@Test
public void shutdownDisallowedOnCustomSingletonInstance() throws Exception {
Analytics.singleton = null;
try {
Analytics analytics = new Analytics.Builder(RuntimeEnvironment.application, "foo").build();
Analytics.setSingletonInstance(analytics);
analytics.shutdown();
fail("Calling shutdown() on static singleton instance should throw");
} catch (UnsupportedOperationException ignored) {
}
}
代码示例来源:origin: segmentio/analytics-android
@Test
public void multipleInstancesWithSameTagIsAllowedAfterShutdown() throws Exception {
new Analytics.Builder(RuntimeEnvironment.application, "foo").build().shutdown();
new Analytics.Builder(RuntimeEnvironment.application, "bar").tag("foo").build();
}
内容来源于网络,如有侵权,请联系作者删除!