ReturningAttributesWidget extends AbstractWidget { public static String[] stringToArray( String s ) { if ( s == null ) { return null; } else { List<String> attributeList = new ArrayList<String>(); StringBuffer temp = new StringBuffer(); for ( int i = 0; i < s.length(); i++ ) { char c = s.charAt( i ); if ( ( c >= 'a' && c <= 'z' ) || ( c >= 'A' && c <= 'Z' ) || ( c >= '0' && c <= '9' ) || c == '-' || c == '.' || c == ';' || c == '_' || c == '*' || c == '+' || c == '@' || c == '=' ) { temp.append( c ); } else { if ( temp.length() > 0 ) { attributeList.add( temp.toString() ); temp = new StringBuffer(); } } } if ( temp.length() > 0 ) { attributeList.add( temp.toString() ); } return ( String[] ) attributeList.toArray( new String[attributeList.size()] ); } } ReturningAttributesWidget( IBrowserConnection browserConnection, String[] initialReturningAttributes );  ReturningAttributesWidget(); void createWidget( Composite parent ); void setBrowserConnection( IBrowserConnection browserConnection ); void setInitialReturningAttributes( String[] initialReturningAttributes ); void setEnabled( boolean b ); String[] getReturningAttributes(); void saveDialogSettings(); void setFocus(); static String[] stringToArray( String s );  }
@Test public void testStringToArrayNull() { String[] attributes = ReturningAttributesWidget.stringToArray( null ); assertNull( attributes ); }
@Test public void testStringToArrayEmpty() { String[] attributes = ReturningAttributesWidget.stringToArray( "" ); assertNotNull( attributes ); assertArrayEquals( new String[0], attributes ); }
@Test public void testStringToArrayNoAttrs() { String[] attributes = ReturningAttributesWidget.stringToArray( "1.1" ); assertNotNull( attributes ); assertArrayEquals( new String[] { "1.1" }, attributes ); }
@Test public void testStringToArraySingleAttribute() { String[] attributes = ReturningAttributesWidget.stringToArray( "cn" ); assertNotNull( attributes ); assertArrayEquals( new String[] { "cn" }, attributes ); }
@Test public void testStringToArrayStingleAttributeWithTrailingWhitespace() { String[] attributes = ReturningAttributesWidget.stringToArray( " cn\t " ); assertNotNull( attributes ); assertArrayEquals( new String[] { "cn" }, attributes ); }
@Test public void testStringToArrayStingleAttributeWithTrailingCommas() { String[] attributes = ReturningAttributesWidget.stringToArray( " , ,cn,," ); assertNotNull( attributes ); assertArrayEquals( new String[] { "cn" }, attributes ); }
@Test public void testStringToArrayMultipleAttributes() { String[] attributes = ReturningAttributesWidget.stringToArray( "cn, sn uid" ); assertNotNull( attributes ); assertArrayEquals( new String[] { "cn", "sn", "uid" }, attributes ); }
@Test public void testStringToArrayMultiplwWithAllUserAndOperationalAttributes() { String[] attributes = ReturningAttributesWidget.stringToArray( "cn, sn uid, * +" ); assertNotNull( attributes ); assertArrayEquals( new String[] { "cn", "sn", "uid", "*", "+" }, attributes ); }
@Test public void testStringToArrayMultipleAttributesWithOptions() { String[] attributes = ReturningAttributesWidget.stringToArray( "cn, sn;lang-de;lang-en uid" ); assertNotNull( attributes ); assertArrayEquals( new String[] { "cn", "sn;lang-de;lang-en", "uid" }, attributes ); }
@Test public void testStringToArrayMultipleAttributesAsOid() { String[] attributes = ReturningAttributesWidget.stringToArray( "2.5.4.3, 2.5.4.4 0.9.2342.19200300.100.1.1" ); assertNotNull( attributes ); assertArrayEquals( new String[] { "2.5.4.3", "2.5.4.4", "0.9.2342.19200300.100.1.1" }, attributes ); }
@Test public void testStringToArrayMultipleAttributesWithUnderscore() { String[] attributes = ReturningAttributesWidget.stringToArray( "cn, s_n u_i_d" ); assertNotNull( attributes ); assertArrayEquals( new String[] { "cn", "s_n", "u_i_d" }, attributes ); }
@Test public void testStringToArrayMultipleAttributesWithRangeOption() { String[] attributes = ReturningAttributesWidget.stringToArray( "cn, member;Range=0-* objectClass" ); assertNotNull( attributes ); assertArrayEquals( new String[] { "cn", "member;Range=0-*", "objectClass" }, attributes ); }