Преглед на файлове

new: BasicUserStore
fix: GenericHshMap / GenericKey / UserProperty #toString
fix: CFTPHandler: backslashes

Ranides Atterwim преди 9 години
родител
ревизия
c820d94411

+ 6 - 1
assira/src/main/java/net/ranides/assira/collection/maps/GenericHashMap.java

@@ -118,7 +118,12 @@ public class GenericHashMap<K> implements GenericMap<K> {
     public <V> Collection<V> getAll(GenericKey<K, V> key) {
         return (Collection<V>)map.getAll(key);
     }
-    
+
+    @Override
+    public String toString() {
+        return map.toString();
+    }
+
     private static final class CGEntry<K> implements GenericEntry<K> {
         
         private final Entry<GenericKey<K,?>, Object> entry;

+ 7 - 5
assira/src/main/java/net/ranides/assira/collection/maps/GenericKey.java

@@ -15,7 +15,7 @@ import net.ranides.assira.reflection.IClass;
  *
  * @author msieron
  */
-public class GenericKey<K,V> implements Function<GenericHashMap<K>, V> {
+public class GenericKey<K,V> implements Function<GenericMap<K>, V> {
     
     private final IClass<V> type;
     private final K key;
@@ -44,7 +44,7 @@ public class GenericKey<K,V> implements Function<GenericHashMap<K>, V> {
     }
 
     @Override
-    public V apply(GenericHashMap<K> map) {
+    public V apply(GenericMap<K> map) {
         return map.get(this);
     }
     
@@ -71,7 +71,9 @@ public class GenericKey<K,V> implements Function<GenericHashMap<K>, V> {
         final GenericKey<?, ?> that = (GenericKey<?, ?>) object;
         return Objects.equals(this.type, that.type) && Objects.equals(this.key, that.key);
     }
-    
-    
-    
+
+    @Override
+    public String toString() {
+        return "#" + key;
+    }
 }

+ 97 - 0
assira/src/main/java/net/ranides/assira/credentials/BasicUserStore.java

@@ -0,0 +1,97 @@
+package net.ranides.assira.credentials;
+
+import net.ranides.assira.collection.maps.GenericKey;
+import net.ranides.assira.collection.maps.GenericMap;
+import net.ranides.assira.collection.query.CQuery;
+import net.ranides.assira.collection.query.CQueryBuilder;
+import net.ranides.assira.collection.sets.HashSet;
+import net.ranides.assira.index.IQuery;
+import net.ranides.assira.index.IQueryMap;
+import net.ranides.assira.index.IQueryMapTree;
+import net.ranides.assira.io.uri.URIUtils;
+
+import java.net.URI;
+import java.util.Optional;
+import java.util.Set;
+import java.util.function.Predicate;
+import java.util.stream.Stream;
+
+/**
+ * @author msieron
+ */
+public class BasicUserStore implements UserStore {
+
+    private final IQueryMap<GenericMap<String>> tree;
+
+    public BasicUserStore() {
+        tree = new IQueryMapTree();
+        index(UserProperty.ACCOUNT);
+        index(UserProperty.HOST);
+        index(UserProperty.PORT);
+    }
+
+    private <T> void index(GenericKey<String, T> key) {
+        tree.index(key.key(), key);
+    }
+
+    @Override
+    public CQuery<GenericMap<String>> match(URI uri) {
+        Optional<String> login = URIUtils.getLogin(uri);
+
+        if(login.isPresent()) {
+            return tree.find()
+                .eq(UserProperty.ACCOUNT, login.get())
+                .optional().eq(UserProperty.HOST, uri.getHost())
+                .optional().eq(UserProperty.PORT, uri.getPort())
+                .filter(u -> urimatch(u, uri));
+        } else {
+            return tree.find()
+                .optional().eq(UserProperty.HOST, uri.getHost())
+                .optional().eq(UserProperty.PORT, uri.getPort())
+                .filter(u -> urimatch(u, uri));
+        }
+
+
+
+//        Set<GenericMap<String>> target = new HashSet<>();
+//
+//        IQuery<GenericMap<String>> query = tree.find()
+//            .optional().eq(UserProperty.HOST, uri.getHost())
+//            .optional().eq(UserProperty.PORT, uri.getPort());
+//
+//        Optional<String> login = URIUtils.getLogin(uri);
+//
+//        if(login.isPresent()) {
+//            query.eq(UserProperty.ACCOUNT, login.get()).into(target);
+//            query.eq(UserProperty.LOGIN, login.get()).into(target);
+//            query.filter(u -> urimatch(u, uri))
+//        } else {
+//            tree.find()
+//                .eq(UserProperty.HOST, null)
+//                .eq(UserProperty.PORT, null)
+//                .filter(u -> urimatch(u, uri))
+//                .into(target);
+//        }
+//
+//        return CQueryBuilder.fromStream(() -> target.stream());
+    }
+
+    private boolean urimatch(GenericMap<String> u, URI uri) {
+        return u.getOptional(UserProperty.URI).map(p -> p.test(uri)).orElse(true);
+    }
+
+    @Override
+    public CQuery<GenericMap<String>> find(String user) {
+        return tree.find().eq(UserProperty.ACCOUNT, user);
+    }
+
+    public BasicUserStore add(GenericMap<String> user) {
+        tree.put(user);
+        return this;
+    }
+
+//    public BasicUserStore add(GenericMap<String> user) {
+//        tree.put(user);
+//        return this;
+//    }
+}

+ 2 - 2
assira/src/main/java/net/ranides/assira/credentials/UserProperty.java

@@ -32,8 +32,8 @@ public final class UserProperty<V> {
     
     public static final GenericKey<String,String> HOST = new GenericKey<>(String.class, "addr.host");
     
-    public static final GenericKey<String,Integer> PORT = new GenericKey<>(Integer.class, "addr.password");
+    public static final GenericKey<String,Integer> PORT = new GenericKey<>(Integer.class, "addr.port");
     
-    public static final GenericKey<String,Predicate<URI>> URI = new GenericKey<String,Predicate<URI>>("addr.password"){};
+    public static final GenericKey<String,Predicate<URI>> URI = new GenericKey<String,Predicate<URI>>("addr.uri"){};
     
 }

+ 26 - 10
assira/src/main/java/net/ranides/assira/io/uri/URIResolver.java

@@ -37,12 +37,22 @@ public final class URIResolver {
         }
     }
 
-    private final MStore store = new MStore();
+    private final MergeStore store = new MergeStore();
     
+    private final List<IClass<? extends URIHandler>> types;
     private final Map<String, URIHandler> handlers;
-    
+
     public URIResolver() {
+        types = new RTList<>();
+        handlers = new HashMap<>();
+    }
+
+    public URIResolver(URIResolver source) {
+        types = new RTList<>(source.types);
         handlers = new HashMap<>();
+        for (IClass<? extends URIHandler> type : types) {
+            register0(type.construct(this));
+        }
     }
     
     public URIHandle resolve(String location) throws IOException {
@@ -67,13 +77,19 @@ public final class URIResolver {
     }
 
     public URIResolver register(Class<? extends URIHandler> type) {
-        URIHandler handler = IClass.typeinfo(type).construct(this);
-        for(String s : handler.schemes()) {
-            handlers.put(s, handler);
-        }
+        IClass<? extends URIHandler> itype = IClass.typeinfo(type);
+        URIHandler handler = itype.construct(this);
+        types.add(itype);
+        register0(handler);
         return this;
     }
-    
+
+    private void register0(URIHandler handler) {
+        for(String scheme : handler.schemes()) {
+            handlers.put(scheme, handler);
+        }
+    }
+
     public URIResolver users(UserStore store) {
         this.store.add(store);
         return this;
@@ -83,9 +99,9 @@ public final class URIResolver {
         return store;
     }
     
-    private static final class MStore implements UserStore {
+    private static final class MergeStore implements UserStore {
         
-        private final List<UserStore> stores = new RTList<>(new UserStore[]{new CStore()});
+        private final List<UserStore> stores = new RTList<>(new UserStore[]{new ExtractStore()});
 
         @Override
         public CQuery<GenericMap<String>> match(URI uri) {
@@ -103,7 +119,7 @@ public final class URIResolver {
         
     }
     
-    private static final class CStore implements UserStore {
+    private static final class ExtractStore implements UserStore {
         
         @Override
         public CQuery<GenericMap<String>> match(URI uri) {

+ 23 - 20
assira/src/main/java/net/ranides/assira/io/uri/impl/CFTPHandler.java

@@ -151,7 +151,7 @@ public class CFTPHandler implements URIHandler {
             FTPFile[] files = man.shared(hostname).listFiles(path, FTPFileFilters.NON_NULL);
             return CQueryBuilder.fromArray(files)
                 .filter(e -> !".".equals(e.getName()) && !"..".equals(e.getName()))
-                .map(f -> new CFTPHandle(ireplace(uri, f.getName())));
+                .map(f -> new CFTPHandle(ireplace(uri, path + "/" + f.getName())));
         }
         
         
@@ -187,30 +187,33 @@ public class CFTPHandler implements URIHandler {
             }
             
             re.add(URIFlags.EXISTS);
-            re.add(URIFlags.SIZE);
+
             if(stat.isDirectory()) {
                 re.add(URIFlags.DIR);
             }
             if(stat.isFile()) {
                 re.add(URIFlags.FILE);
+                re.add(URIFlags.SIZE);
+
+                if(hasPermission(stat, FTPFile.READ_PERMISSION)) {
+                    re.add(URIFlags.READABLE);
+                    re.add(URIFlags.SEEK);
+                }
+                if(hasPermission(stat, FTPFile.WRITE_PERMISSION)) {
+                    re.add(URIFlags.WRITABLE);
+                    re.add(URIFlags.SEEK);
+                }
+                if(hasPermission(stat, FTPFile.EXECUTE_PERMISSION)) {
+                    re.add(URIFlags.EXECUTE);
+                }
+
+                if(text) {
+                    re.add(URIFlags.TEXT);
+                } else {
+                    re.add(URIFlags.BINARY);
+                }
             }
-            if(hasPermission(stat, FTPFile.READ_PERMISSION)) {
-                re.add(URIFlags.READABLE);
-                re.add(URIFlags.SEEK);
-            }
-            if(hasPermission(stat, FTPFile.WRITE_PERMISSION)) {
-                re.add(URIFlags.WRITABLE);
-                re.add(URIFlags.SEEK);
-            }
-            if(hasPermission(stat, FTPFile.EXECUTE_PERMISSION)) {
-                re.add(URIFlags.EXECUTE);
-            }
-            if(text) {
-                re.add(URIFlags.TEXT);
-            } else {
-                re.add(URIFlags.BINARY);
-            }
-            
+
             return re;
         }
         
@@ -270,7 +273,7 @@ public class CFTPHandler implements URIHandler {
     
     private static URI ireplace(URI uri, String path) {
         try {
-            return new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(), "/" + path, null, null);
+            return new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(), path, null, null);
         } catch (URISyntaxException cause) {
             throw new AssertionError("Invalid URI: " + path, cause);
         }

+ 67 - 0
assira/src/test/java/net/ranides/assira/credentials/BasicUserStoreTest.java

@@ -0,0 +1,67 @@
+package net.ranides.assira.credentials;
+
+import net.ranides.assira.collection.maps.GenericHashMap;
+import net.ranides.assira.text.Wildcard;
+import org.junit.Test;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Arrays;
+
+import static org.junit.Assert.*;
+
+/**
+ * @author msieron
+ */
+public class BasicUserStoreTest {
+
+    @Test
+    public void simple() throws URISyntaxException {
+        BasicUserStore store = new BasicUserStore();
+
+        store.add(new GenericHashMap<String>(){{
+            put(UserProperty.ACCOUNT, "home");
+            put(UserProperty.LOGIN, "ranides");
+            put(UserProperty.PASSWORD, "password");
+            put(UserProperty.HOST, "host.net");
+        }});
+        store.add(new GenericHashMap<String>(){{
+            put(UserProperty.ACCOUNT, "home");
+            put(UserProperty.LOGIN, "john");
+            put(UserProperty.PASSWORD, "444");
+            put(UserProperty.HOST, "host.org");
+        }});
+        store.add(new GenericHashMap<String>(){{
+            put(UserProperty.ACCOUNT, "hidden");
+            put(UserProperty.LOGIN, "anne");
+            put(UserProperty.PASSWORD, "555");
+            put(UserProperty.URI, u -> Wildcard.compile("*.htm").test(u.toString()));
+        }});
+        store.add(new GenericHashMap<String>(){{
+            put(UserProperty.ACCOUNT, "hidden");
+            put(UserProperty.LOGIN, "annette");
+            put(UserProperty.PASSWORD, "666");
+            put(UserProperty.URI, u -> Wildcard.compile("*.asp").test(u.toString()));
+        }});
+        store.add(new GenericHashMap<String>(){{
+            put(UserProperty.ACCOUNT, "custom");
+            put(UserProperty.LOGIN, "joanne");
+            put(UserProperty.PASSWORD, "666");
+            put(UserProperty.URI, u -> Wildcard.compile("http://*").test(u.toString()));
+        }});
+
+
+        assertEquals(Arrays.asList("ranides"), store.match(new URI("http://home@host.net/info.htm")).map(UserProperty.LOGIN).sort().list() );
+        assertEquals(Arrays.asList("john"), store.match(new URI("http://home@host.org/info.asp")).map(UserProperty.LOGIN).sort().list() );
+
+        assertEquals(Arrays.asList("annette"), store.match(new URI("http://hidden@host/info.asp")).map(UserProperty.LOGIN).sort().list() );
+        assertEquals(Arrays.asList("annette"), store.match(new URI("ftp://host/info.asp")).map(UserProperty.LOGIN).sort().list() );
+        assertEquals(Arrays.asList("annette", "joanne"), store.match(new URI("http://host/info.asp")).map(UserProperty.LOGIN).sort().list() );
+
+        assertEquals(Arrays.asList("anne"), store.match(new URI("http://hidden@domain/info.htm")).map(UserProperty.LOGIN).sort().list() );
+        assertEquals(Arrays.asList("anne", "joanne"), store.match(new URI("http://host/info.htm")).map(UserProperty.LOGIN).sort().list() );
+        assertEquals(Arrays.asList("anne", "joanne"), store.match(new URI("http://domain/info.htm")).map(UserProperty.LOGIN).sort().list() );
+        assertEquals(Arrays.asList("joanne"), store.match(new URI("http://custom@domain/info.htm")).map(UserProperty.LOGIN).sort().list() );
+    }
+
+}

+ 103 - 69
assira/src/test/java/net/ranides/assira/io/uri/impl/CFTPHandlerTest.java

@@ -6,33 +6,25 @@
  */
 package net.ranides.assira.io.uri.impl;
 
+import static net.ranides.assira.io.uri.URIFlags.*;
+import static net.ranides.assira.junit.NewAssert.*;
+
 import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.nio.charset.Charset;
-import java.util.Map;
-import java.util.Optional;
+
+import org.junit.Test;
 
 import net.ranides.assira.collection.maps.GenericHashMap;
-import net.ranides.assira.collection.maps.GenericMap;
-import net.ranides.assira.collection.maps.HashMap;
-import net.ranides.assira.collection.query.CQuery;
-import net.ranides.assira.collection.query.CQueryBuilder;
+import net.ranides.assira.credentials.BasicUserStore;
 import net.ranides.assira.credentials.UserProperty;
-import net.ranides.assira.credentials.UserStore;
+import net.ranides.assira.io.uri.URIFlags;
 import net.ranides.assira.io.uri.URIHandle;
-import net.ranides.assira.io.uri.URIHandler;
 import net.ranides.assira.io.uri.URIResolver;
-import net.ranides.assira.io.uri.URIUtils;
-import net.ranides.assira.reflection.util.ReflectUtils;
-import net.ranides.assira.text.IOStrings;
-import static net.ranides.assira.junit.NewAssert.*;
 import net.ranides.assira.text.Charsets;
-
+import net.ranides.assira.text.IOStrings;
 import net.ranides.assira.trace.ExceptionUtils;
-import org.junit.Test;
-
-import javax.naming.spi.Resolver;
 
 /**
  *
@@ -44,32 +36,102 @@ public class CFTPHandlerTest {
     
     private static final String TEXT_2 = "infov1";
 
+    private final URIResolver re = new URIResolver()
+        .register(CFTPHandler.class)
+        .users(new BasicUserStore().add(new GenericHashMap<String>(){{
+            put(UserProperty.ACCOUNT, "user");
+            put(UserProperty.LOGIN, "f12357_assira_ftp_test");
+            put(UserProperty.PASSWORD, "TTYKYbg25ijGxlnYBGfN");
+        }}));
+
+
+    @Test
+    public void testFlags() throws URISyntaxException, IOException {
+        URIHandle handle1 = re.resolve("ftp://user@ftp.ranides.net/");
+        URIHandle handle2 = re.resolve("ftp://user@ftp.ranides.net/dir/data");
+        URIHandle handle3 = re.resolve("ftp://user@ftp.ranides.net/dir/other/content.txt");
+        URIHandle handle4 = re.resolve("ftp://user@ftp.ranides.net/nop");
+
+        assertEquals(URIFlags.collect(EXISTS, DIR), handle1.flags());
+        assertEquals(URIFlags.collect(EXISTS, DIR), handle2.flags());
+        assertEquals(URIFlags.collect(EXISTS, FILE, BINARY, WRITABLE, READABLE, SIZE, SEEK), handle3.flags());
+        assertEquals(URIFlags.collect(), handle4.flags());
+
+        handle1.close();
+        handle2.close();
+        handle3.close();
+        handle4.close();
+    }
 
     @Test
     public void testScan() throws URISyntaxException, IOException {
-        TStore users = new TStore();
-        URIResolver re = new URIResolver().register(CFTPHandler.class).users(users);
 
-        users.add("user", "f12357_assira_ftp_test", "TTYKYbg25ijGxlnYBGfN");
+        String[] exp1 = {
+            "ftp://f12357_assira_ftp_test:TTYKYbg25ijGxlnYBGfN@ftp.ranides.net/dir/data",
+            "ftp://f12357_assira_ftp_test:TTYKYbg25ijGxlnYBGfN@ftp.ranides.net/dir/empty",
+            "ftp://f12357_assira_ftp_test:TTYKYbg25ijGxlnYBGfN@ftp.ranides.net/dir/file.bin",
+            "ftp://f12357_assira_ftp_test:TTYKYbg25ijGxlnYBGfN@ftp.ranides.net/dir/first.txt",
+            "ftp://f12357_assira_ftp_test:TTYKYbg25ijGxlnYBGfN@ftp.ranides.net/dir/other",
+            "ftp://f12357_assira_ftp_test:TTYKYbg25ijGxlnYBGfN@ftp.ranides.net/dir/sec.log"
+        };
+
+        String[] exp2 = {
+            "ftp://user@ftp.ranides.net/.ftpquota",
+            "ftp://user@ftp.ranides.net/dir",
+            "ftp://user@ftp.ranides.net/info.txt",
+            "ftp://user@ftp.ranides.net/readme.txt"
+        };
+
+        String[] exp3 = {
+            "ftp://user@ftp.ranides.net/dir/data",
+            "ftp://user@ftp.ranides.net/dir/empty",
+            "ftp://user@ftp.ranides.net/dir/file.bin",
+            "ftp://user@ftp.ranides.net/dir/first.txt",
+            "ftp://user@ftp.ranides.net/dir/other",
+            "ftp://user@ftp.ranides.net/dir/sec.log"
+        };
+
+        String[] exp4 = {
+            "ftp://user@ftp.ranides.net/dir/other/content.txt",
+            "ftp://user@ftp.ranides.net/dir/other/list.txt",
+        };
 
         URI u1 = new URI("ftp://f12357_assira_ftp_test:TTYKYbg25ijGxlnYBGfN@ftp.ranides.net/dir");
-        URI u2 = new URI("ftp://user@ftp.ranides.net/dir");
-        URI u3 = new URI("ftp://user@ftp.ranides.net/");
-        try(URIHandle handle1 = re.resolve(u1)) {
-            System.out.println(handle1.scan().map(e -> asName(e)).list());
+        URI u2 = new URI("ftp://user@ftp.ranides.net");
+        URI u3 = new URI("ftp://user@ftp.ranides.net/dir");
+        URI u4 = new URI("ftp://user@ftp.ranides.net/dir/other");
+
+
+        try(URIHandle handle = re.resolve(u1)) {
+            assertEquals("ftp://f12357_assira_ftp_test:TTYKYbg25ijGxlnYBGfN@ftp.ranides.net", handle.parent().uri().toString());
+            assertArrayEquals(exp1, handle.scan().map(e -> asName(e)).sort().array(String[]::new));
         }
-        try(URIHandle handle1 = re.resolve(u2)) {
-            System.out.println(handle1.scan().map(e -> asName(e)).list());
+
+        try(URIHandle handle = re.resolve(u2)) {
+            assertEquals("ftp://user@ftp.ranides.net", handle.parent().uri().toString());
+            assertArrayEquals(exp2, handle.scan().map(e -> asName(e)).sort().array(String[]::new));
         }
 
-        try(URIHandle handle1 = re.resolve(u3)) {
-            System.out.println(handle1.scan().map(e -> asName(e)).list());
+        try(URIHandle handle = re.resolve(u3)) {
+            assertEquals("ftp://user@ftp.ranides.net", handle.parent().uri().toString());
+            assertEquals("ftp://user@ftp.ranides.net", handle.parent().parent().uri().toString());
+            assertArrayEquals(exp3, handle.scan().map(e -> asName(e)).sort().array(String[]::new));
         }
+
+        try(URIHandle handle = re.resolve(u4)) {
+            assertEquals("ftp://user@ftp.ranides.net/dir", handle.parent().uri().toString());
+            assertEquals("ftp://user@ftp.ranides.net", handle.parent().parent().uri().toString());
+            assertArrayEquals(exp4, handle.scan().map(e -> asName(e)).sort().array(String[]::new));
+        }
+
+        try(URIHandle handle = re.resolve(u2)) {
+            assertEquals(TEXT_1, IOStrings.read(handle.scan().list().get(3).reader()));
+        }
+
     }
 
     private static String asName(URIHandle handle) {
         try {
-//            return handle.path().toString();
             return handle.uri().toString();
         } catch (IOException e) {
             throw ExceptionUtils.rethrow(e);
@@ -78,16 +140,13 @@ public class CFTPHandlerTest {
 
     @Test
     public void testUser() throws URISyntaxException, IOException {
-        URIHandler resolver = new CFTPHandler();
+        URI u1 = new URI("ftp://user@ftp.ranides.net/readme.txt");
         
-        URI u1 = new URI("ftp://f12357_assira_ftp_test:TTYKYbg25ijGxlnYBGfN@ftp.ranides.net/readme.txt");
-        
-        URIHandle handle1 = resolver.resolve(u1);
+        URIHandle handle1 = re.resolve(u1);
         assertEquals(TEXT_1, IOStrings.read(handle1.reader()));
-//        handle1.close();
-        
-        URI u2 = new URI("ftp://f12357_assira_ftp_test:TTYKYbg25ijGxlnYBGfN@ftp.ranides.net/info.txt");
-        URIHandle handle2 = resolver.resolve(u2);
+
+        URI u2 = new URI("ftp://user@ftp.ranides.net/info.txt");
+        URIHandle handle2 = re.resolve(u2);
         assertEquals(TEXT_2, IOStrings.read(handle2.reader()));
         
         handle1.close();
@@ -96,19 +155,18 @@ public class CFTPHandlerTest {
     
     @Test
     public void testCopy() throws URISyntaxException, IOException {
-        URIHandler resolver = new CFTPHandler();
-        
-        URI u1 = new URI("ftp://f12357_assira_ftp_test:TTYKYbg25ijGxlnYBGfN@ftp.ranides.net/readme.txt");
-        URI u2 = new URI("ftp://f12357_assira_ftp_test:TTYKYbg25ijGxlnYBGfN@ftp.ranides.net/out-1.txt");
-        String s3 = "ftp://f12357_assira_ftp_test:TTYKYbg25ijGxlnYBGfN@ftp.ranides.net/out-2.txt?charset=windows-1250";
-        try (URIHandle target = resolver.resolve(u2)) {
+
+        URI u1 = new URI("ftp://user@ftp.ranides.net/readme.txt");
+        URI u2 = new URI("ftp://user@ftp.ranides.net/out-1.txt");
+        String s3 = "ftp://user@ftp.ranides.net/out-2.txt?charset=windows-1250";
+        try (URIHandle target = re.resolve(u2)) {
             
             assertFalse(target.exists());
             
-            try (URIHandle source = resolver.resolve(u1)) {
+            try (URIHandle source = re.resolve(u1)) {
                 source.copy(target);
             }
-            try (URIHandle source = resolver.resolve(u1)) {
+            try (URIHandle source = re.resolve(u1)) {
                 source.copy(s3);
             }
             
@@ -118,7 +176,7 @@ public class CFTPHandlerTest {
             target.delete();
             assertFalse(target.exists());
             
-            try(URIHandle u3 = resolver.resolve(new URI(s3))) {
+            try(URIHandle u3 = re.resolve(new URI(s3))) {
                 assertNotEquals(TEXT_1, IOStrings.read(u3.reader()));
                 assertEquals(cast(TEXT_1, Charsets.UTF8 ,Charsets.PL_WINDOWS), IOStrings.read(u3.reader()));
                 u3.delete();
@@ -131,28 +189,4 @@ public class CFTPHandlerTest {
         return new String(text.getBytes(source), target);
     }
 
-    private static final class TStore implements UserStore {
-
-        private Map<String, GenericMap<String>> users = new HashMap<>();
-
-        @Override
-        public CQuery<GenericMap<String>> match(URI uri) {
-            return URIUtils.getLogin(uri).map(this::find).orElse(CQueryBuilder.empty());
-        }
-
-        @Override
-        public CQuery<GenericMap<String>> find(String user) {
-            GenericMap<String> map = users.get(user);
-            return map!=null ? CQueryBuilder.of(map) : CQueryBuilder.empty();
-        }
-
-        public void add(String id, String login, String pass) {
-            GenericMap<String> map = new GenericHashMap<>();
-            map.put(UserProperty.LOGIN, login);
-            map.put(UserProperty.PASSWORD, pass);
-            users.put(id, map);
-        }
-
-    }
-    
 }