@@ -0,0 +1,3365 @@
+package org.opennms.web.element;%0A%0Aimport java.sql.Connection;%0Aimport java.sql.SQLException;%0Aimport java.util.Properties;%0A%0Aimport javax.sql.DataSource;%0A%0Aimport org.opennms.core.resource.Vault;%0Aimport org.opennms.core.resource.db.DbConnectionFactory;%0Aimport org.opennms.netmgt.dao.db.PopulatedTemporaryDatabaseTestCase;%0A%0Apublic class NetworkElementFactoryTest extends PopulatedTemporaryDatabaseTestCase %7B%0A    @Override%0A    protected void setUp() throws Exception %7B%0A        setSetupIpLike(true);%0A        %0A        super.setUp();%0A        %0A        Vault.setDbConnectionFactory(new DataSourceDbConnectionFactory(getDataSource()));%0A    %7D%0A    %0A    public void testGetNodesWithIpLikeOneInterface() throws Exception %7B%0A        jdbcTemplate.update(%22INSERT INTO node (nodeId, nodeCreateTime, nodeType) VALUES (1, now(), 'A')%22);%0A        jdbcTemplate.update(%22INSERT INTO ipInterface (nodeId, ipAddr, isManaged) VALUES (1, '1.1.1.1', 'M')%22);%0A        %0A        assertEquals(%22node count in DB%22, 1, jdbcTemplate.queryForInt(%22SELECT count(*) FROM node%22));%0A        assertEquals(%22ipInterface count in DB%22, 1, jdbcTemplate.queryForInt(%22SELECT count(*) FROM ipInterface%22));%0A        %0A        Node%5B%5D nodes = NetworkElementFactory.getNodesWithIpLike(%22*.*.*.*%22);%0A        assertEquals(%22node count%22, 1, nodes.length);%0A    %7D%0A    %0A    // bug introduced in revision 2932%0A    public void testGetNodesWithIpLikeTwoInterfaces() throws Exception %7B%0A        jdbcTemplate.update(%22INSERT INTO node (nodeId, nodeCreateTime, nodeType) VALUES (1, now(), 'A')%22);%0A        jdbcTemplate.update(%22INSERT INTO ipInterface (nodeId, ipAddr, isManaged) VALUES (1, '1.1.1.1', 'M')%22);%0A        jdbcTemplate.update(%22INSERT INTO ipInterface (nodeId, ipAddr, isManaged) VALUES (1, '1.1.1.2', 'M')%22);%0A        %0A        assertEquals(%22node count in DB%22, 1, jdbcTemplate.queryForInt(%22SELECT count(*) FROM node%22));%0A        assertEquals(%22ipInterface count in DB%22, 2, jdbcTemplate.queryForInt(%22SELECT count(*) FROM ipInterface%22));%0A%0A        Node%5B%5D nodes = NetworkElementFactory.getNodesWithIpLike(%22*.*.*.*%22);%0A        assertEquals(%22node count%22, 1, nodes.length);%0A    %7D%0A    %0A    public class DataSourceDbConnectionFactory implements DbConnectionFactory %7B%0A        private DataSource m_dataSource;%0A%0A        public DataSourceDbConnectionFactory(DataSource dataSource) %7B%0A            m_dataSource = dataSource;%0A        %7D%0A        %0A        public void destroy() throws SQLException %7B%0A            throw new UnsupportedOperationException(%22not implemented%22);%0A        %7D%0A%0A        public Connection getConnection() throws SQLException %7B%0A            return m_dataSource.getConnection();%0A        %7D%0A%0A        public void init(String dbUrl, String dbDriver) throws ClassNotFoundException, SQLException %7B%0A            throw new UnsupportedOperationException(%22not implemented%22);%0A        %7D%0A%0A        public void init(String dbUrl, String dbDriver, String username, String password) throws ClassNotFoundException, SQLException %7B%0A            throw new UnsupportedOperationException(%22not implemented%22);%0A        %7D%0A%0A        public void init(String dbUrl, String dbDriver, Properties properties) throws ClassNotFoundException, SQLException %7B%0A            throw new UnsupportedOperationException(%22not implemented%22);%0A        %7D%0A%0A        public void releaseConnection(Connection connection) throws SQLException %7B%0A            connection.close();%0A        %7D%0A        %0A    %7D%0A%7D%0A

Add tests for NetworkElementFactory.getNodesWithIpLike with multiple interfaces on the same node. This uses the new iplike functionality in PopulatedTemporaryDatabaseTestCase