public static String getNSSLibDir() throws Exception { Properties props = System.getProperties(); String osName = props.getProperty("os.name"); if (osName.startsWith("Win")) { osName = "Windows"; NSPR_PREFIX = "lib"; } String osid = osName + "-" + props.getProperty("os.arch") + "-" + props.getProperty("sun.arch.data.model"); String ostype = osMap.get(osid); if (ostype == null) { System.out.println("Unsupported OS, skipping: " + osid); return null; // throw new Exception("Unsupported OS " + osid); } if (ostype.length() == 0) { System.out.println("NSS not supported on this platform, skipping test"); return null; } String libdir = NSS_BASE + SEP + "lib" + SEP + ostype + SEP; System.setProperty("pkcs11test.nss.libdir", libdir); return libdir; }
/** Print all system property keys and values. */ public static void printSystemProperties() { Properties p = System.getProperties(); for (Object key : p.keySet()) System.out.println(key + ": " + p.getProperty(key.toString())); }
/** Class for testing this. */ private static class TestClass implements Cloneable { private String _String = "This string is my name."; private String[] _StringArray = {"one", "two", "three"}; private int _int = Integer.MIN_VALUE; private Integer _Integer = new Integer(Integer.MAX_VALUE); private double _double = Double.MIN_VALUE; private Double _Double = new Double(Double.MAX_VALUE); private Properties _Properties = System.getProperties(); private File _File = new File("/"); private Object _Object = new Font("Monospaced", Font.PLAIN, 12); private JButton _button = new JButton("I'm a button!"); public void setName(String string) { _String = string; } public String getName() { return _String; } public void setStringArray(String[] array) { _StringArray = array; } public String[] getStringArray() { return _StringArray; } public void setInt(int val) { _int = val; } public int getInt() { return _int; } public void setInteger(Integer val) { _Integer = val; } public Integer getInteger() { return _Integer; } public void setDoub(double val) { _double = val; } public double getDoub() { return _double; } public void setDouble(Double val) { _Double = val; } public Double getDouble() { return _Double; } public void setProperties(Properties props) { _Properties = props; } public Properties getProperties() { return _Properties; } public void setFile(File f) { _File = f; } public File getFile() { return _File; } public void setButton(JButton button) { _button = button; } public JButton getButton() { return _button; } public void setObject(Object o) { _Object = o; } public Object getObject() { return _Object; } public Object clone() { try { return super.clone(); } catch (CloneNotSupportedException ex) { return null; } } }