Java Code Examples for com.sun.jmx.examples.scandir.config.FileMatch

The following examples show how to use com.sun.jmx.examples.scandir.config.FileMatch. These examples are extracted from open source projects. 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
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 2
Source Project: TencentKona-8   Source File: ScanDirConfig.java    License: GNU General Public License v2.0 6 votes vote down vote up
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 3
Source Project: jdk8u60   Source File: ScanDirConfig.java    License: GNU General Public License v2.0 6 votes vote down vote up
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 4
Source Project: openjdk-jdk8u   Source File: ScanDirConfig.java    License: GNU General Public License v2.0 6 votes vote down vote up
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 5
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 6
Source Project: jdk8u-jdk   Source File: ScanDirConfig.java    License: GNU General Public License v2.0 6 votes vote down vote up
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 Project: hottub   Source File: ScanDirConfig.java    License: GNU General Public License v2.0 6 votes vote down vote up
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 8
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 9
Source Project: openjdk-8   Source File: ScanDirConfig.java    License: GNU General Public License v2.0 6 votes vote down vote up
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 10
Source Project: jdk8u_jdk   Source File: ScanDirConfig.java    License: GNU General Public License v2.0 6 votes vote down vote up
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 11
Source Project: jdk8u-jdk   Source File: ScanDirConfig.java    License: GNU General Public License v2.0 6 votes vote down vote up
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 12
Source Project: jdk8u-dev-jdk   Source File: ScanDirConfig.java    License: GNU General Public License v2.0 6 votes vote down vote up
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 13
/**
 * 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 14
/**
 * 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 15
Source Project: jdk8u60   Source File: ScanDirConfigTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 16
/**
 * 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 17
/**
 * 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 18
Source Project: jdk8u-jdk   Source File: ScanDirConfigTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 19
Source Project: hottub   Source File: ScanDirConfigTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 20
/**
 * 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 21
Source Project: openjdk-8   Source File: ScanDirConfigTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 22
Source Project: jdk8u_jdk   Source File: ScanDirConfigTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 23
Source Project: jdk8u-jdk   Source File: ScanDirConfigTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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
/**
 * 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);
}