|
| 1 | +/* |
| 2 | + * Copyright (c) 2014 Red Hat, Inc. and others |
| 3 | + * |
| 4 | + * Red Hat licenses this file to you under the Apache License, version 2.0 |
| 5 | + * (the "License"); you may not use this file except in compliance with the |
| 6 | + * License. You may obtain a copy of the License at: |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | + * License for the specific language governing permissions and limitations |
| 14 | + * under the License. |
| 15 | + * |
| 16 | + */ |
| 17 | + |
| 18 | +package io.vertx.config.kubernetes; |
| 19 | + |
| 20 | +import io.vertx.config.ConfigRetriever; |
| 21 | +import io.vertx.config.ConfigRetrieverOptions; |
| 22 | +import io.vertx.config.ConfigStoreOptions; |
| 23 | +import io.vertx.core.Vertx; |
| 24 | +import io.vertx.core.json.JsonObject; |
| 25 | +import io.vertx.ext.unit.Async; |
| 26 | +import io.vertx.ext.unit.TestContext; |
| 27 | +import io.vertx.ext.unit.junit.VertxUnitRunner; |
| 28 | +import org.junit.After; |
| 29 | +import org.junit.Before; |
| 30 | +import org.junit.Test; |
| 31 | +import org.junit.runner.RunWith; |
| 32 | + |
| 33 | +import java.net.MalformedURLException; |
| 34 | + |
| 35 | +/** |
| 36 | + * @author <a href="http://escoffier.me">Clement Escoffier</a> |
| 37 | + */ |
| 38 | +@RunWith(VertxUnitRunner.class) |
| 39 | +public class ConfigMapStoreOutsideOfKubernetesTest { |
| 40 | + |
| 41 | + protected Vertx vertx; |
| 42 | + private ConfigRetriever retriever; |
| 43 | + |
| 44 | + @Before |
| 45 | + public void setUp(TestContext tc) throws MalformedURLException { |
| 46 | + vertx = Vertx.vertx(); |
| 47 | + vertx.exceptionHandler(tc.exceptionHandler()); |
| 48 | + ConfigStoreOptions store = new ConfigStoreOptions() |
| 49 | + .setType("configmap") |
| 50 | + .setConfig(new JsonObject() |
| 51 | + .put("name", "my-config-map") |
| 52 | + .put("key", "my-app-json")); |
| 53 | + retriever = ConfigRetriever.create(vertx, new ConfigRetrieverOptions().addStore(store)); |
| 54 | + } |
| 55 | + |
| 56 | + @After |
| 57 | + public void tearDown() { |
| 58 | + vertx.close(); |
| 59 | + } |
| 60 | + |
| 61 | + @Test |
| 62 | + public void test(TestContext tc) { |
| 63 | + Async async = tc.async(); |
| 64 | + retriever.getConfig(ar -> { |
| 65 | + if (ar.failed()) { |
| 66 | + ar.cause().printStackTrace(); |
| 67 | + } |
| 68 | + tc.assertTrue(ar.succeeded()); |
| 69 | + tc.assertTrue(ar.result().isEmpty()); |
| 70 | + async.complete(); |
| 71 | + }); |
| 72 | + } |
| 73 | + |
| 74 | + |
| 75 | +} |
0 commit comments