com.sun.jmx.examples.scandir.config.DirectoryScannerConfig Java Examples
The following examples show how to use
com.sun.jmx.examples.scandir.config.DirectoryScannerConfig.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ScanDirConfigTest.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Test of getXmlConfigString method, of class com.sun.jmx.examples.scandir.ScanDirConfig. */ public void testGetXmlConfigString() throws Exception { System.out.println("getXmlConfigString"); try { final File file = File.createTempFile("testconf",".xml"); final ScanDirConfig instance = new ScanDirConfig(file.getAbsolutePath()); final ScanManagerConfig bean = new ScanManagerConfig("testGetXmlConfigString"); final DirectoryScannerConfig dir = new DirectoryScannerConfig("tmp"); dir.setRootDirectory(file.getParent()); bean.putScan(dir); instance.setConfiguration(bean); System.out.println("Expected: " + XmlConfigUtils.toString(bean)); System.out.println("Received: " + instance.getConfiguration().toString()); assertEquals(XmlConfigUtils.toString(bean), instance.getConfiguration().toString()); } catch (Exception x) { x.printStackTrace(); throw x; } }
Example #2
Source File: ScanDirConfigTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * Test of getXmlConfigString method, of class com.sun.jmx.examples.scandir.ScanDirConfig. */ public void testGetXmlConfigString() throws Exception { System.out.println("getXmlConfigString"); try { final File file = File.createTempFile("testconf",".xml"); final ScanDirConfig instance = new ScanDirConfig(file.getAbsolutePath()); final ScanManagerConfig bean = new ScanManagerConfig("testGetXmlConfigString"); final DirectoryScannerConfig dir = new DirectoryScannerConfig("tmp"); dir.setRootDirectory(file.getParent()); bean.putScan(dir); instance.setConfiguration(bean); System.out.println("Expected: " + XmlConfigUtils.toString(bean)); System.out.println("Received: " + instance.getConfiguration().toString()); assertEquals(XmlConfigUtils.toString(bean), instance.getConfiguration().toString()); } catch (Exception x) { x.printStackTrace(); throw x; } }
Example #3
Source File: DirectoryScannerTest.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Test of getState method, of class com.sun.jmx.examples.scandir.DirectoryScanner. */ public void testGetState() { System.out.println("getState"); final DirectoryScannerConfig bean = new DirectoryScannerConfig("test"); bean.setRootDirectory(System.getProperty("java.io.tmpdir")); final ResultLogManager log = new ResultLogManager(); DirectoryScanner instance = new DirectoryScanner(bean,log); ScanState expResult = STOPPED; ScanState result = instance.getState(); assertEquals(STOPPED, result); instance.scan(); result = instance.getState(); assertEquals(COMPLETED, result); }
Example #4
Source File: ScanDirConfigTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Test of getXmlConfigString method, of class com.sun.jmx.examples.scandir.ScanDirConfig. */ public void testGetXmlConfigString() throws Exception { System.out.println("getXmlConfigString"); try { final File file = File.createTempFile("testconf",".xml"); final ScanDirConfig instance = new ScanDirConfig(file.getAbsolutePath()); final ScanManagerConfig bean = new ScanManagerConfig("testGetXmlConfigString"); final DirectoryScannerConfig dir = new DirectoryScannerConfig("tmp"); dir.setRootDirectory(file.getParent()); bean.putScan(dir); instance.setConfiguration(bean); System.out.println("Expected: " + XmlConfigUtils.toString(bean)); System.out.println("Received: " + instance.getConfiguration().toString()); assertEquals(XmlConfigUtils.toString(bean), instance.getConfiguration().toString()); } catch (Exception x) { x.printStackTrace(); throw x; } }
Example #5
Source File: ScanManager.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
private void applyConfiguration(ScanManagerConfig bean) throws IOException, JMException { if (bean == null) return; if (!sequencer.tryAcquire()) { throw new IllegalStateException("Can't acquire lock"); } try { unregisterScanners(); final DirectoryScannerConfig[] scans = bean.getScanList(); if (scans == null) return; for (DirectoryScannerConfig scan : scans) { addDirectoryScanner(scan); } log.setConfig(bean.getInitialResultLogConfig()); } finally { sequencer.release(); } }
Example #6
Source File: ScanDirConfig.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
public DirectoryScannerConfig addDirectoryScanner(String name, String dir, String filePattern, long sizeExceedsMaxBytes, long sinceLastModified) { final DirectoryScannerConfig scanner = new DirectoryScannerConfig(name); scanner.setRootDirectory(dir); if (filePattern!=null||sizeExceedsMaxBytes>0||sinceLastModified>0) { final FileMatch filter = new FileMatch(); filter.setFilePattern(filePattern); filter.setSizeExceedsMaxBytes(sizeExceedsMaxBytes); if (sinceLastModified > 0) filter.setLastModifiedBefore(new Date(new Date().getTime() -sinceLastModified)); scanner.addIncludeFiles(filter); } synchronized (this) { config.putScan(scanner); status = MODIFIED; } LOG.fine("config: "+config); sendNotification(NOTIFICATION_MODIFIED); return scanner; }
Example #7
Source File: DirectoryScannerTest.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Test of getState method, of class com.sun.jmx.examples.scandir.DirectoryScanner. */ public void testGetState() { System.out.println("getState"); final DirectoryScannerConfig bean = new DirectoryScannerConfig("test"); bean.setRootDirectory(System.getProperty("java.io.tmpdir")); final ResultLogManager log = new ResultLogManager(); DirectoryScanner instance = new DirectoryScanner(bean,log); ScanState expResult = STOPPED; ScanState result = instance.getState(); assertEquals(STOPPED, result); instance.scan(); result = instance.getState(); assertEquals(COMPLETED, result); }
Example #8
Source File: ScanDirConfigTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * Test of load method, of class com.sun.jmx.examples.scandir.ScanDirConfig. */ public void testLoad() throws Exception { System.out.println("load"); final File file = File.createTempFile("testconf",".xml"); final ScanDirConfig instance = new ScanDirConfig(file.getAbsolutePath()); final ScanManagerConfig bean = new ScanManagerConfig("testLoad"); final DirectoryScannerConfig dir = new DirectoryScannerConfig("tmp"); dir.setRootDirectory(file.getParent()); bean.putScan(dir); XmlConfigUtils.write(bean,new FileOutputStream(file),false); instance.load(); assertEquals(bean,instance.getConfiguration()); bean.removeScan(dir.getName()); XmlConfigUtils.write(bean,new FileOutputStream(file),false); assertNotSame(bean,instance.getConfiguration()); instance.load(); assertEquals(bean,instance.getConfiguration()); }
Example #9
Source File: DirectoryScannerTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
/** * Test of getState method, of class com.sun.jmx.examples.scandir.DirectoryScanner. */ public void testGetState() { System.out.println("getState"); final DirectoryScannerConfig bean = new DirectoryScannerConfig("test"); bean.setRootDirectory(System.getProperty("java.io.tmpdir")); final ResultLogManager log = new ResultLogManager(); DirectoryScanner instance = new DirectoryScanner(bean,log); ScanState expResult = STOPPED; ScanState result = instance.getState(); assertEquals(STOPPED, result); instance.scan(); result = instance.getState(); assertEquals(COMPLETED, result); }
Example #10
Source File: DirectoryScannerTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Test of getState method, of class com.sun.jmx.examples.scandir.DirectoryScanner. */ public void testGetState() { System.out.println("getState"); final DirectoryScannerConfig bean = new DirectoryScannerConfig("test"); bean.setRootDirectory(System.getProperty("java.io.tmpdir")); final ResultLogManager log = new ResultLogManager(); DirectoryScanner instance = new DirectoryScanner(bean,log); ScanState expResult = STOPPED; ScanState result = instance.getState(); assertEquals(STOPPED, result); instance.scan(); result = instance.getState(); assertEquals(COMPLETED, result); }
Example #11
Source File: ScanDirConfigTest.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Test of load method, of class com.sun.jmx.examples.scandir.ScanDirConfig. */ public void testLoad() throws Exception { System.out.println("load"); final File file = File.createTempFile("testconf",".xml"); final ScanDirConfig instance = new ScanDirConfig(file.getAbsolutePath()); final ScanManagerConfig bean = new ScanManagerConfig("testLoad"); final DirectoryScannerConfig dir = new DirectoryScannerConfig("tmp"); dir.setRootDirectory(file.getParent()); bean.putScan(dir); XmlConfigUtils.write(bean,new FileOutputStream(file),false); instance.load(); assertEquals(bean,instance.getConfiguration()); bean.removeScan(dir.getName()); XmlConfigUtils.write(bean,new FileOutputStream(file),false); assertNotSame(bean,instance.getConfiguration()); instance.load(); assertEquals(bean,instance.getConfiguration()); }
Example #12
Source File: DirectoryScannerTest.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Test of getState method, of class com.sun.jmx.examples.scandir.DirectoryScanner. */ public void testGetState() { System.out.println("getState"); final DirectoryScannerConfig bean = new DirectoryScannerConfig("test"); bean.setRootDirectory(System.getProperty("java.io.tmpdir")); final ResultLogManager log = new ResultLogManager(); DirectoryScanner instance = new DirectoryScanner(bean,log); ScanState expResult = STOPPED; ScanState result = instance.getState(); assertEquals(STOPPED, result); instance.scan(); result = instance.getState(); assertEquals(COMPLETED, result); }
Example #13
Source File: DirectoryScannerTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Test of getState method, of class com.sun.jmx.examples.scandir.DirectoryScanner. */ public void testGetState() { System.out.println("getState"); final DirectoryScannerConfig bean = new DirectoryScannerConfig("test"); bean.setRootDirectory(System.getProperty("java.io.tmpdir")); final ResultLogManager log = new ResultLogManager(); DirectoryScanner instance = new DirectoryScanner(bean,log); ScanState expResult = STOPPED; ScanState result = instance.getState(); assertEquals(STOPPED, result); instance.scan(); result = instance.getState(); assertEquals(COMPLETED, result); }
Example #14
Source File: ScanDirConfigTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Test of getXmlConfigString method, of class com.sun.jmx.examples.scandir.ScanDirConfig. */ public void testGetXmlConfigString() throws Exception { System.out.println("getXmlConfigString"); try { final File file = File.createTempFile("testconf",".xml"); final ScanDirConfig instance = new ScanDirConfig(file.getAbsolutePath()); final ScanManagerConfig bean = new ScanManagerConfig("testGetXmlConfigString"); final DirectoryScannerConfig dir = new DirectoryScannerConfig("tmp"); dir.setRootDirectory(file.getParent()); bean.putScan(dir); instance.setConfiguration(bean); System.out.println("Expected: " + XmlConfigUtils.toString(bean)); System.out.println("Received: " + instance.getConfiguration().toString()); assertEquals(XmlConfigUtils.toString(bean), instance.getConfiguration().toString()); } catch (Exception x) { x.printStackTrace(); throw x; } }
Example #15
Source File: ScanDirConfig.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public DirectoryScannerConfig addDirectoryScanner(String name, String dir, String filePattern, long sizeExceedsMaxBytes, long sinceLastModified) { final DirectoryScannerConfig scanner = new DirectoryScannerConfig(name); scanner.setRootDirectory(dir); if (filePattern!=null||sizeExceedsMaxBytes>0||sinceLastModified>0) { final FileMatch filter = new FileMatch(); filter.setFilePattern(filePattern); filter.setSizeExceedsMaxBytes(sizeExceedsMaxBytes); if (sinceLastModified > 0) filter.setLastModifiedBefore(new Date(new Date().getTime() -sinceLastModified)); scanner.addIncludeFiles(filter); } synchronized (this) { config.putScan(scanner); status = MODIFIED; } LOG.fine("config: "+config); sendNotification(NOTIFICATION_MODIFIED); return scanner; }
Example #16
Source File: ScanDirConfig.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
public DirectoryScannerConfig addDirectoryScanner(String name, String dir, String filePattern, long sizeExceedsMaxBytes, long sinceLastModified) { final DirectoryScannerConfig scanner = new DirectoryScannerConfig(name); scanner.setRootDirectory(dir); if (filePattern!=null||sizeExceedsMaxBytes>0||sinceLastModified>0) { final FileMatch filter = new FileMatch(); filter.setFilePattern(filePattern); filter.setSizeExceedsMaxBytes(sizeExceedsMaxBytes); if (sinceLastModified > 0) filter.setLastModifiedBefore(new Date(new Date().getTime() -sinceLastModified)); scanner.addIncludeFiles(filter); } synchronized (this) { config.putScan(scanner); status = MODIFIED; } LOG.fine("config: "+config); sendNotification(NOTIFICATION_MODIFIED); return scanner; }
Example #17
Source File: ScanDirConfigTest.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Test of getXmlConfigString method, of class com.sun.jmx.examples.scandir.ScanDirConfig. */ public void testGetXmlConfigString() throws Exception { System.out.println("getXmlConfigString"); try { final File file = File.createTempFile("testconf",".xml"); final ScanDirConfig instance = new ScanDirConfig(file.getAbsolutePath()); final ScanManagerConfig bean = new ScanManagerConfig("testGetXmlConfigString"); final DirectoryScannerConfig dir = new DirectoryScannerConfig("tmp"); dir.setRootDirectory(file.getParent()); bean.putScan(dir); instance.setConfiguration(bean); System.out.println("Expected: " + XmlConfigUtils.toString(bean)); System.out.println("Received: " + instance.getConfiguration().toString()); assertEquals(XmlConfigUtils.toString(bean), instance.getConfiguration().toString()); } catch (Exception x) { x.printStackTrace(); throw x; } }
Example #18
Source File: ScanDirConfigTest.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Test of load method, of class com.sun.jmx.examples.scandir.ScanDirConfig. */ public void testLoad() throws Exception { System.out.println("load"); final File file = File.createTempFile("testconf",".xml"); final ScanDirConfig instance = new ScanDirConfig(file.getAbsolutePath()); final ScanManagerConfig bean = new ScanManagerConfig("testLoad"); final DirectoryScannerConfig dir = new DirectoryScannerConfig("tmp"); dir.setRootDirectory(file.getParent()); bean.putScan(dir); XmlConfigUtils.write(bean,new FileOutputStream(file),false); instance.load(); assertEquals(bean,instance.getConfiguration()); bean.removeScan(dir.getName()); XmlConfigUtils.write(bean,new FileOutputStream(file),false); assertNotSame(bean,instance.getConfiguration()); instance.load(); assertEquals(bean,instance.getConfiguration()); }
Example #19
Source File: ScanManager.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private void applyConfiguration(ScanManagerConfig bean) throws IOException, JMException { if (bean == null) return; if (!sequencer.tryAcquire()) { throw new IllegalStateException("Can't acquire lock"); } try { unregisterScanners(); final DirectoryScannerConfig[] scans = bean.getScanList(); if (scans == null) return; for (DirectoryScannerConfig scan : scans) { addDirectoryScanner(scan); } log.setConfig(bean.getInitialResultLogConfig()); } finally { sequencer.release(); } }
Example #20
Source File: DirectoryScannerTest.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Test of getState method, of class com.sun.jmx.examples.scandir.DirectoryScanner. */ public void testGetState() { System.out.println("getState"); final DirectoryScannerConfig bean = new DirectoryScannerConfig("test"); bean.setRootDirectory(System.getProperty("java.io.tmpdir")); final ResultLogManager log = new ResultLogManager(); DirectoryScanner instance = new DirectoryScanner(bean,log); ScanState expResult = STOPPED; ScanState result = instance.getState(); assertEquals(STOPPED, result); instance.scan(); result = instance.getState(); assertEquals(COMPLETED, result); }
Example #21
Source File: ScanDirConfig.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public DirectoryScannerConfig addDirectoryScanner(String name, String dir, String filePattern, long sizeExceedsMaxBytes, long sinceLastModified) { final DirectoryScannerConfig scanner = new DirectoryScannerConfig(name); scanner.setRootDirectory(dir); if (filePattern!=null||sizeExceedsMaxBytes>0||sinceLastModified>0) { final FileMatch filter = new FileMatch(); filter.setFilePattern(filePattern); filter.setSizeExceedsMaxBytes(sizeExceedsMaxBytes); if (sinceLastModified > 0) filter.setLastModifiedBefore(new Date(new Date().getTime() -sinceLastModified)); scanner.addIncludeFiles(filter); } synchronized (this) { config.putScan(scanner); status = MODIFIED; } LOG.fine("config: "+config); sendNotification(NOTIFICATION_MODIFIED); return scanner; }
Example #22
Source File: ScanDirConfigTest.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Test of getXmlConfigString method, of class com.sun.jmx.examples.scandir.ScanDirConfig. */ public void testGetXmlConfigString() throws Exception { System.out.println("getXmlConfigString"); try { final File file = File.createTempFile("testconf",".xml"); final ScanDirConfig instance = new ScanDirConfig(file.getAbsolutePath()); final ScanManagerConfig bean = new ScanManagerConfig("testGetXmlConfigString"); final DirectoryScannerConfig dir = new DirectoryScannerConfig("tmp"); dir.setRootDirectory(file.getParent()); bean.putScan(dir); instance.setConfiguration(bean); System.out.println("Expected: " + XmlConfigUtils.toString(bean)); System.out.println("Received: " + instance.getConfiguration().toString()); assertEquals(XmlConfigUtils.toString(bean), instance.getConfiguration().toString()); } catch (Exception x) { x.printStackTrace(); throw x; } }
Example #23
Source File: ScanDirConfigTest.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Test of load method, of class com.sun.jmx.examples.scandir.ScanDirConfig. */ public void testLoad() throws Exception { System.out.println("load"); final File file = File.createTempFile("testconf",".xml"); final ScanDirConfig instance = new ScanDirConfig(file.getAbsolutePath()); final ScanManagerConfig bean = new ScanManagerConfig("testLoad"); final DirectoryScannerConfig dir = new DirectoryScannerConfig("tmp"); dir.setRootDirectory(file.getParent()); bean.putScan(dir); XmlConfigUtils.write(bean,new FileOutputStream(file),false); instance.load(); assertEquals(bean,instance.getConfiguration()); bean.removeScan(dir.getName()); XmlConfigUtils.write(bean,new FileOutputStream(file),false); assertNotSame(bean,instance.getConfiguration()); instance.load(); assertEquals(bean,instance.getConfiguration()); }
Example #24
Source File: ScanManager.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
private void applyConfiguration(ScanManagerConfig bean) throws IOException, JMException { if (bean == null) return; if (!sequencer.tryAcquire()) { throw new IllegalStateException("Can't acquire lock"); } try { unregisterScanners(); final DirectoryScannerConfig[] scans = bean.getScanList(); if (scans == null) return; for (DirectoryScannerConfig scan : scans) { addDirectoryScanner(scan); } log.setConfig(bean.getInitialResultLogConfig()); } finally { sequencer.release(); } }
Example #25
Source File: DirectoryScannerTest.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
/** * Test of getState method, of class com.sun.jmx.examples.scandir.DirectoryScanner. */ public void testGetState() { System.out.println("getState"); final DirectoryScannerConfig bean = new DirectoryScannerConfig("test"); bean.setRootDirectory(System.getProperty("java.io.tmpdir")); final ResultLogManager log = new ResultLogManager(); DirectoryScanner instance = new DirectoryScanner(bean,log); ScanState expResult = STOPPED; ScanState result = instance.getState(); assertEquals(STOPPED, result); instance.scan(); result = instance.getState(); assertEquals(COMPLETED, result); }
Example #26
Source File: ScanDirConfigTest.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Test of load method, of class com.sun.jmx.examples.scandir.ScanDirConfig. */ public void testLoad() throws Exception { System.out.println("load"); final File file = File.createTempFile("testconf",".xml"); final ScanDirConfig instance = new ScanDirConfig(file.getAbsolutePath()); final ScanManagerConfig bean = new ScanManagerConfig("testLoad"); final DirectoryScannerConfig dir = new DirectoryScannerConfig("tmp"); dir.setRootDirectory(file.getParent()); bean.putScan(dir); XmlConfigUtils.write(bean,new FileOutputStream(file),false); instance.load(); assertEquals(bean,instance.getConfiguration()); bean.removeScan(dir.getName()); XmlConfigUtils.write(bean,new FileOutputStream(file),false); assertNotSame(bean,instance.getConfiguration()); instance.load(); assertEquals(bean,instance.getConfiguration()); }
Example #27
Source File: DirectoryScanner.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Constructs a new {@code DirectoryScanner}. * <p>This constructor is * package protected, and this MBean cannot be created by a remote * client, because it needs a reference to the {@link ResultLogManager}, * which cannot be provided from remote. * </p> * <p>This is a conscious design choice: {@code DirectoryScanner} MBeans * are expected to be completely managed (created, registered, unregistered) * by the {@link ScanManager} which does provide this reference. * </p> * * @param config This {@code DirectoryScanner} configuration. * @param logManager The info log manager with which to log the info * records. * @throws IllegalArgumentException if one of the parameter is null, or if * the provided {@code config} doesn't have its {@code name} set, * or if the {@link DirectoryScannerConfig#getRootDirectory * root directory} provided in the {@code config} is not acceptable * (not provided or not found or not readable, etc...). **/ public DirectoryScanner(DirectoryScannerConfig config, ResultLogManager logManager) throws IllegalArgumentException { if (logManager == null) throw new IllegalArgumentException("log=null"); if (config == null) throw new IllegalArgumentException("config=null"); if (config.getName() == null) throw new IllegalArgumentException("config.name=null"); broadcaster = new NotificationBroadcasterSupport(); // Clone the config: ensure data encapsulation. // this.config = XmlConfigUtils.xmlClone(config); // Checks that the provided root directory is valid. // Throws IllegalArgumentException if it isn't. // rootFile = validateRoot(config.getRootDirectory()); // Initialize the Set<Action> for which this DirectoryScanner // is configured. // if (config.getActions() == null) actions = Collections.emptySet(); else actions = EnumSet.copyOf(Arrays.asList(config.getActions())); this.logManager = logManager; }
Example #28
Source File: ScanDirConfigTest.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Test of addDirectoryScanner method, of class * com.sun.jmx.examples.scandir.ScanDirConfig. */ public void testAddDirectoryScanner() throws IOException { System.out.println("addDirectoryScanner"); System.out.println("save"); final File file = File.createTempFile("testconf",".xml"); final ScanDirConfig instance = new ScanDirConfig(file.getAbsolutePath()); final ScanManagerConfig bean = new ScanManagerConfig("testSave"); final DirectoryScannerConfig dir = new DirectoryScannerConfig("tmp"); dir.setRootDirectory(file.getParent()); FileMatch filter = new FileMatch(); filter.setFilePattern(".*"); dir.setIncludeFiles(new FileMatch[] { filter }); instance.setConfiguration(bean); instance.addDirectoryScanner(dir.getName(), dir.getRootDirectory(), filter.getFilePattern(), filter.getSizeExceedsMaxBytes(), 0); instance.save(); final ScanManagerConfig loaded = new XmlConfigUtils(file.getAbsolutePath()).readFromFile(); assertNotNull(loaded.getScan(dir.getName())); assertEquals(dir,loaded.getScan(dir.getName())); assertEquals(instance.getConfiguration(),loaded); assertEquals(instance.getConfiguration().getScan(dir.getName()),dir); }
Example #29
Source File: ScanDirConfigTest.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Test of addDirectoryScanner method, of class * com.sun.jmx.examples.scandir.ScanDirConfig. */ public void testAddDirectoryScanner() throws IOException { System.out.println("addDirectoryScanner"); System.out.println("save"); final File file = File.createTempFile("testconf",".xml"); final ScanDirConfig instance = new ScanDirConfig(file.getAbsolutePath()); final ScanManagerConfig bean = new ScanManagerConfig("testSave"); final DirectoryScannerConfig dir = new DirectoryScannerConfig("tmp"); dir.setRootDirectory(file.getParent()); FileMatch filter = new FileMatch(); filter.setFilePattern(".*"); dir.setIncludeFiles(new FileMatch[] { filter }); instance.setConfiguration(bean); instance.addDirectoryScanner(dir.getName(), dir.getRootDirectory(), filter.getFilePattern(), filter.getSizeExceedsMaxBytes(), 0); instance.save(); final ScanManagerConfig loaded = new XmlConfigUtils(file.getAbsolutePath()).readFromFile(); assertNotNull(loaded.getScan(dir.getName())); assertEquals(dir,loaded.getScan(dir.getName())); assertEquals(instance.getConfiguration(),loaded); assertEquals(instance.getConfiguration().getScan(dir.getName()),dir); }
Example #30
Source File: ScanDirConfigTest.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Test of addDirectoryScanner method, of class * com.sun.jmx.examples.scandir.ScanDirConfig. */ public void testAddDirectoryScanner() throws IOException { System.out.println("addDirectoryScanner"); System.out.println("save"); final File file = File.createTempFile("testconf",".xml"); final ScanDirConfig instance = new ScanDirConfig(file.getAbsolutePath()); final ScanManagerConfig bean = new ScanManagerConfig("testSave"); final DirectoryScannerConfig dir = new DirectoryScannerConfig("tmp"); dir.setRootDirectory(file.getParent()); FileMatch filter = new FileMatch(); filter.setFilePattern(".*"); dir.setIncludeFiles(new FileMatch[] { filter }); instance.setConfiguration(bean); instance.addDirectoryScanner(dir.getName(), dir.getRootDirectory(), filter.getFilePattern(), filter.getSizeExceedsMaxBytes(), 0); instance.save(); final ScanManagerConfig loaded = new XmlConfigUtils(file.getAbsolutePath()).readFromFile(); assertNotNull(loaded.getScan(dir.getName())); assertEquals(dir,loaded.getScan(dir.getName())); assertEquals(instance.getConfiguration(),loaded); assertEquals(instance.getConfiguration().getScan(dir.getName()),dir); }