//
// This file is part of the OpenNMS(R) Application.
//
// OpenNMS(R) is Copyright (C) 2005 The OpenNMS Group, Inc.  All rights reserved.
// OpenNMS(R) is a derivative work, containing both original code, included code and modified
// code that was published under the GNU General Public License. Copyrights for modified 
// and included code are below.
//
// OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
//
// Original code base Copyright (C) 1999-2001 Oculan Corp.  All rights reserved.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// For more information contact:
// OpenNMS Licensing       <license@opennms.org>
//     http://www.opennms.org/
//     http://www.opennms.com/
//

package org.opennms.netmgt.config;

import java.io.InputStreamReader;
import java.io.Reader;

import junit.framework.TestCase;

import org.opennms.netmgt.mock.MockDatabase;
import org.opennms.netmgt.mock.MockNetwork;

public class CollectdConfigFactoryTest extends TestCase {
	
	private CollectdConfigFactory m_factory;

	protected void setUp() throws Exception {
		super.setUp();
		
		MockNetwork network = new MockNetwork();
		
		MockDatabase db = new MockDatabase();
		db.populate(network);
		
		DataSourceFactory.setInstance(db);
		
		

		Reader rdr = new InputStreamReader(getClass().getResourceAsStream("/org/opennms/netmgt/config/collectd-testdata.xml"));
		m_factory = new CollectdConfigFactory(rdr, "localhost", false);
		rdr.close();
		
	}

	protected void tearDown() throws Exception {
		// TODO Auto-generated method stub
		super.tearDown();
	}
	
	public void testGetName() {
		String pkgName = "example1";
		CollectdPackage wpkg = m_factory.getPackage(pkgName);
		assertNotNull(wpkg);
		assertEquals(pkgName, wpkg.getName());
	}

}

@@ -418,24 +418,105 @@
 up, Inc.%0A//%0A
+// Modifications:%0A//%0A// 2008 Feb 10: Simplify setUp() a bit. - dj@opennms.org%0A//%0A
 // Original 
@@ -1451,17 +1451,16 @@
 com/%0A//%0A
-%0A
 package 
@@ -1491,42 +1491,8 @@
 g;%0A%0A
-import java.io.InputStreamReader;%0A
 impo
@@ -1633,16 +1633,64 @@
 Network;
+%0Aimport org.opennms.test.ConfigurationTestUtils;
 %0A%0Apublic
@@ -1741,19 +1741,21 @@
 tCase %7B%0A
-%09%0A%09
+%0A    
 private 
@@ -1788,17 +1788,34 @@
 ctory;%0A%0A
-%09
+    @Override%0A    
 protecte
@@ -1848,18 +1848,24 @@
 ption %7B%0A
-%09%09
+        
 super.se
@@ -1867,29 +1867,33 @@
 er.setUp();%0A
-%09%09%0A%09%09
+%0A        
 MockNetwork 
@@ -1921,21 +1921,25 @@
 work();%0A
-%09%09%0A%09%09
+%0A        
 MockData
@@ -1968,18 +1968,24 @@
 base();%0A
-%09%09
+        
 db.popul
@@ -1998,21 +1998,25 @@
 twork);%0A
-%09%09%0A%09%09
+%0A        
 DataSour
@@ -2046,17 +2046,17 @@
 b);%0A
-%09%09%0A%09%09%0A%0A%09%09
+%0A        
 Read
@@ -2068,89 +2068,59 @@
 r = 
-new InputStreamReader(getClass().getResourceAsStream(%22/org/opennms/netmgt/config/
+ConfigurationTestUtils.getReaderForResource(this, %22
 coll
@@ -2138,21 +2138,44 @@
 ta.xml%22)
-)
 ;%0A
-%09%09
+        try %7B%0A            
 m_factor
@@ -2234,31 +2234,88 @@
 e);%0A
-%09%09rdr.close();%0A%09%09%0A%09%7D%0A%0A%09
+        %7D finally %7B%0A            rdr.close();%0A        %7D%0A    %7D%0A%0A    @Override%0A    
 prot
@@ -2355,18 +2355,24 @@
 ption %7B%0A
-%09%09
+        
 // TODO 
@@ -2398,18 +2398,24 @@
 od stub%0A
-%09%09
+        
 super.te
@@ -2428,14 +2428,19 @@
 ();%0A
-%09%7D%0A%09%0A%09
+    %7D%0A%0A    
 publ
@@ -2463,18 +2463,24 @@
 ame() %7B%0A
-%09%09
+        
 String p
@@ -2500,18 +2500,24 @@
 mple1%22;%0A
-%09%09
+        
 Collectd
@@ -2562,18 +2562,24 @@
 gName);%0A
-%09%09
+        
 assertNo
@@ -2595,10 +2595,16 @@
 g);%0A
-%09%09
+        
 asse
@@ -2642,9 +2642,12 @@
 ));%0A
-%09
+    
 %7D%0A%0A%7D

Simplify setUp() a bit.