Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 2 commits
  • 4 files changed
  • 0 comments
  • 1 contributor
26  nosql/pom.xml
... ...
@@ -0,0 +1,26 @@
  1
+<?xml version="1.0" encoding="UTF-8"?>
  2
+<project xmlns="http://maven.apache.org/POM/4.0.0"
  3
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  5
+   <modelVersion>4.0.0</modelVersion>
  6
+
  7
+   <parent>
  8
+      <groupId>com.lateralthoughts</groupId>
  9
+      <artifactId>commons-parent</artifactId>
  10
+      <version>0.1-SNAPSHOT</version>
  11
+      <relativePath>../</relativePath>
  12
+   </parent>
  13
+
  14
+   <groupId>com.lateralthoughts</groupId>
  15
+   <artifactId>commons-nosql</artifactId>
  16
+   <version>0.1-SNAPSHOT</version>
  17
+
  18
+   <dependencies>
  19
+      <!-- Spring -->
  20
+      <dependency>
  21
+         <groupId>redis.clients</groupId>
  22
+         <artifactId>jedis</artifactId>
  23
+      </dependency>
  24
+   </dependencies>
  25
+
  26
+</project>
434  nosql/src/main/java/com/lateralthoughts/commons/nosql/redis/stub/FakeJedis.java
... ...
@@ -0,0 +1,434 @@
  1
+package com.lateralthoughts.commons.nosql.redis.stub;
  2
+
  3
+import redis.clients.jedis.BinaryClient;
  4
+import redis.clients.jedis.JedisCommands;
  5
+import redis.clients.jedis.SortingParams;
  6
+import redis.clients.jedis.Tuple;
  7
+
  8
+import java.util.*;
  9
+import java.util.concurrent.ConcurrentHashMap;
  10
+
  11
+/**
  12
+ * @author Jean-Baptiste Lemée
  13
+ */
  14
