Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldPublishStoredClusterIdIfPreviouslyBound() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldPublishStoredClusterIdIfPreviouslyBound()
        {
            // given
            ClusterId previouslyBoundClusterId = new ClusterId(System.Guid.randomUUID());

            CoreTopologyService topologyService = mock(typeof(CoreTopologyService));

            when(topologyService.SetClusterId(previouslyBoundClusterId, "default")).thenReturn(true);

            StubSimpleStorage <ClusterId> clusterIdStorage = new StubSimpleStorage <ClusterId>(this);

            clusterIdStorage.WriteState(previouslyBoundClusterId);

            ClusterBinder binder = ClusterBinder(clusterIdStorage, topologyService);

            // when
            binder.BindToCluster();

            // then
            verify(topologyService).setClusterId(previouslyBoundClusterId, "default");
            Optional <ClusterId> clusterId = binder.Get();

            assertTrue(clusterId.Present);
            assertEquals(previouslyBoundClusterId, clusterId.get());
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBootstrapWhenBootstrappable() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldBootstrapWhenBootstrappable()
        {
            // given
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            IDictionary <MemberId, CoreServerInfo> members = IntStream.range(0, _minCoreHosts).mapToObj(i => Pair.of(new MemberId(System.Guid.randomUUID()), TestTopology.addressesForCore(i, false))).collect(Collectors.toMap(Pair::first, Pair::other));

            CoreTopology bootstrappableTopology = new CoreTopology(null, true, members);

            CoreTopologyService topologyService = mock(typeof(CoreTopologyService));

            when(topologyService.LocalCoreServers()).thenReturn(bootstrappableTopology);
            when(topologyService.SetClusterId(any(), eq("default"))).thenReturn(true);
            CoreSnapshot snapshot = mock(typeof(CoreSnapshot));

            when(_coreBootstrapper.bootstrap(any())).thenReturn(snapshot);

            ClusterBinder binder = ClusterBinder(new StubSimpleStorage <ClusterId>(this), topologyService);

            // when
            BoundState boundState = binder.BindToCluster();

            // then
            verify(_coreBootstrapper).bootstrap(any());
            Optional <ClusterId> clusterId = binder.Get();

            assertTrue(clusterId.Present);
            verify(topologyService).setClusterId(clusterId.get(), "default");
            assertTrue(boundState.Snapshot().Present);
            assertEquals(boundState.Snapshot().get(), snapshot);
        }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBindToClusterIdPublishedByAnotherMember() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldBindToClusterIdPublishedByAnotherMember()
        {
            // given
            ClusterId    publishedClusterId = new ClusterId(System.Guid.randomUUID());
            CoreTopology unboundTopology    = new CoreTopology(null, false, emptyMap());
            CoreTopology boundTopology      = new CoreTopology(publishedClusterId, false, emptyMap());

            CoreTopologyService topologyService = mock(typeof(CoreTopologyService));

            when(topologyService.LocalCoreServers()).thenReturn(unboundTopology).thenReturn(boundTopology);

            ClusterBinder binder = ClusterBinder(new StubSimpleStorage <ClusterId>(this), topologyService);

            // when
            binder.BindToCluster();

            // then
            Optional <ClusterId> clusterId = binder.Get();

            assertTrue(clusterId.Present);
            assertEquals(publishedClusterId, clusterId.get());
            verify(topologyService, atLeast(2)).localCoreServers();
        }