Merge remote-tracking branch 'origin/feature/travis-ci' into feature/travis-ci
# Conflicts: # .travis.ymlpull/509/head
commit
06361b775d
@ -1,107 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<actions>
|
||||
<action>
|
||||
<actionName>test</actionName>
|
||||
<packagings>
|
||||
<packaging>*</packaging>
|
||||
</packagings>
|
||||
<goals>
|
||||
<goal>test</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<argLine>"-DredisBinary=/Applications/EAPManager.app/Contents/Resources/redis/redis-server"</argLine>
|
||||
</properties>
|
||||
</action>
|
||||
<action>
|
||||
<actionName>test.single</actionName>
|
||||
<packagings>
|
||||
<packaging>*</packaging>
|
||||
</packagings>
|
||||
<goals>
|
||||
<goal>test-compile</goal>
|
||||
<goal>surefire:test</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<test>${packageClassName}</test>
|
||||
<argLine>"-DredisBinary=/Applications/EAPManager.app/Contents/Resources/redis/redis-server"</argLine>
|
||||
</properties>
|
||||
</action>
|
||||
<action>
|
||||
<actionName>run.single.main</actionName>
|
||||
<packagings>
|
||||
<packaging>*</packaging>
|
||||
</packagings>
|
||||
<goals>
|
||||
<goal>process-classes</goal>
|
||||
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<exec.args>-classpath %classpath ${packageClassName}</exec.args>
|
||||
<exec.executable>java</exec.executable>
|
||||
<exec.classpathScope>${classPathScope}</exec.classpathScope>
|
||||
<argLine>"-DredisBinary=/Applications/EAPManager.app/Contents/Resources/redis/redis-server"</argLine>
|
||||
</properties>
|
||||
</action>
|
||||
<action>
|
||||
<actionName>debug</actionName>
|
||||
<properties>
|
||||
<argLine>"-DredisBinary=/Applications/EAPManager.app/Contents/Resources/redis/redis-server"</argLine>
|
||||
</properties>
|
||||
</action>
|
||||
<action>
|
||||
<actionName>debug.single.main</actionName>
|
||||
<packagings>
|
||||
<packaging>*</packaging>
|
||||
</packagings>
|
||||
<goals>
|
||||
<goal>process-classes</goal>
|
||||
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<exec.args>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath ${packageClassName}</exec.args>
|
||||
<exec.executable>java</exec.executable>
|
||||
<exec.classpathScope>${classPathScope}</exec.classpathScope>
|
||||
<jpda.listen>true</jpda.listen>
|
||||
<argLine>"-DredisBinary=/Applications/EAPManager.app/Contents/Resources/redis/redis-server"</argLine>
|
||||
</properties>
|
||||
</action>
|
||||
<action>
|
||||
<actionName>debug.test.single</actionName>
|
||||
<packagings>
|
||||
<packaging>*</packaging>
|
||||
</packagings>
|
||||
<goals>
|
||||
<goal>test-compile</goal>
|
||||
<goal>surefire:test</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<test>${packageClassName}</test>
|
||||
<forkMode>once</forkMode>
|
||||
<maven.surefire.debug>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address}</maven.surefire.debug>
|
||||
<jpda.listen>true</jpda.listen>
|
||||
<argLine>"-DredisBinary=/Applications/EAPManager.app/Contents/Resources/redis/redis-server"</argLine>
|
||||
</properties>
|
||||
</action>
|
||||
<action>
|
||||
<actionName>profile</actionName>
|
||||
<properties>
|
||||
<argLine>"-DredisBinary=/Applications/EAPManager.app/Contents/Resources/redis/redis-server"</argLine>
|
||||
</properties>
|
||||
</action>
|
||||
<action>
|
||||
<actionName>profile.single.main</actionName>
|
||||
<packagings>
|
||||
<packaging>*</packaging>
|
||||
</packagings>
|
||||
<goals>
|
||||
<goal>process-classes</goal>
|
||||
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<exec.args>-classpath %classpath ${packageClassName}</exec.args>
|
||||
<exec.executable>java</exec.executable>
|
||||
<exec.classpathScope>${classPathScope}</exec.classpathScope>
|
||||
<argLine>"-DredisBinary=/Applications/EAPManager.app/Contents/Resources/redis/redis-server"</argLine>
|
||||
</properties>
|
||||
</action>
|
||||
</actions>
|
@ -0,0 +1,118 @@
|
||||
/**
|
||||
* Copyright 2014 Nikita Koksharov, Nickolay Borbit
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.redisson;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.redisson.client.codec.Codec;
|
||||
import org.redisson.client.codec.DelegateDecoderCodec;
|
||||
import org.redisson.client.protocol.RedisCommand;
|
||||
import org.redisson.client.protocol.RedisCommand.ValueType;
|
||||
import org.redisson.client.protocol.RedisCommands;
|
||||
import org.redisson.command.CommandExecutor;
|
||||
import org.redisson.connection.decoder.MapGetAllDecoder;
|
||||
import org.redisson.core.RBucket;
|
||||
import org.redisson.core.RBuckets;
|
||||
|
||||
import io.netty.util.concurrent.Future;
|
||||
|
||||
public class RedissonBuckets implements RBuckets {
|
||||
|
||||
private final Codec codec;
|
||||
private final CommandExecutor commandExecutor;
|
||||
private final Redisson redisson;
|
||||
|
||||
public RedissonBuckets(Redisson redisson, CommandExecutor commandExecutor) {
|
||||
this(redisson, commandExecutor.getConnectionManager().getCodec(), commandExecutor);
|
||||
}
|
||||
|
||||
public RedissonBuckets(Redisson redisson, Codec codec, CommandExecutor commandExecutor) {
|
||||
super();
|
||||
this.codec = codec;
|
||||
this.commandExecutor = commandExecutor;
|
||||
this.redisson = redisson;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <V> List<RBucket<V>> find(String pattern) {
|
||||
Collection<String> keys = commandExecutor.get(commandExecutor.<List<String>, String>readAllAsync(RedisCommands.KEYS, pattern));
|
||||
List<RBucket<V>> buckets = new ArrayList<RBucket<V>>(keys.size());
|
||||
for (String key : keys) {
|
||||
if(key == null) {
|
||||
continue;
|
||||
}
|
||||
buckets.add(redisson.<V>getBucket(key, codec));
|
||||
}
|
||||
return buckets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <V> Map<String, V> get(String... keys) {
|
||||
if (keys.length == 0) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
RedisCommand<Map<Object, Object>> command = new RedisCommand<Map<Object, Object>>("MGET", new MapGetAllDecoder(Arrays.<Object>asList(keys), 0), ValueType.OBJECTS);
|
||||
Future<Map<String, V>> future = commandExecutor.readAsync(keys[0], new DelegateDecoderCodec(codec), command, keys);
|
||||
return commandExecutor.get(future);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean trySet(Map<String, ?> buckets) {
|
||||
if (buckets.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
List<Object> params = new ArrayList<Object>(buckets.size());
|
||||
for (Entry<String, ?> entry : buckets.entrySet()) {
|
||||
params.add(entry.getKey());
|
||||
try {
|
||||
params.add(codec.getValueEncoder().encode(entry.getValue()));
|
||||
} catch (IOException e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
}
|
||||
}
|
||||
|
||||
return commandExecutor.write(params.get(0).toString(), RedisCommands.MSETNX, params.toArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(Map<String, ?> buckets) {
|
||||
if (buckets.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<Object> params = new ArrayList<Object>(buckets.size());
|
||||
for (Entry<String, ?> entry : buckets.entrySet()) {
|
||||
params.add(entry.getKey());
|
||||
try {
|
||||
params.add(codec.getValueEncoder().encode(entry.getValue()));
|
||||
} catch (IOException e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
}
|
||||
}
|
||||
|
||||
commandExecutor.write(params.get(0).toString(), RedisCommands.MSET, params.toArray());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Copyright 2014 Nikita Koksharov, Nickolay Borbit
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.redisson.client.codec;
|
||||
|
||||
import org.redisson.client.protocol.Decoder;
|
||||
|
||||
public class DelegateDecoderCodec extends StringCodec {
|
||||
|
||||
private final Codec delegate;
|
||||
|
||||
public DelegateDecoderCodec(Codec delegate) {
|
||||
super();
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Decoder<Object> getValueDecoder() {
|
||||
return delegate.getValueDecoder();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
/**
|
||||
* Copyright 2014 Nikita Koksharov, Nickolay Borbit
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.redisson.core;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface RBuckets {
|
||||
|
||||
/**
|
||||
* <p>Returns a list of object holder instances by a key pattern.
|
||||
*
|
||||
* <pre>Supported glob-style patterns:
|
||||
* h?llo subscribes to hello, hallo and hxllo
|
||||
* h*llo subscribes to hllo and heeeello
|
||||
* h[ae]llo subscribes to hello and hallo, but not hillo
|
||||
* h[^e]llo matches hallo, hbllo, ... but not hello
|
||||
* h[a-b]llo matches hallo and hbllo</pre>
|
||||
* <p>Use \ to escape special characters if you want to match them verbatim.
|
||||
*
|
||||
* @param pattern
|
||||
* @return
|
||||
*/
|
||||
<V> List<RBucket<V>> find(String pattern);
|
||||
|
||||
/**
|
||||
* Returns Redis object mapped by key. Result Map is not contains
|
||||
* key-value entry for null values.
|
||||
*
|
||||
* @param keys
|
||||
* @return
|
||||
*/
|
||||
<V> Map<String, V> get(String ... keys);
|
||||
|
||||
/**
|
||||
* Try to save objects mapped by Redis key.
|
||||
* If at least one of them is already exist then
|
||||
* don't set none of them.
|
||||
*
|
||||
* @param buckets
|
||||
*/
|
||||
boolean trySet(Map<String, ?> buckets);
|
||||
|
||||
/**
|
||||
* Saves objects mapped by Redis key.
|
||||
*
|
||||
* @param buckets
|
||||
*/
|
||||
void set(Map<String, ?> buckets);
|
||||
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
package org.redisson;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.redisson.core.RBucket;
|
||||
|
||||
public class RedissonBucketsTest extends BaseTest {
|
||||
|
||||
@Test
|
||||
public void testGet() {
|
||||
RBucket<String> bucket1 = redisson.getBucket("test1");
|
||||
bucket1.set("someValue1");
|
||||
RBucket<String> bucket3 = redisson.getBucket("test3");
|
||||
bucket3.set("someValue3");
|
||||
|
||||
Map<String, String> result = redisson.getBuckets().get("test1", "test2", "test3", "test4");
|
||||
Map<String, String> expected = new HashMap<String, String>();
|
||||
expected.put("test1", "someValue1");
|
||||
expected.put("test3", "someValue3");
|
||||
|
||||
Assert.assertEquals(expected, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFind() {
|
||||
Collection<String> names = Arrays.asList("test:testGetPattern:one", "test:testGetPattern:two");
|
||||
Collection<String> vals = Arrays.asList("one-val", "two-val");
|
||||
|
||||
redisson.getBucket("test:testGetPattern:one").set("one-val");
|
||||
redisson.getBucket("test:testGetPattern:two").set("two-val");
|
||||
|
||||
List<RBucket<String>> buckets = redisson.getBuckets().find("test:testGetPattern:*");
|
||||
Assert.assertEquals(2, buckets.size());
|
||||
Assert.assertTrue(names.contains(buckets.get(0).getName()));
|
||||
Assert.assertTrue(names.contains(buckets.get(1).getName()));
|
||||
Assert.assertTrue(vals.contains(buckets.get(0).get()));
|
||||
Assert.assertTrue(vals.contains(buckets.get(1).get()));
|
||||
for (RBucket<String> bucket : buckets) {
|
||||
bucket.delete();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testSet() {
|
||||
Map<String, Integer> buckets = new HashMap<String, Integer>();
|
||||
buckets.put("12", 1);
|
||||
buckets.put("41", 2);
|
||||
redisson.getBuckets().set(buckets);
|
||||
|
||||
RBucket<Object> r1 = redisson.getBucket("12");
|
||||
assertThat(r1.get()).isEqualTo(1);
|
||||
|
||||
RBucket<Object> r2 = redisson.getBucket("41");
|
||||
assertThat(r2.get()).isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTrySet() {
|
||||
redisson.getBucket("12").set("341");
|
||||
|
||||
Map<String, Integer> buckets = new HashMap<String, Integer>();
|
||||
buckets.put("12", 1);
|
||||
buckets.put("41", 2);
|
||||
assertThat(redisson.getBuckets().trySet(buckets)).isFalse();
|
||||
|
||||
RBucket<Object> r2 = redisson.getBucket("41");
|
||||
assertThat(r2.get()).isNull();
|
||||
|
||||
Map<String, Integer> buckets2 = new HashMap<String, Integer>();
|
||||
buckets2.put("61", 1);
|
||||
buckets2.put("41", 2);
|
||||
assertThat(redisson.getBuckets().trySet(buckets2)).isTrue();
|
||||
|
||||
RBucket<Object> r1 = redisson.getBucket("61");
|
||||
assertThat(r1.get()).isEqualTo(1);
|
||||
|
||||
RBucket<Object> r3 = redisson.getBucket("41");
|
||||
assertThat(r3.get()).isEqualTo(2);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,183 @@
|
||||
package org.redisson;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.redisson.core.GeoEntry;
|
||||
import org.redisson.core.GeoPosition;
|
||||
import org.redisson.core.GeoUnit;
|
||||
import org.redisson.core.RGeo;
|
||||
|
||||
public class RedissonGeoTest extends BaseTest {
|
||||
|
||||
@Test
|
||||
public void testAdd() {
|
||||
RGeo<String> geo = redisson.getGeo("test");
|
||||
assertThat(geo.add(2.51, 3.12, "city1")).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddEntries() {
|
||||
RGeo<String> geo = redisson.getGeo("test");
|
||||
assertThat(geo.add(new GeoEntry(3.11, 9.10321, "city1"), new GeoEntry(81.1231, 38.65478, "city2"))).isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDist() {
|
||||
RGeo<String> geo = redisson.getGeo("test");
|
||||
geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));
|
||||
|
||||
assertThat(geo.dist("Palermo", "Catania", GeoUnit.METERS)).isEqualTo(166274.15156960033D);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDistEmpty() {
|
||||
RGeo<String> geo = redisson.getGeo("test");
|
||||
|
||||
assertThat(geo.dist("Palermo", "Catania", GeoUnit.METERS)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHash() {
|
||||
RGeo<String> geo = redisson.getGeo("test");
|
||||
geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));
|
||||
|
||||
Map<String, String> expected = new LinkedHashMap<String, String>();
|
||||
expected.put("Palermo", "sqc8b49rny0");
|
||||
expected.put("Catania", "sqdtr74hyu0");
|
||||
assertThat(geo.hash("Palermo", "Catania")).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHashEmpty() {
|
||||
RGeo<String> geo = redisson.getGeo("test");
|
||||
|
||||
assertThat(geo.hash("Palermo", "Catania")).isEmpty();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testPos() {
|
||||
RGeo<String> geo = redisson.getGeo("test");
|
||||
geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));
|
||||
|
||||
Map<String, GeoPosition> expected = new LinkedHashMap<String, GeoPosition>();
|
||||
expected.put("Palermo", new GeoPosition(13.361389338970184, 38.115556395496299));
|
||||
expected.put("Catania", new GeoPosition(15.087267458438873, 37.50266842333162));
|
||||
assertThat(geo.pos("test2", "Palermo", "test3", "Catania", "test1")).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPosEmpty() {
|
||||
RGeo<String> geo = redisson.getGeo("test");
|
||||
|
||||
assertThat(geo.pos("test2", "Palermo", "test3", "Catania", "test1")).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRadius() {
|
||||
RGeo<String> geo = redisson.getGeo("test");
|
||||
geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));
|
||||
|
||||
assertThat(geo.radius(15, 37, 200, GeoUnit.KILOMETERS)).containsExactly("Palermo", "Catania");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRadiusEmpty() {
|
||||
RGeo<String> geo = redisson.getGeo("test");
|
||||
|
||||
assertThat(geo.radius(15, 37, 200, GeoUnit.KILOMETERS)).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRadiusWithDistance() {
|
||||
RGeo<String> geo = redisson.getGeo("test");
|
||||
geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));
|
||||
|
||||
Map<String, Double> expected = new HashMap<String, Double>();
|
||||
expected.put("Palermo", 190.4424);
|
||||
expected.put("Catania", 56.4413);
|
||||
assertThat(geo.radiusWithDistance(15, 37, 200, GeoUnit.KILOMETERS)).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRadiusWithDistanceEmpty() {
|
||||
RGeo<String> geo = redisson.getGeo("test");
|
||||
|
||||
assertThat(geo.radiusWithDistance(15, 37, 200, GeoUnit.KILOMETERS)).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRadiusWithPosition() {
|
||||
RGeo<String> geo = redisson.getGeo("test");
|
||||
geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));
|
||||
|
||||
Map<String, GeoPosition> expected = new HashMap<String, GeoPosition>();
|
||||
expected.put("Palermo", new GeoPosition(13.361389338970184, 38.115556395496299));
|
||||
expected.put("Catania", new GeoPosition(15.087267458438873, 37.50266842333162));
|
||||
assertThat(geo.radiusWithPosition(15, 37, 200, GeoUnit.KILOMETERS)).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRadiusWithPositionEmpty() {
|
||||
RGeo<String> geo = redisson.getGeo("test");
|
||||
|
||||
assertThat(geo.radiusWithPosition(15, 37, 200, GeoUnit.KILOMETERS)).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRadiusMember() {
|
||||
RGeo<String> geo = redisson.getGeo("test");
|
||||
geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));
|
||||
|
||||
assertThat(geo.radius("Palermo", 200, GeoUnit.KILOMETERS)).containsExactly("Palermo", "Catania");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRadiusMemberEmpty() {
|
||||
RGeo<String> geo = redisson.getGeo("test");
|
||||
|
||||
assertThat(geo.radius("Palermo", 200, GeoUnit.KILOMETERS)).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRadiusMemberWithDistance() {
|
||||
RGeo<String> geo = redisson.getGeo("test");
|
||||
geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));
|
||||
|
||||
Map<String, Double> expected = new HashMap<String, Double>();
|
||||
expected.put("Palermo", 0.0);
|
||||
expected.put("Catania", 166.2742);
|
||||
assertThat(geo.radiusWithDistance("Palermo", 200, GeoUnit.KILOMETERS)).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRadiusMemberWithDistanceEmpty() {
|
||||
RGeo<String> geo = redisson.getGeo("test");
|
||||
|
||||
assertThat(geo.radiusWithDistance("Palermo", 200, GeoUnit.KILOMETERS)).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRadiusMemberWithPosition() {
|
||||
RGeo<String> geo = redisson.getGeo("test");
|
||||
geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));
|
||||
|
||||
Map<String, GeoPosition> expected = new HashMap<String, GeoPosition>();
|
||||
expected.put("Palermo", new GeoPosition(13.361389338970184, 38.115556395496299));
|
||||
expected.put("Catania", new GeoPosition(15.087267458438873, 37.50266842333162));
|
||||
assertThat(geo.radiusWithPosition("Palermo", 200, GeoUnit.KILOMETERS)).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRadiusMemberWithPositionEmpty() {
|
||||
RGeo<String> geo = redisson.getGeo("test");
|
||||
|
||||
assertThat(geo.radiusWithPosition("Palermo", 200, GeoUnit.KILOMETERS)).isEmpty();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue