### Question:
StringUtil { public static final int toInt(String str, int defaultValue) { int value = defaultValue; if ( str == null || str.length() <= 0 ) { return value; } try { value = Integer.parseInt(str); } catch (NumberFormatException e) { value = defaultValue; } return value; }  static final String substring(String line, String start, String end); static final String substringR(String line, String start, String end); static final String concat(Object ... value ); static final int toInt(String str, int defaultValue); static final float toFloat(String str, float defaultValue); static final boolean checkNotEmpty(String str); static final void padStringRight(StringBuilder buf, String str, int length); static final String bytesToHexString(byte[] bytes); static final byte[] hexStringToBytes(String hexString); static final String[] splitMachineId(String machineId); static final Locale parseLocale(String languageTag, Locale defaultLocale); static final boolean checkValidEmail(String emailAddress); static String encryptSHA1(String data); static String encryptMD5(String data);  }### Answer:
@Test public void testToInt1() { int value = StringUtil.toInt("1", 1); assertEquals(1, value); }
@Test public void testToInt2() { int value = StringUtil.toInt("1a", 0); assertEquals(0, value); }