Coder Social home page Coder Social logo

ranxerox / mock-aerospike Goto Github PK

View Code? Open in Web Editor NEW

This project forked from srini156/mock-aerospike

0.0 1.0 0.0 50 KB

Mock Aerospike Java Client for unit testing

Home Page: http://www.aerospike.com/docs/client/java

License: Apache License 2.0

Java 100.00%

mock-aerospike's Introduction

mock-aerospike

Just use MockAerospikeClient implementation for the interface IAerospikeClient in your unit tests.

Goals

  • Lightweight & Embedded
  • Easy to use (implements the same interface)
  • Reduce effort in unit testing
  • Allow extensibility

Issues with IAerospikeClient

Currently, Aerospike provides for IAerospikeClient (in Java) with sole intention of making AerospikeClient testable. However, there are few issues pointed out - aerospike/aerospike-client-java#34

  • Don't mock what you don't own (Mocking IAerospikeClient, then mocking Record).

Better approach to testing is to create MockAerospikeClient which implements IAerospikeClient, thus avoiding mocking RecordSet and Record itself.

Implementation

MockAerospikeClient implements IAerospikeClient (version - 3.2.1)
Currently, MockAerospikeClient supports the following methods:

  • put
  • get
  • delete
  • exists
  • getHeader

MockAerospikeClient internally uses a HashMap to store Record corresponding to a Key

Setup

  • Maven
  • Java 1.8 or greater

Usage

  • pom.xml
    Add the following dependency to your pom.xml
<dependency>
  <groupId>com.github.srini156</groupId>
  <artifactId>mock-aerospike-java</artifactId>
  <version>0.0.4</version>
</dependency>
  • Code
  MockAerospikeClient client = new MockAerospikeClient();
  //Put entry into Aerospike
  client.put(null, new Key("namespace", "set", "key"), new Bin[] { new Bin("bin1", "value1") });
  //Fetch entry from Aerospike
  client.get(null, new Key("namespace","set","key"));

Contributions

It is currently alpha and WIP. Contributions are welcome, please raise a pull request.

mock-aerospike's People

Contributors

srini156 avatar phaneesh avatar vvv-aa avatar

Watchers

Agustín Cataldi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.