FileController(final FsModel model) { super(model); if (null != model.getParent()) throw new IllegalArgumentException(); URI uri = model.getMountPoint().toUri(); if ('\\' == separatorChar && null != uri.getRawAuthority()) { try { // Postfix: Move Windows UNC host from authority to path // component because the File class can't deal with this. // Note that the authority parameter must not be null and that // you cannot use the UriBuilder class - using either of these // would result in the authority property of the new URI object // being equal to the original value again. // Note that the use of the buggy URI constructor is authorized // for this case! // See http://java.net/jira/browse/TRUEZIP-288 . uri = new URI( uri.getScheme(), "", TWO_SEPARATORS + uri.getAuthority() + uri.getPath(), uri.getQuery(), uri.getFragment()); } catch (URISyntaxException ex) { throw new AssertionError(ex); } } this.target = new File(uri); }
FileController(final FsModel model) { super(model); if (null != model.getParent()) throw new IllegalArgumentException(); URI uri = model.getMountPoint().toUri(); if ('\\' == separatorChar && null != uri.getRawAuthority()) { try { // Postfix: Move Windows UNC host from authority to path // component because the File class can't deal with this. // Note that the authority parameter must not be null and that // you cannot use the UriBuilder class - using either of these // would result in the authority property of the new URI object // being equal to the original value again. // Note that the use of the buggy URI constructor is authorized // for this case! // See http://java.net/jira/browse/TRUEZIP-288 . uri = new URI( uri.getScheme(), "", TWO_SEPARATORS + uri.getAuthority() + uri.getPath(), uri.getQuery(), uri.getFragment()); } catch (URISyntaxException ex) { throw new AssertionError(ex); } } this.target = Paths.get(uri); }
/** * Constructs a new mock controller. * * @param model The file system model. * @param parent The parent file system controller. * @param config The mocking configuration. */ public MockController( final FsModel model, final @CheckForNull FsController<?> parent, final @CheckForNull TestConfig config) { assert null == model.getParent() ? null == parent : model.getParent().equals(parent.getModel()); this.model = model; this.parent = parent; this.config = null != config ? config : TestConfig.get(); }
private MockController newController(final FsModel model) { final FsModel pm = model.getParent(); final FsController<?> pc = null == pm ? null : newController(pm); return new TestController(model, pc); }
@Test @SuppressWarnings("ResultOfObjectAllocationIgnored") public void testConstructorWithMountPoint() { for (final String[] params : new String[][] { { "foo:/bar/" }, }) { final FsMountPoint mountPoint = FsMountPoint.create(URI.create(params[0])); final FsModel model = newModel(mountPoint, null); assertThat(model.getMountPoint(), sameInstance(mountPoint)); assertThat(model.getMountPoint().getPath(), nullValue()); assertThat(model.getParent(), nullValue()); assertThat(model.isMounted(), is(false)); } }
@Override public void setUp() throws IOException { super.setUp(); // Order is important here! final TestConfig config = getTestConfig(); config.setDataSize(getMaxArchiveLength()); config.setIOPoolProvider(null); // reset parent = newController(model.getParent()); }
assertThat(model.getParent(), sameInstance(parent)); assertThat(model.getMountPoint().getPath().resolve(entryName).getEntryName(), equalTo(parentEntryName)); assertThat(model.getMountPoint().resolve(entryName), equalTo(path));