### Question:
FileSegmentList implements SegmentList { @Override public void append(final Segment segment) { while (true) { List<Segment> currList = segmentList.get(); List<Segment> updateList = new ArrayList<Segment>(currList); updateList.add(segment); if (segmentList.compareAndSet(currList, updateList)) { return; } } } FileSegmentList(final File segListDir, final SegmentType type,
                           boolean needCreate, final long offsetIfCreate,
                           final long lastCheckOffset, StringBuilder sBuilder); @Override void close(); @Override List<Segment> getView(); @Override RecordView getRecordView(final long offset, final int maxSize); @Override void relRecordView(RecordView recordView); @Override void append(final Segment segment); @Override boolean checkExpiredSegments(final long checkTimestamp, final long fileValidTimeMs); @Override void delExpiredSegments(final StringBuilder sb); @Override void delete(final Segment segment); @Override void flushLast(boolean force); @Override Segment last(); @Override long getMinOffset(); @Override long getMaxOffset(); @Override long getCommitMaxOffset(); @Override long getSizeInBytes(); @Override Segment findSegment(final long offset);  }### Answer:
@Test public void append() { File dir = new File("src/test/resource/data"); if (dir.exists()) { File[] files = dir.listFiles(); for (File file : files) { file.delete(); } dir.delete(); } dir.mkdir(); try { File file = new File("src/test/resource/data", DataStoreUtils.nameFromOffset(0L, DataStoreUtils.DATA_FILE_SUFFIX)); file.createNewFile(); fileSegmentList = new FileSegmentList(dir, SegmentType.DATA, true, 0L, Long.MAX_VALUE, new StringBuilder()); Segment fileSegment = new FileSegment(100L, file, true, SegmentType.DATA); String data = "abc"; fileSegment.append(ByteBuffer.wrap(data.getBytes())); fileSegment.flush(true); fileSegmentList.append(fileSegment); List<Segment> segmentList = fileSegmentList.getView(); Assert.assertTrue(segmentList.size() == 2); file.delete(); } catch (IOException e) { e.printStackTrace(); } }