FileDocCategorySizeDatePackage
Support_Configuration.javaAPI DocAndroid 1.5 API16373Wed May 06 22:41:06 BST 2009tests.support

Support_Configuration

public class Support_Configuration extends Object
This class is responsible for providing the dynamic names and addresses for the java.net classes. There are two directories which need to be placed on an ftp server and an http server which should accompany this source. The ftp-files have to be placed on an ftp server and have to be the root of a user jcltest with password jclpass. The testres files must be available on an HTTP server and the name and location can be configured below.

Fields Summary
public static String
DomainAddress
public static String
WebName
public static final String
HomeAddress
public static String
TestResourcesDir
public static final String
TestResources
public static String
HomeAddressResponse
public static String
HomeAddressSoftware
public static String
ProxyServerTestHost
public static String
SocksServerTestHost
public static int
SocksServerTestPort
public static String
UnresolvedIP
public static byte[]
nonLocalAddressBytes
public static String
InetTestAddress
public static String
InetTestIP
public static byte[]
InetTestAddr
public static String
InetTestAddress2
public static String
InetTestIP2
public static byte[]
InetTestCaddr
public static int
InetTestHashcode
public static final String
HomeAddress6
public static String
IPv6GlobalAddressJcl4
public static String
ProxyServerTestHostIPv6
public static String
InetTestIP6
public static String
InetTestIP6LO
public static String
ResolvedNotExistingHost
public static String
SpecialInetTestAddress
An address that resolves to more than one IP address so that the getAllByName test has something to test.
public static String
testURL
public static String
hTTPURLwExpiration
public static String
hTTPURLwLastModified
public static String
hTTPURLyahoo
public static String
hTTPURLgoogle
public static String
testContentEncoding
public static int
SpecialInetTestAddressNumber
public static String
InetAlias1
InetAlias1 and InetAlias2 must be different host names that resolve to the same IP address.
public static String
InetAlias2
public static String
FTPTestAddress
public static String
URLConnectionLastModifiedString
public static long
URLConnectionLastModified
public static long
URLConnectionDate
public static boolean
RunCommTests
public static String
Port1
public static String
Port2
static Hashtable
props
Constructors Summary
Methods Summary
static voidload(java.io.InputStream in, java.util.Hashtable result)

        int NONE = 0, SLASH = 1, UNICODE = 2, CONTINUE = 3, DONE = 4, IGNORE = 5;
        int mode = NONE, unicode = 0, count = 0, nextChar;
        StringBuffer key = new StringBuffer(), value = new StringBuffer(), buffer = key;
        boolean firstChar = true;

        while ((nextChar = in.read()) != -1) {
            if (mode == UNICODE) {
                int digit = Character.digit((char) nextChar, 16);
                if (digit >= 0) {
                    unicode = (unicode << 4) + digit;
                    if (++count < 4) {
                        continue;
                    }
                }
                mode = NONE;
                buffer.append((char) unicode);
                if (nextChar != '\n") {
                    continue;
                }
            }
            if (mode == SLASH) {
                mode = NONE;
                switch (nextChar) {
                case '\r":
                    mode = CONTINUE; // Look for a following \n
                    continue;
                case '\n":
                    mode = IGNORE; // Ignore whitespace on the next line
                    continue;
                case 'b":
                    nextChar = '\b";
                    break;
                case 'f":
                    nextChar = '\f";
                    break;
                case 'n":
                    nextChar = '\n";
                    break;
                case 'r":
                    nextChar = '\r";
                    break;
                case 't":
                    nextChar = '\t";
                    break;
                case 'u":
                    mode = UNICODE;
                    unicode = count = 0;
                    continue;
                }
            } else {
                switch (nextChar) {
                case '#":
                case '!":
                    if (firstChar) {
                        while ((nextChar = in.read()) != -1) {
                            if (nextChar == '\r" || nextChar == '\n") {
                                break;
                            }
                        }
                        continue;
                    }
                    break;
                case '\n":
                    if (mode == CONTINUE) { // Part of a \r\n sequence
                        mode = IGNORE; // Ignore whitespace on the next line
                        continue;
                    }
                    // fall into the next case
                case '\r":
                    mode = NONE;
                    firstChar = true;
                    if (key.length() > 0 || buffer == value) {
                        result.put(key.toString(), value.toString());
                    }
                    key.setLength(0);
                    value.setLength(0);
                    buffer = key;
                    continue;
                case '\\":
                    mode = SLASH;
                    continue;
                case ':":
                case '=":
                    if (buffer == key) {
                        buffer = value;
                        continue;
                    }
                    break;
                }
                char c = (char) nextChar;
                if ((c >= 0x1c && c <= 0x20) || (c >= 0x9 && c <= 0xd)) {
                    if (mode == CONTINUE) {
                        mode = IGNORE;
                    }
                    if (buffer.length() == 0 || mode == IGNORE) {
                        continue;
                    }
                    if (buffer == key) {
                        mode = DONE;
                        continue;
                    }
                }
                if (mode == IGNORE || mode == CONTINUE) {
                    mode = NONE;
                }
            }
            firstChar = false;
            if (mode == DONE) {
                buffer = value;
                mode = NONE;
            }
            buffer.append((char) nextChar);
        }
        if (key.length() > 0 || buffer == value) {
            result.put(key.toString(), value.toString());
        }
    
