mmiklavc commented on a change in pull request #1399: METRON-2073: Create 
in-memory use case for enrichment with map type and flatfile summarizer
URL: https://github.com/apache/metron/pull/1399#discussion_r286660484
 
 

 ##########
 File path: 
metron-platform/metron-enrichment/metron-enrichment-common/src/test/java/org/apache/metron/enrichment/cache/ObjectCacheTest.java
 ##########
 @@ -0,0 +1,113 @@
+/**
+ * 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.metron.enrichment.cache;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.metron.common.utils.SerDeUtils;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import java.io.BufferedOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class ObjectCacheTest {
+
+  @Rule
+  public ExpectedException thrown = ExpectedException.none();
+
+  FileSystem fs;
+  List<String> data;
+  ObjectCache cache;
+
+  @Before
+  public void setup() throws IOException {
+    fs = FileSystem.get(new Configuration());
+    data = new ArrayList<>();
+    {
+      data.add("apache");
+      data.add("metron");
+      data.add("is");
+      data.add("great");
+    }
+    cache = new ObjectCache();
+  }
+
+  @Test
+  public void test() throws Exception {
+    String filename = "target/ogt/test.ser";
 
 Review comment:
   This approach leaves open a potential for dirty data. Here are a few options 
that eliminate this issue altogether are:
   
   1. Our TestUtils functions. You'll need to tweak them for writing byte 
arrays, but there is temp dir functionality there as well - 
https://github.com/apache/metron/blob/master/metron-platform/metron-integration-test/src/main/java/org/apache/metron/integration/utils/TestUtils.java
   2. JUnit's temp directory/file feature 
https://github.com/apache/metron/blob/9cee51eb2c428eb7bf3aa791f5ec1293ed36c43a/metron-platform/metron-common/src/test/java/org/apache/metron/common/utils/HDFSUtilsTest.java#L35
   3. Add a cleanup hook in `@Before` that wipes a pre-determined temporary 
directory, if it exists, e.g. `target/ogt/`. One benefit of this approach is 
that if a test fails, the test data is still in the temp dir and can be readily 
inspected.
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to