ZooKeeperIndex implements IIndex { @Override public void addArtifact(IndexKey key, IndexArtifact artifact) throws IndexException, IndexConfictException { String path = convertPath(key); if (isArtifact(key)) { if (!(getArtifact(key) instanceof ReservedArtifact)) { try { client.setData().forPath(path, SerializationUtils.serialize(artifact)); } catch (Exception exc) { throw new IndexException(exc); } } else { throw new IndexConfictException(); } } else { try { client.create().creatingParentsIfNeeded().forPath(path, SerializationUtils.serialize(artifact)); } catch (Exception exc) { throw new IndexException(exc); } } }  @Override boolean isArtifact(IndexKey key); @Override void addArtifact(IndexKey key, IndexArtifact artifact); @Override IndexArtifact getArtifact(IndexKey key); @Override void load(RepositoryType type, IStorage storage, String uploadPath); @Override ReservedArtifact addReservationKey(IndexKey key); @Override void addReservedArtifact(IndexKey key, ReservedArtifact reservation,
            IndexArtifact artifact); void startClient(String connectionString);  }
@Test public void testAddArtifact() throws Exception { TestingServer testingServer = new TestingServer(); index.startClient(testingServer.getConnectString()); try { index.addArtifact(IndexUtils.TEST1.getKey(), IndexUtils.TEST1.getArtifact()); Assert.assertTrue(index.isArtifact(IndexUtils.TEST1.getKey())); assertEquals(IndexUtils.TEST1.getArtifact(), index.getArtifact(IndexUtils.TEST1.getKey())); } finally { CloseableUtils.closeQuietly(testingServer); } }