S3FileNameParser extends AbstractFileNameParser { public FileName parseUri( VfsComponentContext context, FileName base, String uri ) throws FileSystemException { StringBuilder name = new StringBuilder(); String scheme = UriParser.extractScheme( uri, name ); UriParser.canonicalizePath( name, 0, name.length(), this ); UriParser.fixSeparators( name ); FileType fileType = UriParser.normalisePath( name ); String fullPath = name.toString(); final String bucketName = UriParser.extractFirstElement( name ); return new S3FileName( scheme, bucketName, fullPath, fileType ); } S3FileNameParser(); static FileNameParser getInstance(); FileName parseUri( VfsComponentContext context, FileName base, String uri );  }
@Test public void testParseUri() throws Exception { VfsComponentContext context = mock( VfsComponentContext.class ); FileName fileName = mock( FileName.class ); String uri = "s3: FileName noBaseFile = parser.parseUri( context, null, uri ); assertNotNull( noBaseFile ); assertEquals( "bucket", ( (S3FileName) noBaseFile ).getBucketId() ); FileName withBaseFile = parser.parseUri( context, fileName, uri ); assertNotNull( withBaseFile ); assertEquals( "bucket", ( (S3FileName) withBaseFile ).getBucketId() ); uri = "s3: withBaseFile = parser.parseUri( context, fileName, uri ); assertEquals( "s3", ( (S3FileName)withBaseFile ).getBucketId() ); }