com.sun.jmx.examples.scandir.config.ScanManagerConfig Java Examples
The following examples show how to use
com.sun.jmx.examples.scandir.config.ScanManagerConfig.
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 jdk8u-dev-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 #2
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 #3
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 #4
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 #5
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 #6
Source File: ScanDirConfigTest.java From openjdk-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 #7
Source File: ScanManager.java From openjdk-jdk8u-backup 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 #8
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 #9
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 #10
Source File: ScanManager.java From TencentKona-8 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 #11
Source File: ScanDirConfigTest.java From jdk8u60 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: ScanManager.java From openjdk-8 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 #13
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 #14
Source File: ScanDirConfigTest.java From openjdk-jdk8u 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: ScanDirConfigTest.java From openjdk-jdk8u-backup 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 #16
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 #17
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 #18
Source File: ScanDirConfigTest.java From openjdk-jdk8u 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: ScanDirConfigTest.java From openjdk-8-source 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 #20
Source File: ScanManager.java From jdk8u-dev-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 #21
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 #22
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 #23
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 #24
Source File: ScanManager.java From hottub with GNU General Public License v2.0 | 5 votes |
public void applyCurrentResultLogConfig(boolean toMemory) throws IOException, JMException { final ScanManagerConfig bean = config.getConfiguration(); bean.setInitialResultLogConfig(log.getConfig()); config.setConfiguration(bean); if (toMemory==false) config.save(); }
Example #25
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 #26
Source File: ScanDirConfig.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
public void setConfiguration(ScanManagerConfig config) { synchronized (this) { if (config == null) { this.config = null; return; } if (configname == null) configname = config.getName(); this.config = config.copy(configname); status = MODIFIED; } sendNotification(NOTIFICATION_MODIFIED); }
Example #27
Source File: ScanManager.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public void applyCurrentResultLogConfig(boolean toMemory) throws IOException, JMException { final ScanManagerConfig bean = config.getConfiguration(); bean.setInitialResultLogConfig(log.getConfig()); config.setConfiguration(bean); if (toMemory==false) config.save(); }
Example #28
Source File: ScanDirConfig.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public void setConfiguration(ScanManagerConfig config) { synchronized (this) { if (config == null) { this.config = null; return; } if (configname == null) configname = config.getName(); this.config = config.copy(configname); status = MODIFIED; } sendNotification(NOTIFICATION_MODIFIED); }
Example #29
Source File: ScanDirConfigTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Test of save method, of class com.sun.jmx.examples.scandir.ScanDirConfig. */ public void testSave() throws Exception { System.out.println("save"); final File file = File.createTempFile("testconf",".xml"); final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); final ScanManagerMXBean manager = ScanManager.register(mbs); try { final ScanDirConfigMXBean instance = manager.createOtherConfigurationMBean("testSave",file.getAbsolutePath()); assertTrue(mbs.isRegistered( ScanManager.makeScanDirConfigName("testSave"))); final ScanManagerConfig bean = new ScanManagerConfig("testSave"); final DirectoryScannerConfig dir = new DirectoryScannerConfig("tmp"); dir.setRootDirectory(file.getParent()); bean.putScan(dir); instance.setConfiguration(bean); instance.save(); final ScanManagerConfig loaded = new XmlConfigUtils(file.getAbsolutePath()).readFromFile(); assertEquals(instance.getConfiguration(),loaded); assertEquals(bean,loaded); instance.getConfiguration().removeScan("tmp"); instance.save(); assertNotSame(loaded,instance.getConfiguration()); final ScanManagerConfig loaded2 = new XmlConfigUtils(file.getAbsolutePath()).readFromFile(); assertEquals(instance.getConfiguration(),loaded2); } finally { manager.close(); mbs.unregisterMBean(ScanManager.SCAN_MANAGER_NAME); } final ObjectName all = new ObjectName(ScanManager.SCAN_MANAGER_NAME.getDomain()+":*"); assertEquals(0,mbs.queryNames(all,null).size()); }
Example #30
Source File: ScanDirConfigTest.java From jdk8u-dev-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); }