1+ package com .zegelin .cassandra .exporter .cli ;
2+
3+ import com .google .common .collect .ImmutableSet ;
4+ import com .zegelin .cassandra .exporter .Harvester ;
5+ import org .testng .annotations .Test ;
6+
7+ import java .io .IOException ;
8+ import java .nio .file .Files ;
9+ import java .nio .file .Path ;
10+ import java .util .Set ;
11+ import java .util .stream .Collectors ;
12+
13+ import static org .testng .Assert .*;
14+
15+ public class HarvesterOptionsTest {
16+
17+ static Set <String > exclusionStrings = ImmutableSet .of ("test_collector" , "test:mbean=foo" );
18+ static Set <Harvester .Exclusion > exclusions = exclusionStrings .stream ()
19+ .map (Harvester .Exclusion ::create )
20+ .collect (Collectors .toSet ());
21+
22+ @ org .testng .annotations .Test
23+ public void testSetExclusions () {
24+ final HarvesterOptions harvesterOptions = new HarvesterOptions ();
25+
26+ harvesterOptions .setExclusions (exclusionStrings );
27+
28+ assertEquals (harvesterOptions .exclusions , exclusions );
29+ }
30+
31+ @ Test
32+ public void testSetExclusionsFromFile () throws IOException {
33+ final Path tempFile = Files .createTempFile (null , null );
34+
35+ Files .write (tempFile , exclusionStrings );
36+
37+ final HarvesterOptions harvesterOptions = new HarvesterOptions ();
38+
39+ harvesterOptions .setExclusions (ImmutableSet .of (String .format ("@%s" , tempFile )));
40+
41+ assertEquals (harvesterOptions .exclusions , exclusions );
42+ }
43+ }
0 commit comments