MountTable extends BaseRecord { public static MountTable newInstance() { MountTable record = StateStoreSerializer.newRecord(MountTable.class); record.init(); return record; } MountTable(); static MountTable newInstance(); static MountTable newInstance(final String src,
      final Map<String, String> destinations,
      long dateCreated, long dateModified); static MountTable newInstance(final String src,
      final Map<String, String> destinations); abstract String getSourcePath(); abstract void setSourcePath(String path); abstract List<RemoteLocation> getDestinations(); abstract void setDestinations(List<RemoteLocation> dests); abstract boolean addDestination(String nsId, String path); abstract boolean isReadOnly(); abstract void setReadOnly(boolean ro); abstract DestinationOrder getDestOrder(); abstract void setDestOrder(DestinationOrder order); abstract boolean isFaultTolerant(); abstract void setFaultTolerant(boolean faultTolerant); abstract String getOwnerName(); abstract void setOwnerName(String owner); abstract String getGroupName(); abstract void setGroupName(String group); abstract FsPermission getMode(); abstract void setMode(FsPermission mode); abstract RouterQuotaUsage getQuota(); abstract void setQuota(RouterQuotaUsage quota); RemoteLocation getDefaultLocation(); @Override boolean like(final BaseRecord o); @Override String toString(); @Override SortedMap<String, String> getPrimaryKeys(); @Override void validate(); @Override long getExpirationMs(); @Override int hashCode(); @Override boolean equals(Object obj); boolean isAll(); static final String ERROR_MSG_NO_SOURCE_PATH; static final String ERROR_MSG_MUST_START_WITH_BACK_SLASH; static final String ERROR_MSG_NO_DEST_PATH_SPECIFIED; static final String ERROR_MSG_INVAILD_DEST_NS; static final String ERROR_MSG_INVAILD_DEST_PATH; static final String ERROR_MSG_ALL_DEST_MUST_START_WITH_BACK_SLASH; static final Comparator<String> PATH_COMPARATOR; static final Comparator<MountTable> SOURCE_COMPARATOR; }
@Test public void testValidation() throws IOException { Map<String, String> destinations = new HashMap<>(); destinations.put("ns0", "/testValidate-dest"); try { MountTable.newInstance("testValidate", destinations); fail("Mount table entry should be created failed."); } catch (Exception e) { GenericTestUtils.assertExceptionContains( MountTable.ERROR_MSG_MUST_START_WITH_BACK_SLASH, e); } destinations.clear(); destinations.put("ns0", "testValidate-dest"); try { MountTable.newInstance("/testValidate", destinations); fail("Mount table entry should be created failed."); } catch (Exception e) { GenericTestUtils.assertExceptionContains( MountTable.ERROR_MSG_ALL_DEST_MUST_START_WITH_BACK_SLASH, e); } destinations.clear(); destinations.put("", "/testValidate-dest"); try { MountTable.newInstance("/testValidate", destinations); fail("Mount table entry should be created failed."); } catch (Exception e) { GenericTestUtils.assertExceptionContains( MountTable.ERROR_MSG_INVAILD_DEST_NS, e); } destinations.clear(); destinations.put("ns0", "/testValidate-dest"); MountTable record = MountTable.newInstance("/testValidate", destinations); assertNotNull(record); }