static voidloadProperties()

     
        loadProperties();
        HomeAddress = WebName + DomainAddress;
        TestResources = HomeAddress + TestResourcesDir;
    
        InputStream in = null;
        Hashtable<String, String> props = new Hashtable<String, String>();

        String iniName = System.getProperty("test.ini.file", "JCLAuto.ini");
        if (System.getProperty("test.comm") != null) {
            RunCommTests = true;
        }

        try {
            in = new FileInputStream(iniName);
        } catch (IOException e) {
        } catch (Exception e) {
            System.out.println("SupportConfiguration.loadProperties()");
            System.out.println(e);
            e.printStackTrace();
        }
        if (in == null) {
            try {
                Class<?> cl = Class
                        .forName("com.ibm.support.Support_Configuration");
                in = cl.getResourceAsStream(iniName);
            } catch (ClassNotFoundException e) {
            }
        }
        try {
            if (in != null) {
                load(in, props);
            }
        } catch (IOException e) {
        }
        if (props.size() == 0) {
            return;
        }
        String value;

        value = props.get("DomainAddress");
        if (value != null) {
            DomainAddress = value;
        }

        value = props.get("WebName");
        if (value != null) {
            WebName = value;
        }

        value = props.get("TestResourcesDir");
        if (value != null) {
            TestResourcesDir = value;
        }
        value = props.get("HomeAddressResponse");
        if (value != null) {
            HomeAddressResponse = value;
        }

        value = props.get("HomeAddressSoftware");
        if (value != null) {
            HomeAddressSoftware = value;
        }

        value = props.get("ProxyServerTestHost");
        if (value != null) {
            ProxyServerTestHost = value;
        }

        value = props.get("SocksServerTestHost");
        if (value != null) {
            SocksServerTestHost = value;
        }

        value = props.get("SocksServerTestPort");
        if (value != null) {
            SocksServerTestPort = Integer.parseInt(value);
        }

        value = props.get("UnresolvedIP");
        if (value != null) {
            UnresolvedIP = value;
        }

        value = props.get("InetTestAddress");
        if (value != null) {
            InetTestAddress = value;
        }

        value = props.get("InetTestIP");
        if (value != null) {
            InetTestIP = value;
            byte[] addr = new byte[4];
            int last = 0;
            try {
                for (int i = 0; i < 3; i++) {
                    int dot = InetTestIP.indexOf('.", last);
                    addr[i] = (byte) Integer.parseInt(InetTestIP.substring(
                            last, dot));
                    last = dot + 1;
                }
                addr[3] = (byte) Integer.parseInt(InetTestIP.substring(last));
                InetTestCaddr = addr;
            } catch (RuntimeException e) {
                System.out.println("Error parsing InetTestIP (" + InetTestIP
                        + ")");
                System.out.println(e);
            }
        }

        value = props.get("NonLocalAddressBytes");
        if (value != null) {
            String nonLocalAddressBytesString = value;
            byte[] addr = new byte[4];
            int last = 0;
            try {
                for (int i = 0; i < 3; i++) {
                    int dot = nonLocalAddressBytesString.indexOf('.", last);
                    addr[i] = (byte) Integer
                            .parseInt(nonLocalAddressBytesString.substring(
                                    last, dot));
                    last = dot + 1;
                }
                addr[3] = (byte) Integer.parseInt(nonLocalAddressBytesString
                        .substring(last));
                nonLocalAddressBytes = addr;
            } catch (RuntimeException e) {
                System.out.println("Error parsing NonLocalAddressBytes ("
                        + nonLocalAddressBytesString + ")");
                System.out.println(e);
            }
        }

        value = props.get("InetTestAddress2");
        if (value != null) {
            InetTestAddress2 = value;
        }

        value = props.get("InetTestIP2");
        if (value != null) {
            InetTestIP2 = value;
        }

        value = props.get("InetTestHashcode");
        if (value != null) {
            InetTestHashcode = Integer.parseInt(value);
        }

        value = props.get("SpecialInetTestAddress");
        if (value != null) {
            SpecialInetTestAddress = value;
        }

        value = props.get("SpecialInetTestAddressNumber");
        if (value != null) {
            SpecialInetTestAddressNumber = Integer.parseInt(value);
        }

        value = props.get("FTPTestAddress");
        if (value != null) {
            FTPTestAddress = value;
        }

        value = props.get("URLConnectionLastModifiedString");
        if (value != null) {
            URLConnectionLastModifiedString = value;
        }

        value = props.get("URLConnectionLastModified");
        if (value != null) {
            URLConnectionLastModified = Long.parseLong(value);
        }

        value = props.get("URLConnectionDate");
        if (value != null) {
            URLConnectionDate = Long.parseLong(value);
        }

        value = props.get("Port1");
        if (value != null) {
            Port1 = value;
        }

        value = props.get("Port2");
        if (value != null) {
            Port2 = value;
        }

        value = props.get("InetTestIP6");
        if (value != null) {
            InetTestIP6 = value;
        }

        value = props.get("InetTestIP6LO");
        if (value != null) {
            InetTestIP6LO = value;
        }

        value = props.get("ProxyServerTestHostIPv6");
        if (value != null) {
            ProxyServerTestHostIPv6 = value;
        }

        value = props.get("ResolvedNotExistingHost");
        if (value != null) {
            ResolvedNotExistingHost = value;
        }

        value = props.get("InetAlias1");
        if (value != null) {
            InetAlias1 = value;
        }

        value = props.get("InetAlias2");
        if (value != null) {
            InetAlias2 = value;
        }

        value = props.get("IPv6GlobalAddressJcl4");
        if (value != null) {
            IPv6GlobalAddressJcl4 = value;
        }