|
| 1 | +/* |
| 2 | + * Licensed to Elasticsearch under one or more contributor |
| 3 | + * license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright |
| 5 | + * ownership. Elasticsearch licenses this file to you under |
| 6 | + * the Apache License, Version 2.0 (the "License"); you may |
| 7 | + * not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +package org.elasticsearch.river; |
| 21 | + |
| 22 | +import com.google.common.base.Predicate; |
| 23 | +import org.elasticsearch.action.get.GetResponse; |
| 24 | +import org.elasticsearch.action.index.IndexResponse; |
| 25 | +import org.elasticsearch.river.dummy.DummyRiverModule; |
| 26 | +import org.elasticsearch.test.ElasticsearchIntegrationTest; |
| 27 | +import org.junit.Test; |
| 28 | + |
| 29 | +import java.util.concurrent.TimeUnit; |
| 30 | + |
| 31 | +import static org.elasticsearch.test.ElasticsearchIntegrationTest.*; |
| 32 | +import static org.hamcrest.Matchers.equalTo; |
| 33 | + |
| 34 | +@ClusterScope(scope = Scope.TEST) |
| 35 | +public class RiverTests extends ElasticsearchIntegrationTest { |
| 36 | + |
| 37 | + @Test |
| 38 | + public void testRiverStart() throws Exception { |
| 39 | + final String riverName = "dummy-river-test"; |
| 40 | + logger.info("--> creating river [{}]", riverName); |
| 41 | + IndexResponse indexResponse = client().prepareIndex(RiverIndexName.Conf.DEFAULT_INDEX_NAME, riverName, "_meta") |
| 42 | + .setSource("type", DummyRiverModule.class.getCanonicalName()).get(); |
| 43 | + assertThat(indexResponse.getVersion(), equalTo(1l)); |
| 44 | + |
| 45 | + logger.info("--> checking that river [{}] was created", riverName); |
| 46 | + assertThat(awaitBusy(new Predicate<Object>() { |
| 47 | + public boolean apply(Object obj) { |
| 48 | + GetResponse response = client().prepareGet(RiverIndexName.Conf.DEFAULT_INDEX_NAME, riverName, "_status").get(); |
| 49 | + return response.isExists(); |
| 50 | + } |
| 51 | + }, 5, TimeUnit.SECONDS), equalTo(true)); |
| 52 | + } |
| 53 | +} |
0 commit comments