+public class FakeJedis implements JedisCommands {
  15
+
  16
+   private static Map<String, String> basicMap = new ConcurrentHashMap<String, String>();
  17
+   private static Map<String, Map<String, String>> namedMap = new ConcurrentHashMap<String, Map<String, String>>();
  18
+   private static Map<String, Set<String>> namedSet = new ConcurrentHashMap<String, Set<String>>();
  19
+   private static Map<String, LinkedList<String>> namedLinkedList = new ConcurrentHashMap<String, LinkedList<String>>();
  20
+
  21
+   public String set(String s, String s1) {
  22
+      return set(basicMap, s, s1);
  23
+   }
  24
+
  25
+   public String set(Map<String, String> map, String s, String s1) {
  26
+      map.put(s, s1);
  27
+      return "OK";
  28
+   }
  29
+
  30
+   public String get(String key) {
  31
+      return basicMap.get(key);
  32
+   }
  33
+
  34
+   private String get(Map<String, String> map, String s) {
  35
+      return map.get(s);
  36
+   }
  37
+
  38
+   public Boolean exists(String key) {
  39
+      return basicMap.containsKey(key);
  40
+   }
  41
+
  42
+   public String type(String s) {
  43
+      throw new UnsupportedOperationException();
  44
+   }
  45
+
  46
+   public Long expire(String s, int i) {
  47
+      throw new UnsupportedOperationException();
  48
+   }
  49
+
  50
+   public Long expireAt(String s, long l) {
  51
+      throw new UnsupportedOperationException();
  52
+   }
  53
+
  54
+   public Long ttl(String s) {
  55
+      throw new UnsupportedOperationException();
  56
+   }
  57
+
  58
+   @Override
  59
+   public boolean setbit(String key, long offset, boolean value) {
  60
+      throw new UnsupportedOperationException();
  61
+   }
  62
+
  63
+   @Override
  64
+   public boolean getbit(String key, long offset) {
  65
+      throw new UnsupportedOperationException();
  66
+   }
  67
+
  68
+   @Override
  69
+   public long setrange(String key, long offset, String value) {
  70
+      throw new UnsupportedOperationException();
  71
+   }
  72
+
  73
+   @Override
  74
+   public String getrange(String key, long startOffset, long endOffset) {
  75
+      throw new UnsupportedOperationException();
  76
+   }
  77
+
  78
+   public String getSet(String s, String s1) {
  79
+      throw new UnsupportedOperationException();
  80
+   }
  81
+
  82
+   public Long setnx(String s, String s1) {
  83
+      throw new UnsupportedOperationException();
  84
+   }
  85
+
  86
+   public String setex(String s, int i, String s1) {
  87
+      throw new UnsupportedOperationException();
  88
+   }
  89
+
  90
+   public Long decrBy(String s, long l) {
  91
+      return incrBy(s, -l);
  92
+   }
  93
+
  94
+   public Long decr(String s) {
  95
+      return decrBy(s, 1);
  96
+   }
  97
+
  98
+   public Long incrBy(String s, long l) {
  99
+      return incrBy(basicMap, s, l);
  100
+   }
  101
+
  102
+   private Long incrBy(Map<String, String> map, String s, long l) {
  103
+      long init = get(map, s) == null ? 0l : Long.valueOf(get(map, s));
  104
+      long newValue = init + l;
  105
+      set(map, s, String.valueOf(newValue));
  106
+      return newValue;
  107
+   }
  108
+
  109
+   public Long incr(String s) {
  110
+      return incrBy(s, 1);
  111
+   }
  112
+
  113
+   public Long append(String s, String s1) {
  114
+      throw new UnsupportedOperationException();
  115
+   }
  116
+
  117
+   public String substr(String s, int i, int i1) {
  118
+      throw new UnsupportedOperationException();
  119
+   }
  120
+
  121
+   public Long hset(String s, String s1, String s2) {
  122
+      if (namedMap.get(s) == null) {
  123
+         namedMap.put(s, new ConcurrentHashMap<String, String>());
  124
+      }
  125
+      Map<String, String> sMap = namedMap.get(s);
  126
+      if (sMap.get(s1) == null) {
  127
+         sMap.put(s1, s2);
  128
+         return 0l;
  129
+      } else {
  130
+         sMap.put(s1, s2);
  131
+         return 1l;
  132
+      }
  133
+   }
  134
+
  135
+   public String hget(String s, String s1) {
  136
+      if (namedMap.get(s) == null) {
  137
+         return null;
  138
+      }
  139
+      return namedMap.get(s).get(s1);
  140
+   }
  141
+
  142
+   public Long hsetnx(String s, String s1, String s2) {
  143
+      throw new UnsupportedOperationException();
  144
+   }
  145
+
  146
+   public String hmset(String s, Map<String, String> stringStringMap) {
  147
+      throw new UnsupportedOperationException();
  148
+   }
  149
+
  150
+   public List<String> hmget(String s, String... strings) {
  151
+      throw new UnsupportedOperationException();
  152
+   }
  153
+
  154
+   public Long hincrBy(String s, String s1, long l) {
  155
+      if (namedMap.get(s) == null) {
  156
+         namedMap.put(s, new ConcurrentHashMap<String, String>());
  157
+      }
  158
+      Map<String, String> sMap = namedMap.get(s);
  159
+      return incrBy(sMap, s1, l);
  160
+   }
  161
+
  162
+   public Boolean hexists(String s, String s1) {
  163
+      if (namedMap.get(s) == null) {
  164
+         return false;
  165
+      }
  166
+
  167
+      return namedMap.get(s).get(s1) != null;
  168
+   }
  169
+
  170
+   public Long hdel(String s, String s1) {
  171
+      if (namedMap.get(s) == null) {
  172
+         return 0l;
  173
+      }
  174
+      Map<String, String> sMap = namedMap.get(s);
  175
+      if (sMap.get(s1) == null) {
  176
+         return 0l;
  177
+      } else {
  178
+         sMap.remove(s1);
  179
+         return 1l;
  180
+      }
  181
+   }
  182
+
  183
+   public Long hlen(String s) {
  184
+      if (namedMap.get(s) == null) {
  185
+         return 0l;
  186
+      }
  187
+      return Long.valueOf(namedMap.get(s).size());
  188
+   }
  189
+
  190
+   public Set<String> hkeys(String s) {
  191
+      return basicMap.keySet();
  192
+   }
  193
+
  194
+   public List<String> hvals(String s) {
  195
+      if (namedMap.get(s) == null) {
  196
+         return new ArrayList<String>();
  197
+      }
  198
+
  199
+      return new ArrayList<String>(namedMap.get(s).values());
  200
+   }
  201
+
  202
+   public Map<String, String> hgetAll(String s) {
  203
+      if (namedMap.get(s) == null) {
  204
+         return new ConcurrentHashMap<String, String>();
  205
+      }
  206
+
  207
+      return namedMap.get(s);
  208
+   }
  209
+
  210
+   public Long rpush(String s, String s1) {
  211
+      if (namedLinkedList.get(s) == null) {
  212
+         namedLinkedList.put(s, new LinkedList<String>());
  213
+      }
  214
+      if (namedLinkedList.get(s).contains(s1)) {
  215
+         return 0l;
  216
+      }
  217
+      namedLinkedList.get(s).addLast(s1);
  218
+      return 1l;
  219
+   }
  220
+
  221
+   public Long lpush(String s, String s1) {
  222
+      if (namedLinkedList.get(s) == null) {
  223
+         namedLinkedList.put(s, new LinkedList<String>());
  224
+      }
  225
+      if (namedLinkedList.get(s).contains(s1)) {
  226
+         return 0l;
  227
+      }
  228
+      namedLinkedList.get(s).addFirst(s1);
  229
+      return 1l;
  230
+   }
  231
+
  232
+   public Long llen(String s) {
  233
+      if (namedLinkedList.get(s) == null) {
  234
+         return 0l;
  235
+      }
  236
+
  237
+      return Long.valueOf(namedLinkedList.get(s).size());
  238
+   }
  239
+
  240
+   @Override
  241
+   public List<String> lrange(String key, long start, long end) {
  242
+      int iStart = new Long(start).intValue();
  243
+      int iEnd = new Long(start).intValue();
  244
+      if (namedLinkedList.get(key) == null) {
  245
+         return new LinkedList<String>();
  246
+      } else {
  247
+         return namedLinkedList.get(key).subList(iStart, Math.min(iEnd, namedLinkedList.get(key).size() - 1));
  248
+      }
  249
+   }
  250
+
  251
+   @Override
  252
+   public String ltrim(String key, long start, long end) {
  253
+      throw new UnsupportedOperationException();
  254
+   }
  255
+
  256
+   @Override
  257
+   public String lindex(String key, long index) {
  258
+      throw new UnsupportedOperationException();
  259
+   }
  260
+
  261
+   @Override
  262
+   public String lset(String key, long index, String value) {
  263
+      throw new UnsupportedOperationException();
  264
+   }
  265
+
  266
+   @Override
  267
+   public Long lrem(String key, long count, String value) {
  268
+      throw new UnsupportedOperationException();
  269
+   }
  270
+
  271
+   public String lpop(String s) {
  272
+      throw new UnsupportedOperationException();
  273
+   }
  274
+
  275
+   public String rpop(String s) {
  276
+      throw new UnsupportedOperationException();
  277
+   }
  278
+
  279
+   public Long sadd(String s, String s1) {
  280
+      if (namedSet.get(s) == null) {
  281
+         namedSet.put(s, new HashSet<String>());
  282
+      }
  283
+      if (namedSet.get(s).contains(s1)) {
  284
+         return 0l;
  285
+      }
  286
+      namedSet.get(s).add(s1);
  287
+      return 1l;
  288
+   }
  289
+
  290
+   public Set<String> smembers(String s) {
  291
+      if (namedSet.get(s) == null) {
  292
+         return new HashSet<String>();
  293
+      }
  294
+      return namedSet.get(s);
  295
+   }
  296
+
  297
+   public Long srem(String s, String s1) {
  298
+      if (namedSet.get(s) == null) {
  299
+         return 0l;
  300
+      }
  301
+      if (namedSet.get(s).contains(s1)) {
  302
+         namedSet.get(s).remove(s1);
  303
+         return 1l;
  304
+      }
  305
+      return 0l;
  306
+   }
  307
+
  308
+   public String spop(String s) {
  309
+      throw new UnsupportedOperationException();
  310
+   }
  311
+
  312
+   public Long scard(String s) {
  313
+      throw new UnsupportedOperationException();
  314
+   }
  315
+
  316
+   public Boolean sismember(String s, String s1) {
  317
+      throw new UnsupportedOperationException();
  318
+   }
  319
+
  320
+   public String srandmember(String s) {
  321
+      throw new UnsupportedOperationException();
  322
+   }
  323
+
  324
+   public Long zadd(String s, double v, String s1) {
  325
+      throw new UnsupportedOperationException();
  326
+   }
  327
+
  328
+   public Set<String> zrange(String s, int i, int i1) {
  329
+      throw new UnsupportedOperationException();
  330
+   }
  331
+
  332
+   public Long zrem(String s, String s1) {
  333
+      throw new UnsupportedOperationException();
  334
+   }
  335
+
  336
+   public Double zincrby(String s, double v, String s1) {
  337
+      throw new UnsupportedOperationException();
  338
+   }
  339
+
  340
+   public Long zrank(String s, String s1) {
  341
+      throw new UnsupportedOperationException();
  342
+   }
  343
+
  344
+   public Long zrevrank(String s, String s1) {
  345
+      throw new UnsupportedOperationException();
  346
+   }
  347
+
  348
+   public Set<String> zrevrange(String s, int i, int i1) {
  349
+      throw new UnsupportedOperationException();
  350
+   }
  351
+
  352
+   public Set<Tuple> zrangeWithScores(String s, int i, int i1) {
  353
+      throw new UnsupportedOperationException();
  354
+   }
  355
+
  356
+   public Set<Tuple> zrevrangeWithScores(String s, int i, int i1) {
  357
+      throw new UnsupportedOperationException();
  358
+   }
  359
+
  360
+   public Long zcard(String s) {
  361
+      throw new UnsupportedOperationException();
  362
+   }
  363
+
  364
+   public Double zscore(String s, String s1) {
  365
+      throw new UnsupportedOperationException();
  366
+   }
  367
+
  368
+   public List<String> sort(String s) {
  369
+      throw new UnsupportedOperationException();
  370
+   }
  371
+
  372
+   public List<String> sort(String s, SortingParams sortingParams) {
  373
+      throw new UnsupportedOperationException();
  374
+   }
  375
+
  376
+   public Long zcount(String s, double v, double v1) {
  377
+      throw new UnsupportedOperationException();
  378
+   }
  379
+
  380
+   public Set<String> zrangeByScore(String s, double v, double v1) {
  381
+      throw new UnsupportedOperationException();
  382
+   }
  383
+
  384
+   @Override
  385
+   public Set<String> zrevrangeByScore(String key, double max, double min) {
  386
+      throw new UnsupportedOperationException();
  387
+   }
  388
+
  389
+   public Set<String> zrangeByScore(String s, double v, double v1, int i, int i1) {
  390
+      throw new UnsupportedOperationException();
  391
+   }
  392
+
  393
+   @Override
  394
+   public Set<String> zrevrangeByScore(String key, double max, double min, int offset, int count) {
  395
+      throw new UnsupportedOperationException();
  396
+   }
  397
+
  398
+   public Set<Tuple> zrangeByScoreWithScores(String s, double v, double v1) {
  399
+      throw new UnsupportedOperationException();
  400
+   }
  401
+
  402
+   @Override
  403
+   public Set<Tuple> zrevrangeByScoreWithScores(String key, double max, double min) {
  404
+      throw new UnsupportedOperationException();
  405
+   }
  406
+
  407
+   public Set<Tuple> zrangeByScoreWithScores(String s, double v, double v1, int i, int i1) {
  408
+      throw new UnsupportedOperationException();
  409
+   }
  410
+
  411
+   @Override
  412
+   public Set<Tuple> zrevrangeByScoreWithScores(String key, double max, double min, int offset, int count) {
  413
+      throw new UnsupportedOperationException();
  414
+   }
  415
+
  416
+   public Long zremrangeByRank(String s, int i, int i1) {
  417
+      throw new UnsupportedOperationException();
  418
+   }
  419
+
  420
+   public Long zremrangeByScore(String s, double v, double v1) {
  421
+      throw new UnsupportedOperationException();
  422
+   }
  423
+
  424
+   public Long linsert(String s, BinaryClient.LIST_POSITION list_position, String s1, String s2) {
  425
+      throw new UnsupportedOperationException();
  426
+   }
  427
+
  428
+   public static void reset() {
  429
+      basicMap.clear();
  430
+      namedMap.clear();
  431
+      namedSet.clear();
  432
+      namedLinkedList.clear();
  433
+   }
  434
+}
11  pom.xml
@@ -21,6 +21,9 @@
21 21
       <commons.collection.version>3.2.1</commons.collection.version>
