@Override
    public List<NodeEvent> refresh() {
        Properties originalProperties = PropertiesUtils.loadProperties(file);
        List<String> nameList = PropertiesUtils.loadNameList(originalProperties, getPrefix());
        Properties properties = new Properties();
        for (String n : nameList) {
            String url = originalProperties.getProperty(n + ".url");
            String username = originalProperties.getProperty(n + ".username");
            String password = originalProperties.getProperty(n + ".password");
            if (url == null || url.isEmpty()) {
                LOG.warn(n + ".url is EMPTY! IGNORE!");
                continue;
            } else {
                properties.setProperty(n + ".url", url);
            }
            if (username == null || username.isEmpty()) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug(n + ".username is EMPTY. Maybe you should check the config.");
                }
            } else {
                properties.setProperty(n + ".username", username);
            }
            if (password == null || password.isEmpty()) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug(n + ".password is EMPTY. Maybe you should check the config.");
                }
            } else {
                properties.setProperty(n + ".password", password);
            }
        }

        List<NodeEvent> events = NodeEvent.getEventsByDiffProperties(getProperties(), properties);
        if (events != null && !events.isEmpty()) {
            LOG.info(events.size() + " different(s) detected.");
            setProperties(properties);
        }
        return events;
    }
@Test
    public void testRefresh() {
        String file = "/com/alibaba/druid/pool/ha/ha-with-prefix-datasource.properties";
        FileNodeListener listener = new FileNodeListener();
        listener.setFile(file);
        listener.setPrefix("prefix1");
        List<NodeEvent> list = listener.refresh();

        Properties properties = listener.getProperties();
        assertEquals(3, properties.size());
        assertEquals("jdbc:derby:memory:foo1;create=true", properties.getProperty("prefix1.foo.url"));

        assertEquals(1, list.size());
        NodeEvent event = list.get(0);
        assertEquals(NodeEventTypeEnum.ADD, event.getType());
        assertEquals("prefix1.foo", event.getNodeName());
        assertEquals("jdbc:derby:memory:foo1;create=true", event.getUrl());
    }