public void ServiceDiscovery_should_throw_when_no_default_discovery_configured() { using var sys = ActorSystem.Create("DiscoveryConfigurationSpec"); var ex = Assert.Throws <ArgumentException>(() => _ = Discovery.Get(sys).Default); ex.Message.Should().Contain("No default service discovery implementation configured"); }
public void ServiceDiscovery_should_throw_an_argument_exception_for_not_existing_method() { const string className = "className"; using var sys = ActorSystem.Create( "DiscoveryConfigurationSpec", ConfigurationFactory.ParseString($@" akka.discovery {{ method = ""{className}"" }}").WithFallback(ConfigurationFactory.Load())); Assert.Throws <ArgumentException>(() => _ = Discovery.Get(sys).Default); }
public void ServiceDiscovery_should_give_warning_when_no_default_discovery_configured() { using var sys = ActorSystem.Create(nameof(DiscoveryConfigurationSpec), DefaultConfig); var probe = CreateTestProbe(sys); sys.EventStream.Subscribe(probe.Ref, typeof(Warning)); var discovery = Discovery.Get(sys).Default; AwaitAssert(() => { probe.ExpectMsg <Warning>().Message.ToString().Should() .StartWith("No default service discovery implementation configured in `akka.discovery.method`."); }); }
public void ServiceDiscovery_should_select_implementation_from_config_by_config_name_inside_namespace() { var className = typeof(FakeTestDiscovery).TypeQualifiedName(); using var sys = ActorSystem.Create( "DiscoveryConfigurationSpec", ConfigurationFactory.ParseString($@" akka.discovery {{ method = akka-mock-inside akka-mock-inside {{ class = ""{className}"" }} }}").WithFallback(ConfigurationFactory.Load())); var discovery = Discovery.Get(sys).Default; discovery.Should().BeAssignableTo <FakeTestDiscovery>(); }
public void ServiceDiscovery_should_throw_a_specific_discovery_method_exception() { var className = typeof(ExceptionThrowingDiscovery).TypeQualifiedName(); using var sys = ActorSystem.Create( "DiscoveryConfigurationSpec", ConfigurationFactory.ParseString($@" akka.discovery {{ method = mock1 mock1 {{ class = ""{className}"" }} }}").WithFallback(ConfigurationFactory.Load())); Action discoveryInstance = () => _ = Discovery.Get(sys).Default; discoveryInstance .Should().Throw <TargetInvocationException>() .WithInnerException <DiscoveryException>(); }
public void ServiceDiscovery_should_return_same_instance_for_same_method() { var className1 = typeof(FakeTestDiscovery).TypeQualifiedName(); var className2 = typeof(FakeTestDiscovery2).TypeQualifiedName(); using var sys = ActorSystem.Create( "DiscoveryConfigurationSpec", ConfigurationFactory.ParseString($@" akka.discovery {{ method = mock1 mock1 {{ class = ""{className1}"" }} mock2 {{ class = ""{className2}"" }} }}").WithFallback(ConfigurationFactory.Load())); Discovery.Get(sys).LoadServiceDiscovery("mock2").Should().BeSameAs(Discovery.Get(sys).LoadServiceDiscovery("mock2")); Discovery.Get(sys).Default.Should().BeSameAs(Discovery.Get(sys).LoadServiceDiscovery("mock1")); }
public void ServiceDiscovery_should_load_another_implementation_from_config_by_config_name() { var className1 = typeof(FakeTestDiscovery).TypeQualifiedName(); var className2 = typeof(FakeTestDiscovery2).TypeQualifiedName(); using var sys = ActorSystem.Create( "DiscoveryConfigurationSpec", ConfigurationFactory.ParseString($@" akka.discovery {{ method = mock1 mock1 {{ class = ""{className1}"" }} mock2 {{ class = ""{className2}"" }} }}").WithFallback(ConfigurationFactory.Load())); Discovery.Get(sys).Default.Should().BeAssignableTo <FakeTestDiscovery>(); Discovery.Get(sys).LoadServiceDiscovery("mock2").Should().BeAssignableTo <FakeTestDiscovery2>(); }
public ConfigServiceDiscoverySpec() : base(Config, "ConfigDiscoverySpec") { _discovery = Discovery.Get(Sys).Default; }