keith-turner commented on a change in pull request #2316:
URL: https://github.com/apache/accumulo/pull/2316#discussion_r728455540



##########
File path: 
core/src/test/java/org/apache/accumulo/core/spi/compaction/DefaultCompactionPlannerTest.java
##########
@@ -234,6 +234,168 @@ public void testMaxSize() {
     assertEquals(CompactionExecutorIdImpl.externalId("large"), 
job.getExecutor());
   }
 
+  /**
+   * Tests internal type executor with no numThreads set throws error
+   */
+  @Test
+  public void testErrorInternalTypeNoNumThreads() {
+    DefaultCompactionPlanner planner = new DefaultCompactionPlanner();
+    Configuration conf = EasyMock.createMock(Configuration.class);
+    
EasyMock.expect(conf.isSet(EasyMock.anyString())).andReturn(false).anyTimes();
+
+    ServiceEnvironment senv = EasyMock.createMock(ServiceEnvironment.class);
+    EasyMock.expect(senv.getConfiguration()).andReturn(conf).anyTimes();
+    EasyMock.replay(conf, senv);
+
+    try {
+      String executors = getExecutors("'type': 'internal','maxSize':'32M'",
+          "'type': 'internal','maxSize':'128M','numThreads':2",
+          "'type': 'internal','maxSize':'512M','numThreads':3");
+      planner.init(getInitParams(senv, executors));
+      fail("Failed to throw error");
+    } catch (NullPointerException e) {
+      assertTrue("Error message didn't contain numThreads", 
e.getMessage().contains("numThreads"));
+    }

Review comment:
       Could use assertThrows from junit, it returns the exception allowing the 
message to be checked.
   
   ```suggestion
      String executors = getExecutors("'type': 'internal','maxSize':'32M'",
          "'type': 'internal','maxSize':'128M','numThreads':2",
          "'type': 'internal','maxSize':'512M','numThreads':3");
      var e = assertThrows(NullPointerException.class, 
()->planner.init(getInitParams(senv, executors)));
      assertTrue("Error message didn't contain numThreads", 
e.getMessage().contains("numThreads"));
   ```




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