### Question:
ReplicationUtil { public Map<String,String> getPeers() { Map<String,String> peers = new HashMap<>(); for (Entry<String,String> property : context.getConfiguration() .getAllPropertiesWithPrefix(Property.REPLICATION_PEERS).entrySet()) { String key = property.getKey(); if (!key.startsWith(Property.REPLICATION_PEER_USER.getKey()) && !key.startsWith(Property.REPLICATION_PEER_PASSWORD.getKey()) && !key.startsWith(Property.REPLICATION_PEER_KEYTAB.getKey())) { String peerName = property.getKey().substring(Property.REPLICATION_PEERS.getKey().length()); Entry<String,String> entry; try { entry = factory.parseReplicaSystemConfiguration(property.getValue()); } catch (Exception e) { log.warn("Could not instantiate ReplicaSystem for {} with configuration {}", property.getKey(), property.getValue(), e); continue; } peers.put(peerName, entry.getKey()); } } return peers; } ReplicationUtil(ServerContext context);  ReplicationUtil(ServerContext context, ReplicaSystemFactory factory); int getMaxReplicationThreads(MasterMonitorInfo mmi); Map<String,String> getPeers(); Set<ReplicationTarget> getReplicationTargets(); Map<ReplicationTarget,Long> getPendingReplications(); Set<Path> getPendingReplicationPaths(); static final String STATUS_FORMATTER_CLASS_NAME; }### Answer:
@Test public void testUserNamePassword() { final String peerName = "peer"; final String systemImpl = "my.replica.system.impl"; final String config = "accumulo_peer,remote_host:2181"; final String peerDefinition = systemImpl + "," + config; confEntries.put(Property.REPLICATION_PEER_USER.getKey() + peerName, "user"); confEntries.put(Property.REPLICATION_PEER_PASSWORD.getKey() + peerName, "password"); confEntries.put(Property.REPLICATION_PEERS.getKey() + peerName, peerDefinition); ReplicaSystem system = EasyMock.createMock(ReplicaSystem.class); EasyMock.expect(conf.getAllPropertiesWithPrefix(Property.REPLICATION_PEERS)) .andReturn(confEntries); EasyMock.replay(context, conf, system); Map<String,String> peers = util.getPeers(); EasyMock.verify(context, conf, system); assertEquals(1, peers.size()); Entry<String,String> peer = peers.entrySet().iterator().next(); assertEquals(peerName, peer.getKey()); assertEquals(systemImpl, peer.getValue()); }
@Test public void testUserNameKeytab() { final String peerName = "peer"; final String systemImpl = "my.replica.system.impl"; final String config = "accumulo_peer,remote_host:2181"; final String peerDefinition = systemImpl + "," + config; confEntries.put(Property.REPLICATION_PEER_USER.getKey() + peerName, "user"); confEntries.put(Property.REPLICATION_PEER_KEYTAB.getKey() + peerName, "/path/to/keytab"); confEntries.put(Property.REPLICATION_PEERS.getKey() + peerName, peerDefinition); ReplicaSystem system = EasyMock.createMock(ReplicaSystem.class); EasyMock.expect(conf.getAllPropertiesWithPrefix(Property.REPLICATION_PEERS)) .andReturn(confEntries); EasyMock.replay(context, conf, system); Map<String,String> peers = util.getPeers(); EasyMock.verify(context, conf, system); assertEquals(1, peers.size()); Entry<String,String> peer = peers.entrySet().iterator().next(); assertEquals(peerName, peer.getKey()); assertEquals(systemImpl, peer.getValue()); }