/** 
 * 
 * Copyright 2004 Hiram Chirino
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at 
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and 
 * limitations under the License. 
 * 
 **/
package org.activemq.security.jassjacc;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import junit.framework.TestCase;

/**
 * @version $Revision: 1.1.1.1 $
 */
public class PropertiesConfigLoaderTest extends TestCase {

	public void testConfigLoading() throws IOException {
		InputStream s = getClass().getResourceAsStream("security.properties");
		Properties p = new Properties();
		p.load(s);
		s.close();
		
		PropertiesConfigLoader loader = new PropertiesConfigLoader("localhost", p);
		BrokerSecurityConfig brokerConfig = loader.getBrokerSecurityConfig();
		assertNotNull(brokerConfig);
		assertEquals("localhost", brokerConfig.getBrokerName());
		assertTrue(brokerConfig.getConnectRoles().contains("admins"));
		assertTrue(brokerConfig.getConnectRoles().contains("traders"));
		assertTrue(brokerConfig.getConnectRoles().contains("brokers"));
		assertTrue(brokerConfig.getConnectRoles().contains("guests"));
		
		DestinationSecurityConfig[] destinationSecurityConfigs = loader.getDestinationSecurityConfigs();
		assertEquals(4, destinationSecurityConfigs.length);		
	}
}
