@Test
	public void testAtomicity() throws Exception {
		RedisRichGaugeRepository modified = new RedisRichGaugeRepository(connectionFactory, null) {
			/*
			 * Use a modified version of the repo that introduces a pause in the atomic unit, so that we can
			 * interfere from another thread.
			 */
			@Override
			public RichGauge findOne(String name) {
				try {
					Thread.sleep(500);
				}
				catch (InterruptedException e) {
					throw new RuntimeException(e);
				}
				return super.findOne(name);
			}

		};

		Thread concurrent = new Thread() {
			@Override
			public void run() {
				try {
					Thread.sleep(200);
				}
				catch (InterruptedException e) {
					throw new RuntimeException(e);
				}
				repo.recordValue("foo", 42.0D, -1.0D);
			}
		};


		concurrent.start();
		modified.recordValue("foo", 1.0D, -1.0D);
		concurrent.join();

		RichGauge result = repo.findOne("foo");
		assertThat(result.getAverage(), equalTo(21.5D));

	}
Tests for the Redis implementation of RichGaugeRepository.

@author Eric Bottard
@author Luke Taylor
@author Gary Russell
spring-xd-analytics/src/test/java/org/springframework/xd/analytics/metrics/redis/RedisRichGaugeRepositoryTests.java