dlmarion commented on code in PR #30:
URL: 
https://github.com/apache/accumulo-classloaders/pull/30#discussion_r2547494579


##########
modules/local-caching-classloader/src/test/java/org/apache/accumulo/classloader/lcc/LocalCachingContextTest.java:
##########
@@ -0,0 +1,221 @@
+/*
+ * 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
+ *
+ *   https://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.classloader.lcc;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.accumulo.classloader.lcc.definition.ContextDefinition;
+import org.apache.accumulo.classloader.lcc.definition.Resource;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.FsUrlStreamHandlerFactory;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hdfs.MiniDFSCluster;
+import org.eclipse.jetty.server.Server;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+public class LocalCachingContextTest {
+
+  private static final String CONTEXT_NAME = "TEST_CONTEXT";
+  private static final int MONITOR_INTERVAL_SECS = 5;
+  private static MiniDFSCluster hdfs;
+  private static Server jetty;
+  private static ContextDefinition def;
+
+  @TempDir
+  private static java.nio.file.Path tempDir;
+
+  @BeforeAll
+  public static void beforeAll() throws Exception {
+    String tmp = tempDir.resolve("base").toUri().toString();
+    System.setProperty(Constants.CACHE_DIR_PROPERTY, tmp);
+
+    // Find the Test jar files
+    final URL jarAOrigLocation =
+        
LocalCachingContextTest.class.getResource("/ClassLoaderTestA/TestA.jar");
+    assertNotNull(jarAOrigLocation);
+    final URL jarBOrigLocation =
+        
LocalCachingContextTest.class.getResource("/ClassLoaderTestB/TestB.jar");
+    assertNotNull(jarBOrigLocation);
+    final URL jarCOrigLocation =
+        
LocalCachingContextTest.class.getResource("/ClassLoaderTestC/TestC.jar");
+    assertNotNull(jarCOrigLocation);
+
+    // Put B into HDFS
+    hdfs = TestUtils.getMiniCluster();
+    final FileSystem fs = hdfs.getFileSystem();
+    assertTrue(fs.mkdirs(new Path("/contextB")));
+    final Path dst = new Path("/contextB/TestB.jar");
+    fs.copyFromLocalFile(new Path(jarBOrigLocation.toURI()), dst);
+    assertTrue(fs.exists(dst));
+    URL.setURLStreamHandlerFactory(new 
FsUrlStreamHandlerFactory(hdfs.getConfiguration(0)));
+    final URL jarBNewLocation = new URL(fs.getUri().toString() + 
dst.toUri().toString());
+
+    // Put C into Jetty
+    java.nio.file.Path jarCParentDirectory = 
Paths.get(jarCOrigLocation.toURI()).getParent();
+    jetty = TestUtils.getJetty(jarCParentDirectory);
+    final URL jarCNewLocation = jetty.getURI().resolve("TestC.jar").toURL();
+
+    // Create ContextDefinition with all three resources
+    final List<Resource> resources = new ArrayList<>();
+    resources.add(new Resource(jarAOrigLocation.toString(),
+        TestUtils.computeResourceChecksum(jarAOrigLocation)));
+    resources.add(new Resource(jarBNewLocation.toString(),
+        TestUtils.computeResourceChecksum(jarBOrigLocation)));
+    resources.add(new Resource(jarCNewLocation.toString(),
+        TestUtils.computeResourceChecksum(jarCOrigLocation)));
+
+    def = new ContextDefinition(CONTEXT_NAME, MONITOR_INTERVAL_SECS, 
resources);
+  }
+
+  @AfterAll
+  public static void afterAll() throws Exception {
+    jetty.stop();
+    jetty.join();

Review Comment:
   Added this in f4387dd



##########
modules/local-caching-classloader/src/test/java/org/apache/accumulo/classloader/lcc/LocalCachingContextTest.java:
##########
@@ -0,0 +1,221 @@
+/*
+ * 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
+ *
+ *   https://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.classloader.lcc;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.accumulo.classloader.lcc.definition.ContextDefinition;
+import org.apache.accumulo.classloader.lcc.definition.Resource;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.FsUrlStreamHandlerFactory;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hdfs.MiniDFSCluster;
+import org.eclipse.jetty.server.Server;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+public class LocalCachingContextTest {
+
+  private static final String CONTEXT_NAME = "TEST_CONTEXT";
+  private static final int MONITOR_INTERVAL_SECS = 5;
+  private static MiniDFSCluster hdfs;
+  private static Server jetty;
+  private static ContextDefinition def;
+
+  @TempDir
+  private static java.nio.file.Path tempDir;
+
+  @BeforeAll
+  public static void beforeAll() throws Exception {
+    String tmp = tempDir.resolve("base").toUri().toString();
+    System.setProperty(Constants.CACHE_DIR_PROPERTY, tmp);
+
+    // Find the Test jar files
+    final URL jarAOrigLocation =
+        
LocalCachingContextTest.class.getResource("/ClassLoaderTestA/TestA.jar");
+    assertNotNull(jarAOrigLocation);
+    final URL jarBOrigLocation =
+        
LocalCachingContextTest.class.getResource("/ClassLoaderTestB/TestB.jar");
+    assertNotNull(jarBOrigLocation);
+    final URL jarCOrigLocation =
+        
LocalCachingContextTest.class.getResource("/ClassLoaderTestC/TestC.jar");
+    assertNotNull(jarCOrigLocation);
+
+    // Put B into HDFS
+    hdfs = TestUtils.getMiniCluster();
+    final FileSystem fs = hdfs.getFileSystem();
+    assertTrue(fs.mkdirs(new Path("/contextB")));
+    final Path dst = new Path("/contextB/TestB.jar");
+    fs.copyFromLocalFile(new Path(jarBOrigLocation.toURI()), dst);
+    assertTrue(fs.exists(dst));
+    URL.setURLStreamHandlerFactory(new 
FsUrlStreamHandlerFactory(hdfs.getConfiguration(0)));
+    final URL jarBNewLocation = new URL(fs.getUri().toString() + 
dst.toUri().toString());
+
+    // Put C into Jetty
+    java.nio.file.Path jarCParentDirectory = 
Paths.get(jarCOrigLocation.toURI()).getParent();
+    jetty = TestUtils.getJetty(jarCParentDirectory);
+    final URL jarCNewLocation = jetty.getURI().resolve("TestC.jar").toURL();
+
+    // Create ContextDefinition with all three resources
+    final List<Resource> resources = new ArrayList<>();
+    resources.add(new Resource(jarAOrigLocation.toString(),
+        TestUtils.computeResourceChecksum(jarAOrigLocation)));
+    resources.add(new Resource(jarBNewLocation.toString(),
+        TestUtils.computeResourceChecksum(jarBOrigLocation)));
+    resources.add(new Resource(jarCNewLocation.toString(),
+        TestUtils.computeResourceChecksum(jarCOrigLocation)));
+
+    def = new ContextDefinition(CONTEXT_NAME, MONITOR_INTERVAL_SECS, 
resources);
+  }
+
+  @AfterAll
+  public static void afterAll() throws Exception {
+    jetty.stop();

Review Comment:
   Added this in f4387dd



-- 
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