milleruntime commented on a change in pull request #2368:
URL: https://github.com/apache/accumulo/pull/2368#discussion_r756280283



##########
File path: 
core/src/test/java/org/apache/accumulo/core/file/rfile/GenerateSplitsTest.java
##########
@@ -0,0 +1,148 @@
+/*
+ * 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.accumulo.core.file.rfile;
+
+import static org.apache.accumulo.core.file.rfile.GenerateSplits.main;
+import static 
org.apache.accumulo.core.file.rfile.RFileTest.newColFamByteSequence;
+import static org.apache.accumulo.core.file.rfile.RFileTest.newKey;
+import static org.apache.accumulo.core.file.rfile.RFileTest.newValue;
+import static org.junit.Assert.assertThrows;
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.List;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
+@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "paths 
provided by test")
+public class GenerateSplitsTest {
+  private static final Logger log = 
LoggerFactory.getLogger(GenerateSplitsTest.class);
+
+  @ClassRule
+  public static final TemporaryFolder tempFolder =
+      new TemporaryFolder(new File(System.getProperty("user.dir") + 
"/target"));
+
+  private static final RFileTest.TestRFile trf = new RFileTest.TestRFile(null);
+  private static String fileName;
+
+  /**
+   * Creates a test file with 84 bytes of data and 2 Locality groups.
+   */
+  @BeforeClass
+  public static void createFile() throws IOException {
+    trf.openWriter(false);
+    trf.writer.startNewLocalityGroup("lg1", newColFamByteSequence("cf1", 
"cf2"));
+    trf.writer.append(newKey("r1", "cf1", "cq1", "L1", 55), newValue("foo1"));
+    trf.writer.append(newKey("r2", "cf2", "cq1", "L1", 55), newValue("foo2"));
+    trf.writer.append(newKey("r3", "cf2", "cq1", "L1", 55), newValue("foo3"));
+    trf.writer.startNewLocalityGroup("lg2", newColFamByteSequence("cf3", 
"cf4"));
+    trf.writer.append(newKey("r4", "cf3", "cq1", "L1", 55), newValue("foo4"));
+    trf.writer.append(newKey("r5", "cf4", "cq1", "L1", 55), newValue("foo5"));
+    trf.writer.append(newKey("r6", "cf4", "cq1", "L1", 55), newValue("foo6"));
+    trf.closeWriter();
+
+    File file = tempFolder.newFile("testGenerateSplits.rf");
+    FileOutputStream fileOutputStream = new FileOutputStream(file);
+    fileOutputStream.write(trf.baos.toByteArray());
+    fileOutputStream.flush();
+    fileOutputStream.close();
+
+    fileName = file.getAbsolutePath();
+    log.info("Wrote to file {}", fileName);
+  }
+
+  @AfterClass
+  public static void cleanUp() {
+    File file = new File(fileName);
+    if (file.delete())
+      log.info("Cleaned up test file {}", fileName);

Review comment:
       I had added this when i created the test initially because I was unsure 
but I think you are right. I thought I saw another Test doing this as well but 
can't find it 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]


Reply via email to