cryptoe commented on code in PR #12874: URL: https://github.com/apache/druid/pull/12874#discussion_r942547953
########## core/src/test/java/org/apache/druid/storage/LocalFileStorageConnectorTest.java: ########## @@ -0,0 +1,102 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.druid.storage; + +import org.apache.druid.java.util.common.FileUtils; +import org.junit.Assert; +import org.junit.Test; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.UUID; + +public class LocalFileStorageConnectorTest +{ + private File tempDir = FileUtils.createTempDir(); + private StorageConnector storageConnector = new LocalFileStorageConnectorProvider(tempDir.getPath()).get(); + + public LocalFileStorageConnectorTest() + { + tempDir.deleteOnExit(); + } + + @Test + public void sanityCheck() throws IOException + { + String uuid = UUID.randomUUID().toString(); + + //create file + createFile(uuid); + + // check if file is created + Assert.assertTrue(storageConnector.pathExists(uuid)); + Assert.assertTrue(new File(tempDir.getAbsolutePath() + "/" + uuid).exists()); + + // check contents + checkContents(uuid); + + // delete file + storageConnector.delete(uuid); + Assert.assertFalse(new File(tempDir.getAbsolutePath() + "/" + uuid).exists()); + } + + @Test + public void deleteRecursivelyTest() throws IOException + { + String uuid_base = UUID.randomUUID().toString(); + String uuid1 = uuid_base + "/" + UUID.randomUUID(); Review Comment: As I need the string further down for the assert, I will keep it as a string for now. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
