ParallelSnapshotFileMapper implements SnapshotFileMapper { @Override public File mapExportPath(DistributedMember member, File snapshot) { String baseName = getBaseName(snapshot); String memberUniqueId = createUniqueId((InternalDistributedMember) member); String fullName = baseName + "-" + memberUniqueId + RegionSnapshotService.SNAPSHOT_FILE_EXTENSION; return new File(snapshot.getParentFile(), fullName); }  @Override File mapExportPath(DistributedMember member, File snapshot); @Override File[] mapImportPath(DistributedMember member, File snapshot);  }
@Test public void mapExportPathWithIpv4() throws UnknownHostException { InternalDistributedMember member = mock(InternalDistributedMember.class); when(member.getInetAddress()).thenReturn(InetAddress.getByName("127.0.0.1")); when(member.getMembershipPort()).thenReturn(PORT); File mappedFile = mapper.mapExportPath(member, new File(BASE_LOCATION + FILE_TYPE)); File expectedFile = new File(BASE_LOCATION + "-" + 1270011234 + FILE_TYPE); assertEquals(expectedFile, mappedFile); }
@Test public void mapExportPathWithIpv6() throws UnknownHostException { InternalDistributedMember member = mock(InternalDistributedMember.class); when(member.getInetAddress()).thenReturn(InetAddress.getByName("2001:db8::2")); when(member.getMembershipPort()).thenReturn(PORT); File mappedFile = mapper.mapExportPath(member, new File(BASE_LOCATION + FILE_TYPE)); File expectedFile = new File(BASE_LOCATION + "-" + "2001db80000021234" + FILE_TYPE); assertEquals(expectedFile, mappedFile); }
@Test public void filesWithoutCorrectExtensionGiveUsefulException() throws Exception { thrown.expect(IllegalArgumentException.class); mapper.mapExportPath(null, new File(BASE_LOCATION)); }