-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
no longer throw exception on set times (#361)
* no longer throw exception on set times * add copyright * demo of move
- Loading branch information
1 parent
1f61877
commit 56f705e
Showing
3 changed files
with
76 additions
and
4 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
src/examples/java/software/amazon/nio/spi/examples/MoveObject.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package software.amazon.nio.spi.examples; | ||
|
||
import java.io.IOException; | ||
import java.net.URI; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* Demonstrates a move operation using the `Files` class | ||
*/ | ||
public class MoveObject { | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(MoveObject.class.getName()); | ||
|
||
public static void main(String[] args) throws IOException { | ||
|
||
if (args.length != 2) { | ||
logger.error("Usage: java MoveObject <source> <destination>"); | ||
System.exit(1); | ||
} | ||
|
||
logger.info("Moving {} to {}", args[0], args[1]); | ||
|
||
URI source = URI.create(args[0]); | ||
URI destination = URI.create(args[1]); | ||
Files.move(Path.of(source), Path.of(destination)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/test/java/software/amazon/nio/spi/s3/S3BasicFileAttributeViewTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package software.amazon.nio.spi.s3; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import java.net.URI; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class S3BasicFileAttributeViewTest { | ||
final String uriString = "s3://mybucket"; | ||
final S3FileSystemProvider provider = new S3FileSystemProvider(); | ||
|
||
S3FileSystem fileSystem = provider.getFileSystem(URI.create(uriString), true); | ||
S3Path path = S3Path.getPath(fileSystem, uriString); | ||
S3BasicFileAttributeView view = new S3BasicFileAttributeView(path); | ||
|
||
@Test | ||
void setTimes() { | ||
assertDoesNotThrow(() -> view.setTimes(null, null, null)); | ||
} | ||
|
||
@Test | ||
void name() { | ||
assertEquals("s3", view.name()); | ||
} | ||
} |