22 22
       <log.version>1.6.4</log.version>
23 23
 
  24
+      <!-- Data -->
  25
+      <jedis.version>2.0.0</jedis.version>
  26
+
24 27
       <!-- Test -->
25 28
       <mockito.version>1.9.0</mockito.version>
26 29
       <junit.version>4.10</junit.version>
@@ -30,6 +33,7 @@
30 33
       <module>paging</module>
31 34
       <module>web</module>
32 35
       <module>spring</module>
  36
+      <module>nosql</module>
33 37
    </modules>
34 38
 
35 39
    <dependencyManagement>
@@ -127,6 +131,13 @@
127 131
             <version>${log.version}</version>
128 132
          </dependency>
129 133
 
  134
+         <!-- Data -->
  135
+         <dependency>
  136
+            <groupId>redis.clients</groupId>
  137
+            <artifactId>jedis</artifactId>
  138
+            <version>${jedis.version}</version>
  139
+         </dependency>
  140
+
130 141
          <!-- Test -->
131 142
          <dependency>
132 143
             <groupId>org.mockito</groupId>
3  web/src/main/java/com/lateralthoughts/commons/web/wadl/SchemaGenConfig.java
@@ -10,7 +10,6 @@
10 10
 
11 11
    @Override
12 12
    public List<WadlGeneratorDescription> configure() {
13  
-      return generator(
14  
-              WadlGeneratorJAXBGrammarGenerator.class   ).descriptions();
  13
+      return generator( WadlGeneratorJAXBGrammarGenerator.class).descriptions();
15 14
    }
16 15
 }

No commit comments for this range

Something went wrong with that request. Please try again.