All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.lordofthejars.nosqlunit.demo.custom.PropertiesCustomInsertion Maven / Gradle / Ivy

There is a newer version: 1.0.0-rc.5
Show newest version
package com.lordofthejars.nosqlunit.demo.custom;

import java.io.InputStream;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;

import redis.clients.jedis.BinaryJedisCommands;

import com.lordofthejars.nosqlunit.redis.RedisConnectionCallback;
import com.lordofthejars.nosqlunit.redis.RedisInsertionStrategy;

public class PropertiesCustomInsertion implements RedisInsertionStrategy {

	@Override
	public void insert(RedisConnectionCallback connection, InputStream dataset) throws Throwable {
		Properties properties = new Properties();
		properties.load(dataset);

		BinaryJedisCommands insertionJedis = connection.insertionJedis();
		
		Set> entrySet = properties.entrySet();
		
		for (Entry entry : entrySet) {
			String key = (String) entry.getKey();
			String value = (String) entry.getValue();
			insertionJedis.set(key.getBytes(), value.getBytes());
		}
		
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy