/*
 * Java SMPP API
 * Copyright (C) 1998 - 2002 by Oran Kelly
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library 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
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 * 
 * A copy of the LGPL can be viewed at http://www.gnu.org/copyleft/lesser.html
 * Java SMPP API author: orank@users.sf.net
 * Java SMPP API Homepage: http://smppapi.sourceforge.net/
 * $Id$
 */
package ie.omk.smpp.util;

import junit.framework.TestCase;

public class TestAPIConfig extends TestCase {

    public TestAPIConfig(String name) {
	super (name);
    }

    public void testAPIConfig() {
	APIConfig c = APIConfig.getInstance();
	assertNotNull(c.getProperty(APIConfig.TCP_SOCKET_TIMEOUT));
	assertEquals(30000, c.getInt(APIConfig.TCP_SOCKET_TIMEOUT));
    }
}

@@ -1023,16 +1023,84 @@
 .util;%0A%0A
+import java.lang.reflect.Field;%0Aimport java.lang.reflect.Modifier;%0A%0A
 import j
@@ -1124,16 +1124,16 @@
 stCase;%0A
-
 %0Apublic 
@@ -1273,169 +1273,830 @@
  %7B%0A%09
-APIConfig c = APIConfig.getInstance();%0A%09assertNotNull(c.getProperty(APIConfig.TCP_SOCKET_TIMEOUT));%0A%09assertEquals(30000, c.getInt(APIConfig.TCP_SOCKET_TIMEOUT));
+// The test values should match those in the example properties file in%0A%09// the CVS resources directory.%0A%09try %7B%0A%09    APIConfig c = APIConfig.getInstance();%0A%0A%09    int propCount = 0;%0A%09    Class apiClass = c.getClass();%0A%09    Field%5B%5D f = apiClass.getFields();%0A%09    for (int i = 0; i %3C f.length; i++) %7B%0A%09%09int mod = f%5Bi%5D.getModifiers();%0A%09%09if (Modifier.isPublic(mod)%0A%09%09%09&& Modifier.isStatic(mod)%0A%09%09%09&& Modifier.isFinal(mod)%0A%09%09%09&& f%5Bi%5D.getType() == String.class) %7B%0A%0A%09%09    try %7B%0A%09%09%09String fn = f%5Bi%5D.get(c).toString();%0A%09%09%09c.getProperty(fn);%0A%09%09%09propCount++;%0A%09%09    %7D catch (PropertyNotFoundException x) %7B%0A%09%09    %7D%0A%09%09%7D%0A%09    %7D%0A%0A%09    if (propCount %3C 1) %7B%0A%09%09// Probably no properties file.%0A%09%09//pass(%22No properties were loaded. Maybe no props file found?%22);%0A%09    %7D%0A%09%7D catch (Exception x) %7B%0A%09    fail(%22Exception caught: %22 + x.toString());%0A%09%7D
 %0A   

Test APIConfig against the CVS properties file.