use of com.couchbase.client.core.CoreContext in project couchbase-jvm-clients by couchbase.
the class ClusterManagerBucketLoaderTest method setup.
@BeforeEach
void setup() {
CoreEnvironment env = mock(CoreEnvironment.class);
when(env.timeoutConfig()).thenReturn(TimeoutConfig.create());
when(env.retryStrategy()).thenReturn(BestEffortRetryStrategy.INSTANCE);
core = mock(Core.class);
CoreContext ctx = new CoreContext(core, 1, env, mock(Authenticator.class));
when(core.context()).thenReturn(ctx);
loader = new ClusterManagerBucketLoader(core);
}
use of com.couchbase.client.core.CoreContext in project couchbase-jvm-clients by couchbase.
the class KeyValueBucketLoaderTest method setup.
@BeforeEach
void setup() {
CoreEnvironment env = mock(CoreEnvironment.class);
when(env.timeoutConfig()).thenReturn(TimeoutConfig.create());
when(env.retryStrategy()).thenReturn(BestEffortRetryStrategy.INSTANCE);
core = mock(Core.class);
CoreContext ctx = new CoreContext(core, 1, env, mock(Authenticator.class));
when(core.context()).thenReturn(ctx);
loader = new KeyValueBucketLoader(core);
}
use of com.couchbase.client.core.CoreContext in project couchbase-jvm-clients by couchbase.
the class DefaultConfigurationProviderTest method applyBucketConfigWithRevOrEpoch.
@ParameterizedTest
@CsvSource({ "config_lower_rev_no_epoch,1,0,config_higher_rev_no_epoch,2,0", "config_lower_rev_no_epoch,1,0,config_lower_rev_higher_epoch,1,2", "config_lower_rev_lower_epoch,1,1,config_lower_rev_higher_epoch,1,2", "config_higher_rev_lower_epoch,2,1,config_lower_rev_higher_epoch,1,2" })
void applyBucketConfigWithRevOrEpoch(String oldConfigFile, long oldRev, long oldEpoch, String newConfigFile, long newRev, long newEpoch) {
Core core = mock(Core.class);
when(core.context()).thenReturn(new CoreContext(core, 1, ENVIRONMENT, mock(Authenticator.class)));
DefaultConfigurationProvider provider = new DefaultConfigurationProvider(core, SeedNode.LOCALHOST);
String bucket = "travel-sample";
String config = readResource(oldConfigFile + ".json", DefaultConfigurationProviderTest.class);
provider.proposeBucketConfig(new ProposedBucketConfigContext(bucket, config, ORIGIN));
assertEquals(oldRev, provider.config().bucketConfig(bucket).rev());
assertEquals(oldEpoch, provider.config().bucketConfig(bucket).revEpoch());
String newConfig = readResource(newConfigFile + ".json", DefaultConfigurationProviderTest.class);
provider.proposeBucketConfig(new ProposedBucketConfigContext(bucket, newConfig, ORIGIN));
assertEquals(newRev, provider.config().bucketConfig(bucket).rev());
assertEquals(newEpoch, provider.config().bucketConfig(bucket).revEpoch());
}
use of com.couchbase.client.core.CoreContext in project couchbase-jvm-clients by couchbase.
the class DefaultConfigurationProviderTest method currentConfigIsReplayedToLateSubscriber.
@Test
void currentConfigIsReplayedToLateSubscriber() {
Core core = mock(Core.class);
CoreContext ctx = new CoreContext(core, 1, ENVIRONMENT, mock(Authenticator.class));
when(core.context()).thenReturn(ctx);
DefaultConfigurationProvider provider = new DefaultConfigurationProvider(core, SeedNode.LOCALHOST);
provider.configs().blockFirst(Duration.ofSeconds(10));
}
use of com.couchbase.client.core.CoreContext in project couchbase-jvm-clients by couchbase.
the class DefaultConfigurationProviderTest method canUpdateConfigWithNewRev.
@Test
void canUpdateConfigWithNewRev() {
Core core = mock(Core.class);
when(core.context()).thenReturn(new CoreContext(core, 1, ENVIRONMENT, mock(Authenticator.class)));
DefaultConfigurationProvider provider = new DefaultConfigurationProvider(core, SeedNode.LOCALHOST);
final AtomicInteger configsPushed = new AtomicInteger(0);
provider.configs().skip(// ignore initial empty config
1).subscribe((c) -> configsPushed.incrementAndGet());
assertTrue(provider.config().bucketConfigs().isEmpty());
String bucket = "default";
String config = readResource("config_with_external.json", DefaultConfigurationProviderTest.class);
provider.proposeBucketConfig(new ProposedBucketConfigContext(bucket, config, ORIGIN));
assertEquals(1, configsPushed.get());
String newConfig = readResource("config_with_external_higher_rev.json", DefaultConfigurationProviderTest.class);
provider.proposeBucketConfig(new ProposedBucketConfigContext(bucket, newConfig, ORIGIN));
assertEquals(2, configsPushed.get());
assertFalse(provider.config().bucketConfigs().isEmpty());
assertEquals(1888, provider.config().bucketConfig("default").rev());
}
Aggregations