Skip to content

Commit

Permalink
common package builds, tests succeed with 2.0.0_beta1, however apache…
Browse files Browse the repository at this point in the history
… HC and android don't yet build.

Mostly the changes are related to test framework changes and some api changes on the ES side.
  • Loading branch information
andrejserafim committed Sep 17, 2015
1 parent 976258f commit c85fcef
Show file tree
Hide file tree
Showing 70 changed files with 171 additions and 258 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.searchbox.indices;

import com.google.gson.Gson;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;
import org.junit.Test;

import static junit.framework.Assert.assertEquals;
Expand All @@ -24,7 +24,7 @@ public void createIndexWithoutSettings() {

@Test
public void equalsReturnsTrueForSameSettings() {
final ImmutableSettings.Builder indexerSettings = ImmutableSettings.settingsBuilder();
final Settings.Builder indexerSettings = Settings.settingsBuilder();
indexerSettings.put("analysis.analyzer.events.type", "custom");
indexerSettings.put("analysis.analyzer.events.tokenizer", "standard");
indexerSettings.put("analysis.analyzer.events.filter", "snowball, standard, lowercase");
Expand All @@ -36,7 +36,7 @@ public void equalsReturnsTrueForSameSettings() {

@Test
public void equalsReturnsFalseForDifferentSettings() {
final ImmutableSettings.Builder indexerSettings = ImmutableSettings.settingsBuilder();
final Settings.Builder indexerSettings = Settings.settingsBuilder();
indexerSettings.put("analysis.analyzer.events.type", "custom");
indexerSettings.put("analysis.analyzer.events.tokenizer", "standard");
CreateIndex createIndex1 = new CreateIndex.Builder("tweet").settings(indexerSettings.build().getAsMap()).build();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.searchbox.indices.aliases;

import com.google.gson.Gson;
import org.elasticsearch.common.collect.ImmutableMap;
import org.elasticsearch.common.collect.MapBuilder;
import org.junit.Test;

import java.util.Map;
Expand All @@ -13,11 +13,11 @@
*/
public class AddAliasMappingTest {

public static final Map<String, Object> USER_FILTER_JSON = ImmutableMap.<String, Object>builder()
.put("term", ImmutableMap.<String, String>builder()
public static final Map<String, Object> USER_FILTER_JSON = new MapBuilder<String, Object>()
.put("term", MapBuilder.newMapBuilder()
.put("user", "kimchy")
.build())
.build();
.immutableMap())
.immutableMap();

@Test
public void testBasicGetDataForJson() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.searchbox.indices.aliases;

import org.elasticsearch.common.collect.ImmutableMap;
import org.elasticsearch.common.collect.MapBuilder;
import org.junit.Test;

import java.util.Map;
Expand All @@ -13,11 +13,11 @@
*/
public class ModifyAliasesTest {

Map<String, Object> userFilter = ImmutableMap.<String, Object>builder()
.put("term", ImmutableMap.<String, String>builder()
Map<String, Object> userFilter = new MapBuilder<String, Object>()
.put("term", MapBuilder.newMapBuilder()
.put("user", "kimchy")
.build())
.build();
.immutableMap())
.immutableMap();
AliasMapping addMapping = new AddAliasMapping.Builder("t_add_index", "t_add_alias").setFilter(userFilter).build();
AliasMapping removeMapping = new RemoveAliasMapping.Builder("t_remove_index", "t_remove_alias").addRouting("1").build();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.searchbox.indices.aliases;

import com.google.gson.Gson;
import org.elasticsearch.common.collect.ImmutableMap;
import org.elasticsearch.common.collect.MapBuilder;
import org.junit.Test;

import java.util.Map;
Expand All @@ -13,11 +13,11 @@
*/
public class RemoveAliasMappingTest {

public static final Map<String, Object> USER_FILTER_JSON = ImmutableMap.<String, Object>builder()
.put("term", ImmutableMap.<String, String>builder()
public static final Map<String, Object> USER_FILTER_JSON = new MapBuilder<String, Object>()
.put("term", MapBuilder.newMapBuilder()
.put("user", "kimchy")
.build())
.build();
.immutableMap())
.immutableMap();

@Test
public void testBasicGetDataForJson() {
Expand Down
6 changes: 3 additions & 3 deletions jest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,17 @@ String settings = "\"settings\" : {\n" +
" \"number_of_replicas\" : 1\n" +
" }\n";

client.execute(new CreateIndex.Builder("articles").settings(ImmutableSettings.builder().loadFromSource(settings).build().getAsMap()).build());
client.execute(new CreateIndex.Builder("articles").settings(Settings.builder().loadFromSource(settings).build().getAsMap()).build());
```

* using the `SettingsBuilder` helper class from Elasticsearch:

``` java
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;
.
.

ImmutableSettings.Builder settingsBuilder = ImmutableSettings.settingsBuilder();
Settings.Builder settingsBuilder = Settings.settingsBuilder();
settings.put("number_of_shards",5);
settings.put("number_of_replicas",1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import io.searchbox.cluster.Health;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.pool.PoolStats;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.node.internal.InternalNode;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.elasticsearch.node.Node;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.junit.Test;

import java.io.IOException;
Expand All @@ -19,8 +19,8 @@
/**
* @author cihat keser
*/
@ElasticsearchIntegrationTest.ClusterScope(scope = ElasticsearchIntegrationTest.Scope.TEST, numDataNodes = 0)
public class JestClientFactoryIntegrationTest extends ElasticsearchIntegrationTest {
@ClusterScope(scope = Scope.TEST, numDataNodes = 0)
public class JestClientFactoryIntegrationTest extends ESIntegTestCase {

JestClientFactory factory = new JestClientFactory();

Expand Down Expand Up @@ -142,7 +142,7 @@ public void testNoIdleConnectionReaper() throws Exception {
/**
* Forgive me these sins. This is the only way I can think of to determine the *actual* size of the connection pool
* without wrapping large quantities of the underlying client.
* <p/>
* <p>
* This whole method is cheating and full of bad examples. Don't copy this. You've been warned.
*/
private int getPoolSize(JestHttpClient client) throws Exception {
Expand All @@ -166,10 +166,9 @@ private int getPoolSize(JestHttpClient client) throws Exception {

@Override
protected Settings nodeSettings(int nodeOrdinal) {
return ImmutableSettings.settingsBuilder()
return Settings.settingsBuilder()
.put(super.nodeSettings(nodeOrdinal))
.put(RestController.HTTP_JSON_ENABLE, true)
.put(InternalNode.HTTP_ENABLED, true)
.put(Node.HTTP_ENABLED, true)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@
import io.searchbox.client.config.HttpClientConfig;
import io.searchbox.indices.Status;
import org.apache.http.HttpHost;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.node.internal.InternalNode;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.elasticsearch.node.Node;
import org.elasticsearch.test.ESIntegTestCase;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -33,8 +31,8 @@
/**
* @author cihat keser
*/
@ElasticsearchIntegrationTest.ClusterScope(scope = ElasticsearchIntegrationTest.Scope.TEST, numDataNodes = 0)
public class JestHttpClientConfiguredProxyIntegrationTest extends ElasticsearchIntegrationTest {
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0)
public class JestHttpClientConfiguredProxyIntegrationTest extends ESIntegTestCase {

private static final int PROXY_PORT = 8770;

Expand Down Expand Up @@ -145,10 +143,9 @@ public void failed(Exception ex) {

@Override
protected Settings nodeSettings(int nodeOrdinal) {
return ImmutableSettings.settingsBuilder()
return Settings.settingsBuilder()
.put(super.nodeSettings(nodeOrdinal))
.put(RestController.HTTP_JSON_ENABLE, true)
.put(InternalNode.HTTP_ENABLED, true)
.put(Node.HTTP_ENABLED, true)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@
import io.searchbox.client.JestResultHandler;
import io.searchbox.client.config.HttpClientConfig;
import io.searchbox.indices.Status;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.node.internal.InternalNode;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.elasticsearch.node.Node;
import org.elasticsearch.test.ESIntegTestCase;
import org.junit.*;
import org.littleshoot.proxy.HttpFilters;
import org.littleshoot.proxy.HttpFiltersAdapter;
Expand All @@ -31,8 +29,8 @@
/**
* @author cihat keser
*/
@ElasticsearchIntegrationTest.ClusterScope(scope = ElasticsearchIntegrationTest.Scope.TEST, numDataNodes = 0)
public class JestHttpClientSystemWideProxyIntegrationTest extends ElasticsearchIntegrationTest {
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0)
public class JestHttpClientSystemWideProxyIntegrationTest extends ESIntegTestCase {

private static final int PROXY_PORT = 8790;

Expand Down Expand Up @@ -164,10 +162,9 @@ public void failed(Exception ex) {

@Override
protected Settings nodeSettings(int nodeOrdinal) {
return ImmutableSettings.settingsBuilder()
return Settings.settingsBuilder()
.put(super.nodeSettings(nodeOrdinal))
.put(RestController.HTTP_JSON_ENABLE, true)
.put(InternalNode.HTTP_ENABLED, true)
.put(Node.HTTP_ENABLED, true)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import io.searchbox.client.JestResult;
import io.searchbox.common.AbstractIntegrationTest;
import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.elasticsearch.test.ESIntegTestCase;
import org.junit.Test;

import java.io.IOException;
Expand All @@ -12,7 +12,7 @@
/**
* @author cihat keser
*/
@ElasticsearchIntegrationTest.ClusterScope(scope = ElasticsearchIntegrationTest.Scope.SUITE, numDataNodes = 1)
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.SUITE, numDataNodes = 1)
public class GetSettingsIntegrationTest extends AbstractIntegrationTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import io.searchbox.client.JestResult;
import io.searchbox.common.AbstractIntegrationTest;
import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.elasticsearch.test.ESIntegTestCase;
import org.junit.Test;

import static org.hamcrest.core.AnyOf.anyOf;
Expand All @@ -11,7 +11,7 @@
/**
* @author Neil Gentleman
*/
@ElasticsearchIntegrationTest.ClusterScope(scope = ElasticsearchIntegrationTest.Scope.SUITE, numDataNodes = 1)
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.SUITE, numDataNodes = 1)
public class HealthIntegrationTest extends AbstractIntegrationTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

import io.searchbox.client.JestResult;
import io.searchbox.common.AbstractIntegrationTest;
import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.elasticsearch.test.ESIntegTestCase;
import org.junit.Test;

import java.io.IOException;

/**
* @author cihat keser
*/
@ElasticsearchIntegrationTest.ClusterScope(scope = ElasticsearchIntegrationTest.Scope.SUITE, numDataNodes = 2)
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.SUITE, numDataNodes = 2)
public class NodesHotThreadsIntegrationTest extends AbstractIntegrationTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

import io.searchbox.client.JestResult;
import io.searchbox.common.AbstractIntegrationTest;
import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.elasticsearch.test.ESIntegTestCase;
import org.junit.Test;

import java.io.IOException;

/**
* @author Dogukan Sonmez
*/
@ElasticsearchIntegrationTest.ClusterScope(scope = ElasticsearchIntegrationTest.Scope.SUITE, numDataNodes = 1)
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.SUITE, numDataNodes = 1)
public class NodesInfoIntegrationTest extends AbstractIntegrationTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.google.gson.JsonObject;
import io.searchbox.client.JestResult;
import io.searchbox.common.AbstractIntegrationTest;
import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.elasticsearch.test.ESIntegTestCase;
import org.junit.Test;
import org.mockito.internal.matchers.GreaterOrEqual;

Expand All @@ -15,7 +15,7 @@
/**
* @author cihat keser
*/
@ElasticsearchIntegrationTest.ClusterScope(scope = ElasticsearchIntegrationTest.Scope.SUITE, numDataNodes = 2)
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.SUITE, numDataNodes = 2)
public class NodesStatsIntegrationTest extends AbstractIntegrationTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
import com.google.gson.JsonObject;
import io.searchbox.client.JestResult;
import io.searchbox.common.AbstractIntegrationTest;
import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.elasticsearch.test.ESIntegTestCase;
import org.junit.Test;

import java.io.IOException;

/**
* @author cihat keser
*/
@ElasticsearchIntegrationTest.ClusterScope(scope = ElasticsearchIntegrationTest.Scope.SUITE, numDataNodes = 1)
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.SUITE, numDataNodes = 1)
public class StateIntegrationTest extends AbstractIntegrationTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import io.searchbox.client.JestResult;
import io.searchbox.common.AbstractIntegrationTest;
import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.elasticsearch.test.ESIntegTestCase;
import org.junit.Test;

import java.io.IOException;
Expand All @@ -12,7 +12,7 @@
/**
* @author cihat keser
*/
@ElasticsearchIntegrationTest.ClusterScope(scope = ElasticsearchIntegrationTest.Scope.TEST, numDataNodes = 1)
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 1)
public class UpdateSettingsIntegrationTest extends AbstractIntegrationTest {

@Test
Expand Down
Loading

0 comments on commit c85fcef

Please sign in to comment.