io.vertx.servicediscovery.ServiceDiscoveryOptions Java Examples
The following examples show how to use
io.vertx.servicediscovery.ServiceDiscoveryOptions.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DiscoveryRegistrarTest.java From vertx-graphql-service-discovery with Apache License 2.0 | 6 votes |
@Test public void should_Cleanup_Unused_Consumers_On_Closing_Managed_Discovery() { discoveryRegistrar = DiscoveryRegistrar.create(vertx); ServiceDiscovery discovery1 = discoveryRegistrar.startListening( new ServiceDiscoveryOptions().setName("discovery1"), record -> {}, refData -> {}).getDiscovery(); ServiceDiscovery discovery2 = discoveryRegistrar.startListening( new ServiceDiscoveryOptions().setName("discovery1"), record -> {}, refData -> {}).getDiscovery(); ServiceDiscovery discovery3 = discoveryRegistrar.startListening( new ServiceDiscoveryOptions().setName("discovery2").setAnnounceAddress("otherAnnounce"), record -> {}, refData -> {}).getDiscovery(); assertEquals(2, discoveryRegistrar.serviceDiscoveryNames().size()); assertNotNull(discoveryRegistrar.getDiscovery("discovery1")); assertEquals(discoveryRegistrar.getDiscovery("discovery1"), discovery2); assertNotEquals(discoveryRegistrar.getDiscovery("discovery2"), discoveryRegistrar.getDiscovery("discovery3")); // TODO Complete test discovery1.close(); }
Example #2
Source File: BaseMicroserviceVerticle.java From vertx-blueprint-microservice with Apache License 2.0 | 6 votes |
@Override public void start() throws Exception { // init service discovery instance discovery = ServiceDiscovery.create(vertx, new ServiceDiscoveryOptions().setBackendConfiguration(config())); // init circuit breaker instance JsonObject cbOptions = config().getJsonObject("circuit-breaker") != null ? config().getJsonObject("circuit-breaker") : new JsonObject(); circuitBreaker = CircuitBreaker.create(cbOptions.getString("name", "circuit-breaker"), vertx, new CircuitBreakerOptions() .setMaxFailures(cbOptions.getInteger("max-failures", 5)) .setTimeout(cbOptions.getLong("timeout", 10000L)) .setFallbackOnFailure(true) .setResetTimeout(cbOptions.getLong("reset-timeout", 30000L)) ); }
Example #3
Source File: HttpEndpointTest.java From vertx-service-discovery with Apache License 2.0 | 6 votes |
@Before public void setUp() { vertx = Vertx.vertx(); discovery = new DiscoveryImpl(vertx, new ServiceDiscoveryOptions()); Router router = Router.router(vertx); router.get("/foo").handler(ctxt -> { ctxt.response().end("hello"); }); AtomicBoolean done = new AtomicBoolean(); vertx.createHttpServer().requestHandler(router).listen(8080, ar -> { done.set(ar.succeeded()); }); await().untilAtomic(done, is(true)); }
Example #4
Source File: SchemaRegistrar.java From vertx-graphql-service-discovery with Apache License 2.0 | 6 votes |
/** * Registers a schema definition created by the * {@link GraphQLService}. * <p> * The provided registration is cloned, completed with publisher-related information, registered and then returned. * * @param partialRegistration the partially completed schema registration * @param options the service discovery options to add * @param publishedHandler the event handler to invoke on schema published events * @param unpublishedHandler the event handler to invoke on schema unpublished events * @return the completed schema registration */ protected SchemaRegistration register( SchemaRegistration partialRegistration, ServiceDiscoveryOptions options, SchemaPublishedHandler<SchemaRegistration> publishedHandler, SchemaUnpublishedHandler<SchemaRegistration> unpublishedHandler) { // First start listening to schema events. registerSchemaEventConsumers(options, publishedHandler, unpublishedHandler); // Then register service consumer created from schema definition, if it was not registered yet. MessageConsumer<JsonObject> serviceConsumer = registerSchemaServiceConsumer( partialRegistration.getRecord(), partialRegistration.getSchemaDefinition()); // Complete the schema registration SchemaRegistration fullRegistration = SchemaRegistration.create(partialRegistration.getDiscovery(), options, partialRegistration.getRecord(), partialRegistration.getSchemaDefinition(), serviceConsumer); return super.register(options.getName(), fullRegistration); }
Example #5
Source File: SchemaPublisherTest.java From vertx-graphql-service-discovery with Apache License 2.0 | 6 votes |
@Test public void should_Return_Failure_When_Schema_Definition_Not_Provided(TestContext context) { Async async = context.async(4); schemaPublisher.publish(new ServiceDiscoveryOptions(), null, rh -> { assertFalse(rh.succeeded()); async.countDown(); }); schemaPublisher.publish(new ServiceDiscoveryOptions(), null, null, rh -> { assertFalse(rh.succeeded()); async.countDown(); }); schemaPublisher.publishAll(new ServiceDiscoveryOptions(), rh -> { assertFalse(rh.succeeded()); async.countDown(); }); GraphQLSchema[] schemas = null; schemaPublisher.publishAll(new ServiceDiscoveryOptions(), rh -> { assertFalse(rh.succeeded()); async.countDown(); }, schemas); async.awaitSuccess(); }
Example #6
Source File: SchemaRegistrationTest.java From vertx-graphql-service-discovery with Apache License 2.0 | 6 votes |
@Before public void setUp() { vertx = Vertx.vertx(); options = new ServiceDiscoveryOptions().setName("theDiscovery") .setAnnounceAddress("theAnnounceAddress").setUsageAddress("theUsageAddress"); discovery = ServiceDiscovery.create(vertx, options); record = new Record() .setName("theRecord") .setType(Queryable.SERVICE_TYPE) .setMetadata(new JsonObject().put("publisherId", "thePublisherId")) .setLocation(new JsonObject().put(Record.ENDPOINT, Queryable.ADDRESS_PREFIX + ".DroidQueries")) .setStatus(Status.UP); definition = SchemaDefinition.createInstance(droidsSchema, SchemaMetadata.create(new JsonObject().put("publisherId", "thePublisherId"))); consumer = ProxyHelper.registerService(Queryable.class, vertx, definition, Queryable.ADDRESS_PREFIX + ".DroidQueries"); }
Example #7
Source File: AbstractRegistrar.java From vertx-graphql-service-discovery with Apache License 2.0 | 6 votes |
/** * Gets an existing managed repository, or creates it. * * @param options the service discovery options * @param closeHandler the action to perform when {@code discovery.close()} is called * @return the managed service discovery */ protected ServiceDiscovery getOrCreateDiscovery(ServiceDiscoveryOptions options, Action<Void> closeHandler) { if (options.getName() == null) { options.setName(getNodeId(vertx)); } String discoveryName = options.getName(); if (serviceDiscoveries.containsKey(discoveryName)) { return serviceDiscoveries.get(discoveryName); } ServiceDiscovery discovery = ServiceDiscovery.create(vertx, options); if (closeHandler != null) { discovery = ManagedServiceDiscovery.of(discovery, closeHandler); serviceDiscoveries.put(discoveryName, (ManagedServiceDiscovery) discovery); } return discovery; }
Example #8
Source File: KubernetesServerTest.java From vertx-service-discovery with Apache License 2.0 | 6 votes |
/** * Reproduce issue https://github.com/vert-x3/vertx-service-discovery/issues/96. */ @Test public void testWatchWithDeletion() { AtomicBoolean done = new AtomicBoolean(); ServiceDiscovery discovery = ServiceDiscovery.create(vertx, new ServiceDiscoveryOptions().setAutoRegistrationOfImporters(false)); discovery.registerServiceImporter(new KubernetesServiceImporter(), config().copy().put("namespace", "issue96"), ar -> done.set(ar.succeeded())); await().untilAtomic(done, is(true)); await().until(() -> { List<Record> records = getRecordsBlocking(discovery); try { assertThatListDoesNotContain(records, "hello-minikube"); return true; } catch (Throwable e) { return false; } }); }
Example #9
Source File: KubernetesServerTest.java From vertx-service-discovery with Apache License 2.0 | 6 votes |
@Test public void testInitialRetrieval(TestContext tc) { Async async = tc.async(); ServiceDiscovery discovery = ServiceDiscovery.create(vertx, new ServiceDiscoveryOptions().setAutoRegistrationOfImporters(false)); discovery.registerServiceImporter(new KubernetesServiceImporter(), config().copy().put("namespace", "default"), ar -> { if (ar.failed()) { tc.fail(ar.cause()); } else { discovery.getRecords(s -> true, res -> { if (res.failed()) { tc.fail(res.cause()); } else { tc.assertEquals(2, res.result().size()); async.complete(); } }); } }); }
Example #10
Source File: KubernetesServerTest.java From vertx-service-discovery with Apache License 2.0 | 6 votes |
@Test public void testWatch() { AtomicBoolean done = new AtomicBoolean(); ServiceDiscovery discovery = ServiceDiscovery.create(vertx, new ServiceDiscoveryOptions().setAutoRegistrationOfImporters(false)); discovery.registerServiceImporter(new KubernetesServiceImporter(), config().copy().put("namespace", "default"), ar -> done.set(ar.succeeded())); await().untilAtomic(done, is(true)); await().until(() -> { List<Record> records = getRecordsBlocking(discovery); try { assertThatListContains(records, "service3"); assertThatListDoesNotContain(records, "my-service"); assertThatListContains(records, "my-http-service"); return true; } catch (Throwable e) { return false; } }); }
Example #11
Source File: SchemaConsumerTest.java From vertx-graphql-service-discovery with Apache License 2.0 | 6 votes |
@Test public void should_Stop_Repository_Listening_And_Remove_Registration() { DiscoveryRegistration registration = SchemaConsumer .startDiscovery(new ServiceDiscoveryOptions().setName("the-discovery"), testClass); DiscoveryRegistration sameRegistration = SchemaConsumer .startDiscovery(new ServiceDiscoveryOptions().setName("the-discovery"), testClass); assertNotNull(registration); assertEquals(registration, sameRegistration); assertEquals(1, testClass.managedDiscoveries().size()); SchemaConsumer.stopDiscovery(registration, testClass); assertEquals(0, testClass.managedDiscoveries().size()); DiscoveryRegistration registration2 = SchemaConsumer .startDiscovery(new ServiceDiscoveryOptions().setName("the-discovery"), testClass); assertNotNull(registration); assertEquals(1, testClass.managedDiscoveries().size()); SchemaConsumer.stopDiscovery(registration2.getDiscoveryOptions(), testClass); assertEquals(0, testClass.managedDiscoveries().size()); }
Example #12
Source File: AuditVerticleTest.java From vertx-microservices-workshop with Apache License 2.0 | 6 votes |
@Before public void setUp(TestContext tc) { Async async = tc.async(); vertx = Vertx.vertx(); Record record = MessageSource.createRecord("portfolio-events", "portfolio", JsonObject .class); ServiceDiscovery.create(vertx, new ServiceDiscoveryOptions() .setBackendConfiguration(new JsonObject().put("backend-name", DefaultServiceDiscoveryBackend.class.getName()))) .publish(record, r -> { if (r.failed()) { r.cause().printStackTrace(); tc.fail(r.cause()); } vertx.deployVerticle(AuditVerticle.class.getName(), new DeploymentOptions().setConfig(CONFIGURATION), tc.asyncAssertSuccess(s -> async.complete())); }); }
Example #13
Source File: ManagedServiceDiscoveryTest.java From vertx-graphql-service-discovery with Apache License 2.0 | 5 votes |
@Test public void should_Not_Wrap_An_Already_Managed_Discovery() { Action<Void> closeAction = () -> null; ServiceDiscovery discovery = ManagedServiceDiscovery.of( ServiceDiscovery.create(vertx, new ServiceDiscoveryOptions().setName("discovery2")), closeAction); ServiceDiscovery discovery2 = ManagedServiceDiscovery.of(discovery, closeAction); assertEquals(discovery, discovery2); }
Example #14
Source File: SchemaPublisher.java From vertx-graphql-service-discovery with Apache License 2.0 | 5 votes |
/** * Publishes the provided schema definitions to the specified service discovery. * <p> * Upon success a list of {@link SchemaRegistration}s is returned in the result handler. * * @param options the service discovery options * @param resultHandler the result handler * @param schemas the GraphQL schema's to publish */ default void publishAll(ServiceDiscoveryOptions options, Handler<AsyncResult<List<SchemaRegistration>>> resultHandler, GraphQLSchema... schemas) { Objects.requireNonNull(resultHandler, "Publication result handler cannot be null"); if (schemas == null || schemas.length == 0) { resultHandler.handle(Future.failedFuture("Nothing to publish. No schema definitions provided")); return; } List<Future> futures = new ArrayList<>(); Arrays.asList(schemas).forEach(schema -> publish(options, schema, rh -> futures.add( rh.succeeded() ? Future.succeededFuture(rh.result()) : Future.failedFuture(rh.cause())))); CompositeFuture.all(futures).setHandler(rh -> { if (rh.failed()) { resultHandler.handle(Future.failedFuture(rh.cause())); return; } CompositeFuture composite = rh.result(); List<SchemaRegistration> published = composite.list(); if (published.size() != schemas.length) { List<Throwable> errors = rh.result().<Future<Void>>list().stream() .filter(Future::failed) .map(Future::cause) .collect(Collectors.toList()); resultHandler.handle(Future.failedFuture(new PartialPublishException(errors))); } else { resultHandler.handle(Future.succeededFuture(published)); } }); }
Example #15
Source File: SchemaRegistration.java From vertx-graphql-service-discovery with Apache License 2.0 | 5 votes |
private SchemaRegistration(ServiceDiscovery discovery, ServiceDiscoveryOptions options, Record record, SchemaDefinition schemaDefinition, MessageConsumer<JsonObject> serviceConsumer) { super(discovery, options); Objects.requireNonNull(record, "Service record cannot be null"); Objects.requireNonNull(schemaDefinition, "Schema definition cannot be null"); this.record = record; this.schemaDefinition = schemaDefinition; this.serviceConsumer = serviceConsumer; }
Example #16
Source File: SchemaConsumerTest.java From vertx-graphql-service-discovery with Apache License 2.0 | 5 votes |
@Test public void should_Execute_Query_On_Consumer_Instance(TestContext context) { Async async = context.async(); vertx.runOnContext(ctx -> { SchemaConsumer.startDiscovery(new ServiceDiscoveryOptions().setName("the-discovery"), testClass); testClass.executeQuery("the-discovery", "DroidQueries", DROIDS_QUERY, rh -> { context.assertFalse(rh.succeeded()); // Not yet published GraphQLService.publish(vertx, testClass.getDiscovery("the-discovery").get(), droidsSchema, null, null, rh2 -> testClass.executeQuery("the-discovery", "DroidQueries", DROIDS_QUERY, rh3 -> { context.assertNotNull(rh3.result()); QueryResult queryResult = rh3.result(); context.assertTrue(queryResult.isSucceeded()); context.assertNotNull(queryResult.getData()); context.assertNotNull(queryResult.getErrors()); context.assertTrue(queryResult.getErrors().isEmpty()); JsonObject data = queryResult.getData(); context.assertNotNull(data.getJsonObject("droidHero")); context.assertEquals("Droid", data.getJsonObject("droidHero").getString("__typename")); context.assertEquals("R2-D2", data.getJsonObject("droidHero").getString("name")); SchemaConsumer.close(testClass); assertEquals(0, testClass.managedDiscoveries().size()); async.complete(); }) ); }); }); async.awaitSuccess(); }
Example #17
Source File: SchemaRegistrationTest.java From vertx-graphql-service-discovery with Apache License 2.0 | 5 votes |
@Test public void should_Implement_Proper_Reference_Equality() { SchemaRegistration registration1 = SchemaRegistration.create(discovery, options, record, definition, null); assertEquals(registration1, registration1); assertNotEquals(registration1, "test"); SchemaRegistration registration2 = SchemaRegistration.create(discovery, new ServiceDiscoveryOptions(options).setName("theOtherDiscovery"), record, definition, null); assertNotEquals(registration1, registration2); SchemaRegistration registration3 = SchemaRegistration.create(discovery, new ServiceDiscoveryOptions(options).setName("theOtherDiscovery"), record, definition, consumer); assertNotEquals(registration2, registration3); SchemaDefinition starwarsSchema = SchemaDefinition .createInstance(starWarsSchema, SchemaMetadata.create()); SchemaRegistration registration4 = SchemaRegistration.create(discovery, options, record, starwarsSchema, null); assertNotEquals(registration1, registration4); SchemaRegistration registration5 = SchemaRegistration. create(discovery, options, new Record(record).setName("theOtherRecord"), starwarsSchema, null); assertNotEquals(registration4, registration5); SchemaRegistration registration6 = SchemaRegistration. create(discovery, options, new Record(record).setStatus(Status.DOWN), starwarsSchema, null); assertEquals(registration4, registration6); }
Example #18
Source File: GraphQLServiceImplTest.java From vertx-graphql-service-discovery with Apache License 2.0 | 5 votes |
@Before public void setUp() { vertx = Vertx.vertx(); discovery = ServiceDiscovery.create(vertx, new ServiceDiscoveryOptions().setName("test-discovery")); config = new JsonObject().put("deliveryOptions", new JsonObject().put("timeout", 1000).put("codecName", "theCodecName")); record = new Record().setLocation(new JsonObject().put(Record.ENDPOINT, "theEndpoint")); graphQLService = new io.engagingspaces.graphql.servicediscovery.service.impl.GraphQLServiceImpl(); }
Example #19
Source File: IgniteDiscoveryImplClusteredTest.java From vertx-ignite with Apache License 2.0 | 5 votes |
@Before public void setUp() { VertxOptions options = new VertxOptions() .setClusterManager(new IgniteClusterManager()); Vertx.clusteredVertx(options, ar -> { vertx = ar.result(); }); await().until(() -> vertx != null); discovery = new DiscoveryImpl(vertx, new ServiceDiscoveryOptions()); }
Example #20
Source File: InfinispanDiscoveryImplClusteredTest.java From vertx-infinispan with Apache License 2.0 | 5 votes |
@Before public void setUp() { Random random = new Random(); System.setProperty("vertx.infinispan.test.auth.token", new BigInteger(128, random).toString(32)); VertxOptions options = new VertxOptions() .setClusterManager(new InfinispanClusterManager()); Vertx.clusteredVertx(options, ar -> { vertx = ar.result(); }); await().until(() -> vertx != null); discovery = new DiscoveryImpl(vertx, new ServiceDiscoveryOptions()); }
Example #21
Source File: HazelcastDiscoveryImplClusteredTest.java From vertx-hazelcast with Apache License 2.0 | 5 votes |
@Before public void setUp() { Random random = new Random(); System.setProperty("vertx.hazelcast.test.group.name", new BigInteger(128, random).toString(32)); VertxOptions options = new VertxOptions() .setClusterManager(new HazelcastClusterManager()); Vertx.clusteredVertx(options, ar -> { vertx = ar.result(); }); await().until(() -> vertx != null); discovery = new DiscoveryImpl(vertx, new ServiceDiscoveryOptions()); }
Example #22
Source File: SchemaRegistrarTest.java From vertx-graphql-service-discovery with Apache License 2.0 | 5 votes |
@Before public void setUp() { vertx = rule.vertx(); options = new ServiceDiscoveryOptions().setName("theDiscovery") .setAnnounceAddress("announceAddress").setUsageAddress("usageAddress"); schemaRegistrar = SchemaRegistrar.create(vertx); schemaPublisher = new TestClass(schemaRegistrar); }
Example #23
Source File: ManagedServiceDiscoveryTest.java From vertx-graphql-service-discovery with Apache License 2.0 | 5 votes |
@Test public void should_Invoke_Close_Action_When_Closing_Managed_Discovery(TestContext context) { Async async = context.async(); AtomicInteger check = new AtomicInteger(1); final Action<Void> closeAction = () -> { assertEquals(0, check.decrementAndGet()); async.complete(); return null; }; ServiceDiscovery discovery = ManagedServiceDiscovery.of( ServiceDiscovery.create(vertx, new ServiceDiscoveryOptions().setName("discovery2")), closeAction); discovery.close(); }
Example #24
Source File: SchemaPublisher.java From vertx-graphql-service-discovery with Apache License 2.0 | 5 votes |
/** * Publishes the schema definition and metadata to the service discovery indicated by * the provided schema publisher options. * * @param options the service discovery options * @param schema the GraphQL schema to publish * @param metadata the metadata to pass to the published discovery record * @param resultHandler the result handler */ default void publish(ServiceDiscoveryOptions options, GraphQLSchema schema, SchemaMetadata metadata, Handler<AsyncResult<SchemaRegistration>> resultHandler) { if (schema == null) { resultHandler.handle(Future.failedFuture("Nothing to publish. No schema definition provided")); return; } Objects.requireNonNull(schema, "GraphQL schema cannot be null"); Objects.requireNonNull(options, "Schema discovery options cannot be null"); Objects.requireNonNull(resultHandler, "Publication result handler cannot be null"); SchemaDefinition definition = SchemaDefinition.createInstance(schema, metadata); if (schemaRegistrar().findRegistration(options.getName(), definition.schemaName()).isPresent()) { resultHandler.handle(Future.failedFuture("Schema '" + definition.schemaName() + "' was already published to: " + options.getName())); return; } metadata.put("publisherId", schemaRegistrar().getPublisherId()); ServiceDiscovery discovery = schemaRegistrar().getOrCreateDiscovery(options); GraphQLService.publish(schemaRegistrar().getVertx(), discovery, definition, rh -> { if (rh.succeeded()) { SchemaRegistration registration = schemaRegistrar().register(rh.result(), options, this, this); resultHandler.handle(Future.succeededFuture(registration)); } else { resultHandler.handle(Future.failedFuture(rh.cause())); } }); }
Example #25
Source File: AbstractRegistrationTest.java From vertx-graphql-service-discovery with Apache License 2.0 | 5 votes |
@Test public void should_Implement_Proper_Reference_Equality() { TestRegistration registration1 = new TestRegistration(discovery, options); assertEquals(registration1, registration1); assertNotEquals(registration1, "test"); TestRegistration registration2 = new TestRegistration(discovery, options); assertEquals(registration1, registration2); assertEquals(registration1.getDiscovery(), registration2.getDiscovery()); assertEquals(registration1.getDiscoveryOptions().getName(), registration2.getDiscoveryOptions().getName()); assertNotEquals(registration1.getDiscoveryOptions(), registration2.getDiscoveryOptions()); // returns a copy TestRegistration registration3 = new TestRegistration(discovery, new ServiceDiscoveryOptions(options)); assertEquals(registration1, registration3); TestRegistration registration4 = new TestRegistration(discovery, new ServiceDiscoveryOptions(options).setName("theOtherDiscovery")); assertNotEquals(registration1, registration4); TestRegistration registration5 = new TestRegistration(ServiceDiscovery.create(vertx), options); assertNotEquals(registration1, registration5); // would be illegal as well }
Example #26
Source File: SchemaConsumerTest.java From vertx-graphql-service-discovery with Apache License 2.0 | 5 votes |
@Test public void should_Create_Service_Discovery_And_Return_Registration() { DiscoveryRegistration defaultRegistration = SchemaConsumer.startDiscovery(testClass); DiscoveryRegistration registration = SchemaConsumer .startDiscovery(new ServiceDiscoveryOptions().setName("the-discovery"), testClass); assertNotNull(defaultRegistration); assertNotNull(registration); assertNotNull(registration.getDiscovery()); assertNotNull(registration.getDiscoveryOptions()); assertEquals(2, testClass.managedDiscoveries().size()); }
Example #27
Source File: AbstractRegistrationTest.java From vertx-graphql-service-discovery with Apache License 2.0 | 5 votes |
@Before public void setUp() { vertx = Vertx.vertx(); options = new ServiceDiscoveryOptions().setName("theDiscovery") .setAnnounceAddress("theAnnounceAddress").setUsageAddress("theUsageAddress"); discovery = ServiceDiscovery.create(vertx, options); }
Example #28
Source File: AbstractRegistrarTest.java From vertx-graphql-service-discovery with Apache License 2.0 | 5 votes |
@Test public void should_Manage_Service_Discovery_Creation_And_Invoke_Close_Handler(TestContext context) { Async async = context.async(2); vertx.runOnContext(ctx -> { ServiceDiscovery serviceDiscoveryDefault = abstractRegistrar .getOrCreateDiscovery(new ServiceDiscoveryOptions(), null); context.assertNotNull(serviceDiscoveryDefault); ServiceDiscovery serviceDiscovery1 = abstractRegistrar.getOrCreateDiscovery(options, () -> { abstractRegistrar.closeServiceDiscovery(options.getName()); async.countDown(); return null; }); context.assertTrue(serviceDiscovery1 instanceof ManagedServiceDiscovery); context.assertEquals(1, abstractRegistrar.serviceDiscoveryNames().size()); serviceDiscoveryDefault.close(); context.assertEquals(1, abstractRegistrar.serviceDiscoveryNames().size()); ServiceDiscovery serviceDiscovery2 = abstractRegistrar.getOrCreateDiscovery(options, null); context.assertEquals(serviceDiscovery1, serviceDiscovery2); serviceDiscovery1.close(); context.assertEquals(1, async.count()); context.assertEquals(0, abstractRegistrar.serviceDiscoveryNames().size()); async.countDown(); }); async.awaitSuccess(); }
Example #29
Source File: AbstractRegistrarTest.java From vertx-graphql-service-discovery with Apache License 2.0 | 5 votes |
@Before public void setUp() { vertx = Vertx.vertx(); abstractRegistrar = new TestClass(vertx); options = new ServiceDiscoveryOptions().setName("theDiscovery") .setAnnounceAddress("theAnnounceAddress").setUsageAddress("theUsageAddress"); }
Example #30
Source File: GraphQLClientTest.java From vertx-graphql-service-discovery with Apache License 2.0 | 5 votes |
@Before public void setUp(TestContext context) { vertx = Vertx.vertx(); vertx.exceptionHandler(context.exceptionHandler()); ServiceDiscovery serviceDiscovery = ServiceDiscovery.create(vertx, new ServiceDiscoveryOptions().setName("my-schema-discovery")); Handler<SchemaRegistration> schemaHandler = schema -> { record = schema.getRecord(); discovery = schema.getDiscovery(); assertEquals(serviceDiscovery, discovery); }; GraphQLService.publish(vertx, serviceDiscovery, droidsSchema, null, null, context.asyncAssertSuccess(schemaHandler)); }