< prev index next >

core/tests/org.openjdk.jmc.flightrecorder.test/src/test/java/org/openjdk/jmc/flightrecorder/test/FilteredRecordingTest.java

Print this page




  43 import org.junit.Test;
  44 
  45 import org.openjdk.jmc.common.item.IItemCollection;
  46 import org.openjdk.jmc.common.item.IItemIterable;
  47 import org.openjdk.jmc.common.test.io.IOResourceSet;
  48 import org.openjdk.jmc.flightrecorder.CouldNotLoadRecordingException;
  49 import org.openjdk.jmc.flightrecorder.JfrLoaderToolkit;
  50 import org.openjdk.jmc.flightrecorder.parser.IParserExtension;
  51 import org.openjdk.jmc.flightrecorder.parser.ParserExtensionRegistry;
  52 import org.openjdk.jmc.flightrecorder.parser.filter.FilterExtension;
  53 import org.openjdk.jmc.flightrecorder.parser.filter.IOnLoadFilter;
  54 import org.openjdk.jmc.flightrecorder.parser.filter.OnLoadFilters;
  55 import org.openjdk.jmc.flightrecorder.test.util.PrintoutsToolkit;
  56 
  57 /**
  58  * Test that checks that a recording can be filtered when loaded.
  59  */
  60 @SuppressWarnings("nls")
  61 public class FilteredRecordingTest {
  62         private static final String JVM_INFORMATION_REGEXP = ".*JVMInformation";
  63         private static final String COM_ORACLE_JDK_JVM_INFORMATION = "com.oracle.jdk.JVMInformation";
  64 
  65         @Test
  66         public void testIncludeEventTypeFilter() throws IOException, CouldNotLoadRecordingException {
  67                 checkFilter(OnLoadFilters.includeEvents(Arrays.asList(COM_ORACLE_JDK_JVM_INFORMATION)),
  68                                 COM_ORACLE_JDK_JVM_INFORMATION, true,
  69                                 "Expected all event types except '" + COM_ORACLE_JDK_JVM_INFORMATION + "'");
  70         }
  71 
  72         @Test
  73         public void testExcludeEventTypeFilter() throws IOException, CouldNotLoadRecordingException {
  74                 checkFilter(OnLoadFilters.excludeEvents(Arrays.asList(COM_ORACLE_JDK_JVM_INFORMATION)),
  75                                 COM_ORACLE_JDK_JVM_INFORMATION, false, "Expected event type '" + COM_ORACLE_JDK_JVM_INFORMATION + "'");
  76         }
  77 
  78         @Test
  79         public void testIncludeRegexpFilter() throws IOException, CouldNotLoadRecordingException {
  80                 checkFilter(OnLoadFilters.includeEvents(Pattern.compile(JVM_INFORMATION_REGEXP)),
  81                                 COM_ORACLE_JDK_JVM_INFORMATION, true,
  82                                 "Expected all event types except those matching '" + JVM_INFORMATION_REGEXP + "'");
  83         }




  43 import org.junit.Test;
  44 
  45 import org.openjdk.jmc.common.item.IItemCollection;
  46 import org.openjdk.jmc.common.item.IItemIterable;
  47 import org.openjdk.jmc.common.test.io.IOResourceSet;
  48 import org.openjdk.jmc.flightrecorder.CouldNotLoadRecordingException;
  49 import org.openjdk.jmc.flightrecorder.JfrLoaderToolkit;
  50 import org.openjdk.jmc.flightrecorder.parser.IParserExtension;
  51 import org.openjdk.jmc.flightrecorder.parser.ParserExtensionRegistry;
  52 import org.openjdk.jmc.flightrecorder.parser.filter.FilterExtension;
  53 import org.openjdk.jmc.flightrecorder.parser.filter.IOnLoadFilter;
  54 import org.openjdk.jmc.flightrecorder.parser.filter.OnLoadFilters;
  55 import org.openjdk.jmc.flightrecorder.test.util.PrintoutsToolkit;
  56 
  57 /**
  58  * Test that checks that a recording can be filtered when loaded.
  59  */
  60 @SuppressWarnings("nls")
  61 public class FilteredRecordingTest {
  62         private static final String JVM_INFORMATION_REGEXP = ".*JVMInformation";
  63         private static final String COM_ORACLE_JDK_JVM_INFORMATION = "jdk.JVMInformation";
  64 
  65         @Test
  66         public void testIncludeEventTypeFilter() throws IOException, CouldNotLoadRecordingException {
  67                 checkFilter(OnLoadFilters.includeEvents(Arrays.asList(COM_ORACLE_JDK_JVM_INFORMATION)),
  68                                 COM_ORACLE_JDK_JVM_INFORMATION, true,
  69                                 "Expected all event types except '" + COM_ORACLE_JDK_JVM_INFORMATION + "'");
  70         }
  71 
  72         @Test
  73         public void testExcludeEventTypeFilter() throws IOException, CouldNotLoadRecordingException {
  74                 checkFilter(OnLoadFilters.excludeEvents(Arrays.asList(COM_ORACLE_JDK_JVM_INFORMATION)),
  75                                 COM_ORACLE_JDK_JVM_INFORMATION, false, "Expected event type '" + COM_ORACLE_JDK_JVM_INFORMATION + "'");
  76         }
  77 
  78         @Test
  79         public void testIncludeRegexpFilter() throws IOException, CouldNotLoadRecordingException {
  80                 checkFilter(OnLoadFilters.includeEvents(Pattern.compile(JVM_INFORMATION_REGEXP)),
  81                                 COM_ORACLE_JDK_JVM_INFORMATION, true,
  82                                 "Expected all event types except those matching '" + JVM_INFORMATION_REGEXP + "'");
  83         }


< prev index next >