src_fm_fc_ms_ff stringlengths 43 86.8k | target stringlengths 20 276k |
|---|---|
SearchResultEntryImpl extends AbstractResponse implements SearchResultEntry { @Override public boolean equals( Object obj ) { if ( this == obj ) { return true; } if ( !super.equals( obj ) ) { return false; } if ( !( obj instanceof SearchResultEntry ) ) { return false; } SearchResultEntry resp = ( SearchResultEntry ) ob... | @Test public void testEqualsSameObject() { SearchResultEntryImpl resp = new SearchResultEntryImpl( 5 ); assertTrue( resp.equals( resp ), "the same object should be equal" ); } |
SearchResultEntryImpl extends AbstractResponse implements SearchResultEntry { @Override public int hashCode() { int hash = 37; if ( entry != null ) { hash = hash * 17 + entry.hashCode(); } hash = hash * 17 + super.hashCode(); return hash; } SearchResultEntryImpl(); SearchResultEntryImpl( final int id ); @Override Entr... | @Test public void testHashCodeSameObject() { SearchResultEntryImpl resp = new SearchResultEntryImpl( 5 ); assertTrue( resp.hashCode() == resp.hashCode() ); } |
ModifyRequestImpl extends AbstractAbandonableRequest implements ModifyRequest { @Override public boolean equals( Object obj ) { if ( obj == this ) { return true; } if ( !super.equals( obj ) ) { return false; } ModifyRequest req = ( ModifyRequest ) obj; if ( name != null && req.getName() == null ) { return false; } if (... | @Test public void testEqualsSameObj() throws LdapException { ModifyRequestImpl req = getRequest(); assertTrue( req.equals( req ) ); }
@Test public void testEqualsExactCopy() throws LdapException { ModifyRequestImpl req0 = getRequest(); ModifyRequestImpl req1 = getRequest(); assertTrue( req0.equals( req1 ) ); } |
ModifyRequestImpl extends AbstractAbandonableRequest implements ModifyRequest { @Override public int hashCode() { int hash = 37; if ( name != null ) { hash = hash * 17 + name.hashCode(); } hash = hash * 17 + mods.size(); for ( int i = 0; i < mods.size(); i++ ) { hash = hash * 17 + ( ( DefaultModification ) mods.get( i ... | @Test public void testHashCodeSameObj() throws LdapException { ModifyRequestImpl req = getRequest(); assertTrue( req.hashCode() == req.hashCode() ); }
@Test public void testHashCodeExactCopy() throws LdapException { ModifyRequestImpl req0 = getRequest(); ModifyRequestImpl req1 = getRequest(); assertTrue( req0.hashCode(... |
OpaqueExtendedResponse extends AbstractExtendedResponse { @Override public boolean equals( Object obj ) { if ( obj == this ) { return true; } if ( !super.equals( obj ) ) { return false; } if ( !( obj instanceof OpaqueExtendedResponse ) ) { return false; } OpaqueExtendedResponse extendedRequest = ( OpaqueExtendedRespons... | @Test public void testEqualsSameObj() { ExtendedResponse resp = createStub(); assertTrue( resp.equals( resp ) ); }
@Test public void testEqualsExactCopy() { ExtendedResponse resp0 = createStub(); ExtendedResponse resp1 = createStub(); assertTrue( resp0.equals( resp1 ) ); assertTrue( resp1.equals( resp0 ) ); }
@Test pub... |
OpaqueExtendedResponse extends AbstractExtendedResponse { @Override public int hashCode() { int hash = 37; hash = hash * 17 + super.hashCode(); if ( responseName != null ) { hash = hash * 17 + responseName.hashCode(); } if ( responseValue != null ) { for ( byte b : responseValue ) { hash = hash * 17 + b; } } return has... | @Test public void testHashCodeSameObj() { ExtendedResponse resp = createStub(); assertTrue( resp.hashCode() == resp.hashCode() ); }
@Test public void testHashCodeExactCopy() { ExtendedResponse resp0 = createStub(); ExtendedResponse resp1 = createStub(); assertTrue( resp0.hashCode() == resp1.hashCode() ); } |
ReferralImpl implements Referral { @Override public boolean equals( Object obj ) { if ( obj == this ) { return true; } if ( obj instanceof Referral ) { Collection<String> refs = ( ( Referral ) obj ).getLdapUrls(); if ( refs.size() != urls.size() ) { return false; } Iterator<String> list = urls.iterator(); while ( list.... | @Test public void testEqualsSameObject() { ReferralImpl refs = new ReferralImpl(); assertTrue( refs.equals( refs ), "equals method should work for the same object" ); }
@Test public void testEqualsDifferentImpls() { Referral refs0 = new Referral() { public Collection<String> getLdapUrls() { return Collections.emptyList... |
ReferralImpl implements Referral { @Override public int hashCode() { int hash = 37; hash = hash * 17 + urls.size(); for ( String url : urls ) { hash = hash + url.hashCode(); } return hash; } @Override int getReferralLength(); @Override void setReferralLength( int referralLength ); @Override Collection<String> getLdapU... | @Test public void testHashCodeSameObject() { ReferralImpl refs = new ReferralImpl(); assertTrue( refs.hashCode() == refs.hashCode() ); } |
BindResponseImpl extends AbstractResultResponse implements BindResponse { @Override public boolean equals( Object obj ) { if ( obj == this ) { return true; } if ( !( obj instanceof BindResponse ) ) { return false; } if ( !super.equals( obj ) ) { return false; } BindResponse response = ( BindResponse ) obj; byte[] creds... | @Test public void testEqualsSameObj() { BindResponseImpl resp = new BindResponseImpl( 1 ); assertTrue( resp.equals( resp ), "same object should be equal" ); }
@Test public void testEqualsNewWithSameId() { BindResponseImpl resp0 = new BindResponseImpl( 1 ); BindResponseImpl resp1 = new BindResponseImpl( 1 ); assertTrue(... |
BindResponseImpl extends AbstractResultResponse implements BindResponse { @Override public int hashCode() { int hash = 37; hash = hash * 17 + Arrays.hashCode( serverSaslCreds ); hash = hash * 17 + super.hashCode(); return hash; } BindResponseImpl(); BindResponseImpl( final int id ); @Override byte[] getServerSaslCreds... | @Test public void testHashCodeSameObj() { BindResponseImpl resp = new BindResponseImpl( 1 ); assertTrue( resp.hashCode() == resp.hashCode() ); }
@Test public void testHashCodeNewWithSameId() { BindResponseImpl resp0 = new BindResponseImpl( 1 ); BindResponseImpl resp1 = new BindResponseImpl( 1 ); assertTrue( resp1.hashC... |
AbstractResultResponse extends AbstractResponse implements ResultResponse { @Override public boolean equals( Object obj ) { if ( obj == this ) { return true; } if ( !super.equals( obj ) ) { return false; } if ( !( obj instanceof ResultResponse ) ) { return false; } ResultResponse resp = ( ResultResponse ) obj; return (... | @Test public void testEqualsSameObj() { AbstractResultResponse msg; msg = new AbstractResultResponse( 5, MessageTypeEnum.BIND_REQUEST ) { }; assertTrue( msg.equals( msg ) ); }
@Test public void testNotEqualsDiffId() { AbstractResultResponse msg0; AbstractResultResponse msg1; msg0 = new AbstractResultResponse( 5, Messag... |
AbstractMessage implements Message { @Override public boolean equals( Object obj ) { if ( obj == this ) { return true; } if ( !( obj instanceof Message ) ) { return false; } Message msg = ( Message ) obj; if ( msg.getMessageId() != id ) { return false; } if ( msg.getType() != type ) { return false; } Map<String, Contro... | @Test public void testEqualsSameObj() { AbstractMessage msg; msg = new AbstractMessage( 5, MessageTypeEnum.BIND_REQUEST ) { }; assertTrue( msg.equals( msg ) ); }
@Test public void testEqualsExactCopy() { AbstractMessage msg0; AbstractMessage msg1; msg0 = new AbstractMessage( 5, MessageTypeEnum.BIND_REQUEST ) { }; msg1 ... |
LdapResultImpl implements LdapResult { @Override public boolean equals( Object obj ) { if ( obj == this ) { return true; } if ( !( obj instanceof LdapResult ) ) { return false; } LdapResult result = ( LdapResult ) obj; if ( referral == null && result.getReferral() != null ) { return false; } if ( result.getReferral() =... | @Test public void testEqualsSameObj() { LdapResultImpl r0 = new LdapResultImpl(); assertTrue( r0.equals( r0 ), "same object should be equal" ); }
@Test public void testEqualsDefaultCopy() { LdapResultImpl r0 = new LdapResultImpl(); LdapResultImpl r1 = new LdapResultImpl(); assertTrue( r0.equals( r1 ), "default copy sho... |
LdapResultImpl implements LdapResult { @Override public int hashCode() { int hash = 37; if ( referral != null ) { hash = hash * 17 + referral.hashCode(); } hash = hash * 17 + resultCode.hashCode(); if ( diagnosticMessage != null ) { hash = hash * 17 + diagnosticMessage.hashCode(); } if ( matchedDn != null ) { hash = ha... | @Test public void testHashCodeSameObj() { LdapResultImpl r0 = new LdapResultImpl(); assertTrue( r0.hashCode() == r0.hashCode() ); }
@Test public void testHashCodeDefaultCopy() { LdapResultImpl r0 = new LdapResultImpl(); LdapResultImpl r1 = new LdapResultImpl(); assertTrue( r0.hashCode() == r1.hashCode() ); }
@Test publ... |
ModifyDnRequestImpl extends AbstractAbandonableRequest implements ModifyDnRequest { @Override public boolean equals( Object obj ) { if ( obj == this ) { return true; } if ( !super.equals( obj ) ) { return false; } ModifyDnRequest req = ( ModifyDnRequest ) obj; if ( name != null && req.getName() == null ) { return false... | @Test public void testEqualsExactCopy0() { ModifyDnRequestImpl req0 = getRequest(); ModifyDnRequestImpl req1 = getRequest(); assertTrue( req0.equals( req1 ) ); }
@Test public void testEqualsDiffImpl() { ModifyDnRequest req0 = new ModifyDnRequest() { public Dn getName() { try { return new Dn( "dc=admins,dc=apache,dc=org... |
ModifyDnRequestImpl extends AbstractAbandonableRequest implements ModifyDnRequest { @Override public int hashCode() { int hash = 37; if ( name != null ) { hash = hash * 17 + name.hashCode(); } hash = hash * 17 + ( deleteOldRdn ? 0 : 1 ); if ( newRdn != null ) { hash = hash * 17 + newRdn.hashCode(); } if ( newSuperior !... | @Test public void testHashCodeExactCopy0() { ModifyDnRequestImpl req0 = getRequest(); ModifyDnRequestImpl req1 = getRequest(); assertTrue( req0.hashCode() == req1.hashCode() ); } |
UndefinedNode extends AbstractExprNode { @Override public boolean isLeaf() { return false; } private UndefinedNode(); @Override boolean isLeaf(); @Override Object accept( FilterVisitor visitor ); @Override boolean isSchemaAware(); @Override String toString(); static final UndefinedNode UNDEFINED_NODE; } | @Test public void testIsLeaf() throws Exception { assertFalse( undefinedNode.isLeaf() ); } |
UndefinedNode extends AbstractExprNode { @Override public boolean isSchemaAware() { return false; } private UndefinedNode(); @Override boolean isLeaf(); @Override Object accept( FilterVisitor visitor ); @Override boolean isSchemaAware(); @Override String toString(); static final UndefinedNode UNDEFINED_NODE; } | @Test public void testIsSchemaAware() throws Exception { assertFalse( undefinedNode.isSchemaAware() ); } |
UndefinedNode extends AbstractExprNode { @Override public Object accept( FilterVisitor visitor ) { return null; } private UndefinedNode(); @Override boolean isLeaf(); @Override Object accept( FilterVisitor visitor ); @Override boolean isSchemaAware(); @Override String toString(); static final UndefinedNode UNDEFINED_N... | @Test public void testAccept() throws Exception { assertNull( undefinedNode.accept( new FilterVisitor() { public Object visit( ExprNode node ) { return null; } public boolean isPrefix() { return false; } public List<ExprNode> getOrder( BranchNode node, List<ExprNode> children ) { return null; } public boolean canVisit(... |
BranchNormalizedVisitor implements FilterVisitor { @Override public Object visit( ExprNode node ) { if ( !( node instanceof BranchNode ) ) { return null; } BranchNode branch = ( BranchNode ) node; Comparator<ExprNode> nodeComparator = new NodeComparator(); Set<ExprNode> set = new TreeSet<>( nodeComparator ); List<ExprN... | @Test public void testBranchNormalizedVisitor0() throws Exception { String filter = "(ou=Human Resources)"; ExprNode ori = FilterParser.parse( filter ); ExprNode altered = FilterParser.parse( filter ); BranchNormalizedVisitor visitor = new BranchNormalizedVisitor(); visitor.visit( altered ); assertEquals( ori.toString(... |
BranchNormalizedVisitor implements FilterVisitor { public static String getNormalizedFilter( SchemaManager schemaManager, String filter ) throws ParseException { ExprNode originalNode = FilterParser.parse( schemaManager, filter ); return getNormalizedFilter( originalNode ); } @Override Object visit( ExprNode node ); @... | @Test public void testBranchNormalizedComplex() throws Exception { String filter1 = "(&(a=A)(|(b=B)(c=C)))"; String filter2 = "(&(a=A)(|(c=C)(b=B)))"; String normalizedFilter1 = BranchNormalizedVisitor.getNormalizedFilter( null, filter1 ); String normalizedFilter2 = BranchNormalizedVisitor.getNormalizedFilter( null, fi... |
FilterParser { public static ExprNode parse( String filter ) throws ParseException { return parse( null, filter, false ); } private FilterParser(); static ExprNode parse( String filter ); static ExprNode parse( String filter, boolean relaxed ); static ExprNode parse( SchemaManager schemaManager, String filter ); stati... | @Test public void testItemFilter() throws ParseException { String str = "(ou~=people)"; SimpleNode<?> node = ( SimpleNode<?> ) FilterParser.parse( str ); assertEquals( "ou", node.getAttribute() ); assertEquals( "people", node.getValue().getString() ); assertTrue( node instanceof ApproximateNode ); String str2 = node.to... |
Oid { public static Oid fromString( String oidString ) throws DecoderException { if ( ( oidString == null ) || oidString.isEmpty() ) { throw new DecoderException( I18n.err( I18n.ERR_00003_INVALID_OID, "empty" ) ); } byte[] buffer = new byte[oidString.length()]; OidFSAState state = OidFSAState.START; int arcNbChars = 0;... | @Test public void fromString() throws DecoderException { for ( int i = 0; i < 2; i++ ) { for ( int j = 0; j < 40; j++ ) { String oidStr = i + "." + j; byte[] expected = new byte[]{ ( byte ) ( i * 40 + j ) }; byte[] oidBytes = Oid.fromString( oidStr ).toBytes(); assertTrue( Arrays.equals( expected, oidBytes ) ); } } ass... |
SubstringNode extends LeafNode { public static Pattern getRegex( String initialPattern, String[] anyPattern, String finalPattern ) { StringBuilder buf = new StringBuilder(); if ( initialPattern != null ) { buf.append( '^' ).append( Pattern.quote( initialPattern ) ); } if ( anyPattern != null ) { for ( int i = 0; i < an... | @Test public void testGetRegexpEmpty() throws Exception { Pattern pattern = SubstringNode.getRegex( "", new String[] { "" }, "" ); boolean b1 = pattern.matcher( "" ).matches(); assertTrue( b1 ); }
@Test public void testGetRegexpInitial() throws Exception { Pattern pattern = SubstringNode.getRegex( "Test", new String[] ... |
FilterEncoder { public static String format( String filterTemplate, String... values ) { if ( values == null ) { values = Strings.EMPTY_STRING_ARRAY; } MessageFormat mf = new MessageFormat( filterTemplate, Locale.ROOT ); Format[] formats = mf.getFormatsByArgumentIndex(); if ( formats.length != values.length ) { throw n... | @Test public void testFormatWithNoPlaceholdersAndCorrectArgumentCount() { assertEquals( "(cn=foo)", FilterEncoder.format( "(cn=foo)", (String[])null ) ); assertEquals( "(cn=foo)", FilterEncoder.format( "(cn=foo)", ZERO ) ); }
@Test public void testFormatWithNoPlaceholdersAndTooManyArguments() { assertThrows( IllegalArg... |
FilterEncoder { public static String encodeFilterValue( String value ) { StringBuilder sb = new StringBuilder( value.length() ); boolean escaped = false; boolean hexPair = false; char hex = '\0'; for ( int i = 0; i < value.length(); i++ ) { char ch = value.charAt( i ); switch ( ch ) { case '*': if ( escaped ) { sb.appe... | @Test public void testEncodeFilterValue() { assertEquals( "1234567890", FilterEncoder.encodeFilterValue( "1234567890" ) ); assertEquals( "\\28", FilterEncoder.encodeFilterValue( "(" ) ); assertEquals( "\\29", FilterEncoder.encodeFilterValue( ")" ) ); assertEquals( "\\2A", FilterEncoder.encodeFilterValue( "*" ) ); asser... |
PasswordUtil { public static boolean compareCredentials( byte[] receivedCredentials, byte[] storedCredentials ) { LdapSecurityConstants algorithm = findAlgorithm( storedCredentials ); if ( algorithm != null ) { PasswordDetails passwordDetails = PasswordUtil.splitCredentials( storedCredentials ); byte[] userPassword = P... | @Test public void compareCredentialTest() { assertTrue( PasswordUtil.compareCredentials( null, null ) ); assertTrue( PasswordUtil.compareCredentials( new byte[] {}, new byte[] {} ) ); assertTrue( PasswordUtil.compareCredentials( new byte[] { 0x01 }, new byte[] { 0x01 } ) ); assertFalse( PasswordUtil.compareCredentials(... |
AttributeUtils { public static void applyModification( Entry entry, Modification modification ) throws LdapException { Attribute modAttr = modification.getAttribute(); String modificationId = modAttr.getUpId(); switch ( modification.getOperation() ) { case ADD_ATTRIBUTE: Attribute modifiedAttr = entry.get( modification... | @Test public void testApplyAddModificationToEmptyEntry() throws LdapException { Entry entry = new DefaultEntry(); Attribute attr = new DefaultAttribute( "cn", "test" ); Modification modification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attr ); AttributeUtils.applyModification( entry, modification... |
CsnFactory { public Csn newInstance() { int tmpChangeCount; synchronized ( lock ) { long newTimestamp = System.currentTimeMillis(); if ( lastTimestamp == newTimestamp ) { changeCount++; } else { lastTimestamp = newTimestamp; changeCount = 0; } tmpChangeCount = changeCount; } return new Csn( lastTimestamp, tmpChangeCoun... | @Test public void testUnique() { int replicaId = 001; CsnFactory defaultCSNFactory = new CsnFactory( replicaId ); Csn[] csns = new Csn[NUM_GENERATES]; for ( int i = 0; i < NUM_GENERATES; i++ ) { csns[i] = defaultCSNFactory.newInstance(); } for ( int i = 0; i < NUM_GENERATES; i++ ) { for ( int j = i + 1; j < NUM_GENERAT... |
Csn implements Comparable<Csn> { public Csn( long timestamp, int changeCount, int replicaId, int operationNumber ) { this.timestamp = timestamp; this.replicaId = replicaId; this.operationNumber = operationNumber; this.changeCount = changeCount; sdf.setTimeZone( UTC_TIME_ZONE ); } Csn( long timestamp, int changeCount, i... | @Test public void testCSN() { synchronized ( SDF ) { long ts = System.currentTimeMillis(); Csn csn = new Csn( SDF.format( new Date( ts ) ) + "#123456#abc#654321" ); assertEquals( ts / 1000, csn.getTimestamp() / 1000 ); assertEquals( 1193046, csn.getChangeCount() ); assertEquals( 6636321, csn.getOperationNumber() ); ass... |
Csn implements Comparable<Csn> { public static boolean isValid( String value ) { if ( Strings.isEmpty( value ) ) { return false; } char[] chars = value.toCharArray(); if ( chars.length != 40 ) { return false; } for ( int pos = 0; pos < 4; pos++ ) { if ( !Chars.isDigit( chars[pos] ) ) { return false; } } switch ( chars[... | @Test public void testIsValidCsn() { assertTrue( Csn.isValid( "20100111202217.914000Z#000000#000#000000" ) ); } |
ListCursor extends AbstractCursor<E> { @Override public void close() throws IOException { if ( LOG_CURSOR.isDebugEnabled() ) { LOG_CURSOR.debug( I18n.msg( I18n.MSG_13101_CLOSING_LIST_CURSOR, this ) ); } super.close(); } ListCursor( Comparator<E> comparator, int start, List<E> list, int end ); ListCursor( int start, Li... | @Test public void testEmptyList() throws Exception { ListCursor<String> cursor = new ListCursor<String>(); cursor.close(); assertClosed( cursor, "cursor.isClosed() should return true after closing the cursor", true ); }
@Test public void testSingleElementList() throws Exception { ListCursor<String> cursor = new ListCur... |
CsnComparator extends LdapComparator<Object> { @Override public int compare( Object csnObj1, Object csnObj2 ) { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13745_COMPARING_CSN, csnObj1, csnObj2 ) ); } if ( csnObj1 == csnObj2 ) { return 0; } if ( csnObj1 == null ) { return -1; } if ( csnObj2 == null ) { ... | @Test public void testNullCSNs() { assertEquals( 0, comparator.compare( null, null ) ); Csn csn2 = new Csn( System.currentTimeMillis(), 1, 1, 1 ); assertEquals( -1, comparator.compare( null, csn2.toString() ) ); assertEquals( 1, comparator.compare( csn2.toString(), null ) ); }
@Test public void testEqualsCSNs() { long ... |
IntegerComparator extends LdapComparator<Object> implements Serializable { @Override public int compare( Object v1, Object v2 ) { if ( v1 == null ) { if ( v2 == null ) { return 0; } else { return -1; } } else if ( v2 == null ) { return 1; } if ( v1 instanceof String ) { return compare( ( String ) v1, ( String ) v2 ); }... | @Test public void testNullIntegers() { assertEquals( 0, comparator.compare( null, null ) ); String int1 = "1"; assertEquals( -1, comparator.compare( ( String ) null, int1 ) ); assertEquals( 1, comparator.compare( int1, ( String ) null ) ); }
@Test public void testBigIntegerValues() { assertEquals( -1, comparator.compar... |
CsnSidComparator extends LdapComparator<String> { public int compare( String sidStr1, String sidStr2 ) { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13744_COMPARING_CSN_SID, sidStr1, sidStr2 ) ); } if ( sidStr1 == null ) { return ( sidStr2 == null ) ? 0 : -1; } if ( sidStr2 == null ) { return 1; } int s... | @Test public void testNullSids() { assertEquals( 0, comparator.compare( null, null ) ); assertEquals( -1, comparator.compare( null, "000" ) ); assertEquals( 1, comparator.compare( "000", null ) ); }
@Test public void testEqualsSids() { assertEquals( 0, comparator.compare( "000", "000" ) ); assertEquals( 0, comparator.c... |
BitStringComparator extends LdapComparator<String> { public int compare( String bs1, String bs2 ) { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13743_COMPARING_BITSTRING, bs1, bs2 ) ); } if ( bs1 == bs2 ) { return 0; } if ( ( bs1 == null ) || ( bs2 == null ) ) { return bs1 == null ? -1 : 1; } char[] arr... | @Test public void testNullBitString() { assertEquals( 0, comparator.compare( null, null ) ); assertEquals( -1, comparator.compare( null, "0101B" ) ); assertEquals( -1, comparator.compare( null, "000B" ) ); assertEquals( 1, comparator.compare( "0101B", null ) ); assertEquals( 1, comparator.compare( "111B", null ) ); }
@... |
ByteArrayComparator extends LdapComparator<byte[]> { public int compare( byte[] b1, byte[] b2 ) { return Strings.compare( b1, b2 ); } ByteArrayComparator( String oid ); int compare( byte[] b1, byte[] b2 ); } | @Test public void testBothNull() { assertEquals( 0, new ByteArrayComparator( null ).compare( null, null ) ); }
@Test public void testB2Null() { assertEquals( 1, new ByteArrayComparator( null ).compare( new byte[0], null ) ); }
@Test public void testB1Null() { assertEquals( -1, new ByteArrayComparator( null ).compare( n... |
ObjectIdentifierFirstComponentComparator extends LdapComparator<String> { public int compare( String s1, String s2 ) { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13748_COMPARING_OBJECT_IDENTIFIER_FIRST_COMPONENT, s1, s2 ) ); } if ( s1 == null ) { return ( s2 == null ) ? 0 : -1; } if ( s2 == null ) { re... | @Test public void testNullObjectIdentifiers() { assertEquals( 0, comparator.compare( null, null ) ); String c2 = "( 1.1 FQCN org.apache.directory.SimpleComparator BYTECODE ABCDEFGHIJKLMNOPQRSTUVWXYZ+/abcdefghijklmnopqrstuvwxyz0123456789==== )"; assertEquals( -1, comparator.compare( null, c2 ) ); assertEquals( -1, compa... |
GeneralizedTime implements Comparable<GeneralizedTime> { @Override public int compareTo( GeneralizedTime other ) { return calendar.compareTo( other.calendar ); } GeneralizedTime( Date date ); GeneralizedTime( Calendar calendar ); GeneralizedTime( long timeInMillis ); GeneralizedTime( String generalizedTime ); String... | @Test public void testCompareTo() throws ParseException { String gt1 = "20080102121313,999Z"; GeneralizedTime generalizedTime1 = new GeneralizedTime( gt1 ); String gt2 = "20080102121314Z"; GeneralizedTime generalizedTime2 = new GeneralizedTime( gt2 ); String gt3 = "20080102121314,001Z"; GeneralizedTime generalizedTime3... |
WordComparator extends LdapComparator<String> { public int compare( String value, String assertion ) { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13749_COMPARING_STRING, value, assertion ) ); } if ( value == assertion ) { return 0; } if ( ( value == null ) || ( assertion == null ) ) { return ( assertio... | @Test public void testNullWordss() { assertEquals( 0, comparator.compare( null, null ) ); assertEquals( -1, comparator.compare( null, " abc " ) ); assertEquals( 1, comparator.compare( " abc def ghi ", null ) ); }
@Test public void testEqualsWords() { assertEquals( 0, comparator.compare( "abc", "abc" ) ); assertEquals( ... |
BooleanComparator extends LdapComparator<String> { public int compare( String b1, String b2 ) { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13752_COMPARING_BOOLEAN, b1, b2 ) ); } if ( b1 == b2 ) { return 0; } if ( ( b1 == null ) || ( b2 == null ) ) { return b1 == null ? -1 : 1; } boolean boolean1 = Bool... | @Test public void testNullBooleans() { assertEquals( 0, comparator.compare( null, null ) ); assertEquals( -1, comparator.compare( null, "TRUE" ) ); assertEquals( -1, comparator.compare( null, "FALSE" ) ); assertEquals( 1, comparator.compare( "TRUE", null ) ); assertEquals( 1, comparator.compare( "FALSE", null ) ); }
@T... |
TelephoneNumberComparator extends LdapComparator<String> { public int compare( String telephoneNumber1, String telephoneNumber2 ) { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13750_COMPARING_TELEPHONE_NUMBER, telephoneNumber1, telephoneNumber2 ) ); } if ( telephoneNumber1 == null ) { return ( telephone... | @Test public void testNullTelephoneNumbers() { String tel1 = null; String tel2 = null; assertEquals( 0, comparator.compare( tel1, tel2 ) ); tel2 = "abc"; assertEquals( -1, comparator.compare( tel1, tel2 ) ); String tel3 = null; assertEquals( 1, comparator.compare( tel2, tel3 ) ); }
@Test public void testEmptyTelephoneN... |
GeneralizedTime implements Comparable<GeneralizedTime> { @Override public boolean equals( Object obj ) { if ( obj instanceof GeneralizedTime ) { GeneralizedTime other = ( GeneralizedTime ) obj; return calendar.equals( other.calendar ); } else { return false; } } GeneralizedTime( Date date ); GeneralizedTime( Calendar ... | @Test public void testEquals() throws ParseException { String gt1 = "20080102121314Z"; GeneralizedTime generalizedTime1 = new GeneralizedTime( gt1 ); String gt2 = "20080102121314Z"; GeneralizedTime generalizedTime2 = new GeneralizedTime( gt2 ); String gt3 = "20080102121314,001Z"; GeneralizedTime generalizedTime3 = new ... |
NameForm extends AbstractSchemaObject { @Override public String toString() { return SchemaObjectRenderer.OPEN_LDAP_SCHEMA_RENDERER.render( this ); } NameForm( String oid ); String getStructuralObjectClassOid(); ObjectClass getStructuralObjectClass(); void setStructuralObjectClassOid( String structuralObjectClassOid ); ... | @Test public void testToString() throws Exception { String string = nameForm.toString(); assertNotNull( string ); assertTrue( string.startsWith( "nameform (" ) ); assertTrue( string.contains( " NAME " ) ); assertTrue( string.contains( "\n\tDESC " ) ); assertTrue( string.contains( "\n\tOC" ) ); assertTrue( string.contai... |
MatchingRule extends AbstractSchemaObject { @Override public String toString() { return SchemaObjectRenderer.OPEN_LDAP_SCHEMA_RENDERER.render( this ); } MatchingRule( String oid ); LdapSyntax getSyntax(); void setSyntax( LdapSyntax ldapSyntax ); String getSyntaxOid(); void setSyntaxOid( String oid ); LdapComparator<? s... | @Test public void testToString() throws Exception { String string = matchingRule.toString(); assertNotNull( string ); assertTrue( string.startsWith( "matchingrule (" ) ); assertTrue( string.contains( " NAME " ) ); assertTrue( string.contains( "\n\tDESC " ) ); assertTrue( string.contains( "\n\tSYNTAX " ) ); } |
LdapSyntax extends AbstractSchemaObject { @Override public String toString() { return SchemaObjectRenderer.OPEN_LDAP_SCHEMA_RENDERER.render( this ); } LdapSyntax( String oid ); LdapSyntax( String oid, String description ); LdapSyntax( String oid, String description, boolean isHumanReadable ); boolean isHumanReadable(... | @Test public void testToString() throws Exception { String string = ldapSyntax.toString(); assertNotNull( string ); assertTrue( string.startsWith( "ldapsyntax (" ) ); assertTrue( string.contains( "\n\tDESC " ) ); assertTrue( string.contains( "\n\tX-NOT-HUMAN-READABLE " ) ); } |
SchemaObjectRenderer { public String render( ObjectClass oc ) { StringBuilder buf = renderStartOidNamesDescObsolete( oc, "objectclass" ); renderOids( buf, "SUP", oc.getSuperiorOids() ); if ( oc.getType() != null ) { prettyPrintIndent( buf ); buf.append( oc.getType() ); prettyPrintNewLine( buf ); } renderOids( buf, "MUS... | @Test public void testOpenLdapSchemaRendererObjectClassMinimal() { String actual = SchemaObjectRenderer.OPEN_LDAP_SCHEMA_RENDERER.render( new ObjectClass( "1.2.3" ) ); String expected = "objectclass ( 1.2.3\n\tSTRUCTURAL )"; assertEquals( expected, actual ); }
@Test public void testOpenLdapSchemaRendererObjectClassSimp... |
GeneralizedTime implements Comparable<GeneralizedTime> { public Date getDate() { return calendar.getTime(); } GeneralizedTime( Date date ); GeneralizedTime( Calendar calendar ); GeneralizedTime( long timeInMillis ); GeneralizedTime( String generalizedTime ); String toGeneralizedTime(); String toGeneralizedTimeWithou... | @Test public void fractionCloseToOne() throws ParseException { GeneralizedTime close = new GeneralizedTime( "20000101000000.9994Z" ); assertThat( close.getDate(), is( equalTo( format.parse( "01/01/2000 00:00:00.999 GMT" ) ) ) ); GeneralizedTime closer = new GeneralizedTime( "20000101000000.9995Z" ); assertThat( closer.... |
MethodUtils { public static Method getAssignmentCompatibleMethod( Class<?> clazz, String candidateMethodName, Class<?>[] candidateParameterTypes ) throws NoSuchMethodException { if ( LOG.isDebugEnabled() ) { StringBuilder buf = new StringBuilder(); buf.append( "call to getAssignmentCompatibleMethod(): \n\tclazz = " ); ... | @Test public void testSameBehaviourOfStandardGetMethod() { Method m1 = null; Method m2 = null; try { m1 = TestClass.class.getMethod( "methodA", new Class[] { String.class } ); } catch ( SecurityException e ) { e.printStackTrace(); } catch ( NoSuchMethodException e ) { e.printStackTrace(); } try { m2 = MethodUtils.getAs... |
SchemaUtils { static StringBuilder renderQDescrs( StringBuilder buf, List<String> qdescrs ) { if ( ( qdescrs == null ) || qdescrs.isEmpty() ) { return buf; } if ( qdescrs.size() == 1 ) { buf.append( '\'' ).append( qdescrs.get( 0 ) ).append( '\'' ); } else { buf.append( "( " ); for ( String qdescr : qdescrs ) { buf.appe... | @Test public void testRenderQdescrs() { assertEquals( "", SchemaUtils.renderQDescrs( new StringBuilder(), ( List<String> ) null ).toString() ); assertEquals( "", SchemaUtils.renderQDescrs( new StringBuilder(), Arrays.asList( new String[] {} ) ).toString() ); assertEquals( "'name1'", SchemaUtils.renderQDescrs( new Strin... |
SchemaUtils { public static boolean isAttributeNameValid( String attributeName ) { if ( Strings.isEmpty( attributeName ) ) { return false; } boolean descr; boolean zero = false; boolean dot = false; char c = attributeName.charAt( 0 ); if ( ( ( c >= 'a' ) && ( c <= 'z' ) ) || ( ( c >= 'A' ) && ( c <= 'Z' ) ) ) { descr =... | @Test public void testIsAttributeNameValid() { assertFalse( SchemaUtils.isAttributeNameValid( null ) ); assertFalse( SchemaUtils.isAttributeNameValid( "" ) ); assertFalse( SchemaUtils.isAttributeNameValid( " " ) ); assertTrue( SchemaUtils.isAttributeNameValid( "a" ) ); assertTrue( SchemaUtils.isAttributeNameValid( "Obj... |
SchemaObjectSorter { public static Iterable<AttributeType> hierarchicalOrdered( List<AttributeType> attributeTypes ) { return new SchemaObjectIterable<>( attributeTypes, new ReferenceCallback<AttributeType>() { @Override public Collection<String> getSuperiorOids( AttributeType at ) { return Collections.singleton( at.ge... | @Test public void testSortAttributeTypesAlreadySorted() { List<AttributeType> attributeTypes = new ArrayList<AttributeType>(); addAttributeType( attributeTypes, "1.1.1", "att1", null ); addAttributeType( attributeTypes, "1.1.2", "att2", "att1" ); addAttributeType( attributeTypes, "1.1.3", "att3", "att2" ); addAttribute... |
SchemaObjectSorter { public static Iterable<ObjectClass> sortObjectClasses( List<ObjectClass> objectClasses ) { return new SchemaObjectIterable<>( objectClasses, new ReferenceCallback<ObjectClass>() { @Override public Collection<String> getSuperiorOids( ObjectClass oc ) { return oc.getSuperiorOids(); } } ); } private ... | @Test public void testSortObjectClassesAlreadySorted() { List<ObjectClass> objectClasses = new ArrayList<ObjectClass>(); addObjectClass( objectClasses, "1.2.1", "oc1" ); addObjectClass( objectClasses, "1.2.2", "OC2", "oc1" ); addObjectClass( objectClasses, "1.2.3", "oc3", "oC2" ); addObjectClass( objectClasses, "1.2.4"... |
ObjectClass extends AbstractSchemaObject { @Override public boolean equals( Object o ) { if ( !super.equals( o ) ) { return false; } if ( !( o instanceof ObjectClass ) ) { return false; } ObjectClass that = ( ObjectClass ) o; if ( objectClassType != that.objectClassType ) { return false; } if ( superiorOids.size() != t... | @Test public void testEqualsNull() throws Exception { assertFalse( objectClassA.equals( null ) ); }
@Test public void testNotEqualDiffValue() throws Exception { assertFalse( objectClassA.equals( objectClassC ) ); assertFalse( objectClassC.equals( objectClassA ) ); } |
ObjectClass extends AbstractSchemaObject { @Override public int hashCode() { int hash = h; hash = hash * 17 + objectClassType.getValue(); int tempHash = 0; for ( String oid : superiorOids ) { tempHash += oid.hashCode(); } hash = hash * 17 + tempHash; tempHash = 0; for ( String may : mayAttributeTypeOids ) { tempHash +=... | @Test public void testHashCodeReflexive() throws Exception { assertEquals( objectClassA.hashCode(), objectClassA.hashCode() ); }
@Test public void testHashCodeSymmetric() throws Exception { assertEquals( objectClassA.hashCode(), objectClassACopy.hashCode() ); assertEquals( objectClassACopy.hashCode(), objectClassA.hash... |
ObjectClass extends AbstractSchemaObject { @Override public String toString() { return SchemaObjectRenderer.OPEN_LDAP_SCHEMA_RENDERER.render( this ); } ObjectClass( String oid ); List<String> getMayAttributeTypeOids(); List<AttributeType> getMayAttributeTypes(); void addMayAttributeTypeOids( String... oids ); void addM... | @Test public void testToString() throws Exception { String string = objectClass.toString(); assertNotNull( string ); assertTrue( string.startsWith( "objectclass (" ) ); assertTrue( string.contains( " NAME " ) ); assertTrue( string.contains( "\n\tDESC " ) ); assertTrue( string.contains( "\n\tSUP " ) ); assertTrue( strin... |
Strings { public static String trimConsecutiveToOne( String str, char ch ) { if ( ( null == str ) || ( str.length() == 0 ) ) { return ""; } char[] buffer = str.toCharArray(); char[] newbuf = new char[buffer.length]; int pos = 0; boolean same = false; for ( int i = 0; i < buffer.length; i++ ) { char car = buffer[i]; if ... | @Test public void testTrimConsecutiveToOne() { String input = null; String result = null; input = "akarasulu**"; result = Strings.trimConsecutiveToOne( input, '*' ); assertEquals( "akarasulu*", result ); input = "*****akarasulu**"; result = Strings.trimConsecutiveToOne( input, '*' ); assertEquals( "*akarasulu*", result... |
OidRegistry implements Iterable<T> { public OidRegistry<T> copy() { OidRegistry<T> copy = new OidRegistry<>(); copy.byOid = new HashMap<>(); return copy; } boolean contains( String oid ); String getPrimaryName( String oid ); T getSchemaObject( String oid ); List<String> getNameSet( String oid ); Iterator<String> itera... | @Test public void testCopy() throws Exception { } |
Registries implements SchemaLoaderListener, Cloneable { @Override public Registries clone() throws CloneNotSupportedException { Registries clone = ( Registries ) super.clone(); clone.globalOidRegistry = globalOidRegistry.copy(); clone.attributeTypeRegistry = attributeTypeRegistry.copy(); clone.comparatorRegistry = comp... | @Test public void testClone() { } |
AttributeType extends AbstractSchemaObject implements Cloneable { @Override public String toString() { return SchemaObjectRenderer.OPEN_LDAP_SCHEMA_RENDERER.render( this ); } AttributeType( String oid ); boolean isSingleValued(); void setSingleValued( boolean singleValued ); boolean isUserModifiable(); void setUserModi... | @Test public void testToString() throws Exception { String string = attributeType.toString(); assertNotNull( string ); assertTrue( string.startsWith( "attributetype (" ) ); assertTrue( string.contains( " NAME " ) ); assertTrue( string.contains( "\n\tDESC " ) ); assertTrue( string.contains( "\n\tSUP " ) ); assertTrue( s... |
DitStructureRule extends AbstractSchemaObject { @Override public String toString() { return SchemaObjectRenderer.OPEN_LDAP_SCHEMA_RENDERER.render( this ); } DitStructureRule( int ruleId ); String getForm(); void setForm( String form ); int getRuleId(); void setRuleId( int ruleId ); List<Integer> getSuperRules(); void s... | @Test public void testToString() throws Exception { String string = ditStructureRule.toString(); assertNotNull( string ); assertTrue( string.startsWith( "ditstructurerule (" ) ); assertTrue( string.contains( " NAME " ) ); assertTrue( string.contains( "\n\tDESC " ) ); assertTrue( string.contains( "\n\tFORM " ) ); assert... |
NumericNormalizer extends Normalizer implements PreparedNormalizer { public Value normalize( Value value ) throws LdapException { String normalized = normalize( value.getString() ); return new Value( normalized ); } NumericNormalizer(); Value normalize( Value value ); @Override String normalize( String value ); @Overri... | @Test public void testNumericNormalizerNull() throws LdapException { Normalizer normalizer = new NumericNormalizer(); assertEquals( null, normalizer.normalize( ( String ) null ) ); }
@Test public void testNumericNormalizerEmpty() throws LdapException { Normalizer normalizer = new NumericNormalizer(); assertEquals( "", ... |
Strings { public static String listToString( List<?> list ) { if ( ( list == null ) || list.isEmpty() ) { return ""; } StringBuilder sb = new StringBuilder(); boolean isFirst = true; for ( Object elem : list ) { if ( isFirst ) { isFirst = false; } else { sb.append( ", " ); } sb.append( elem ); } return sb.toString(); }... | @Test public void testListToString() { List<String> list = new ArrayList<String>(); list.add( "elem1" ); list.add( "elem2" ); list.add( "elem3" ); assertEquals( "elem1, elem2, elem3", Strings.listToString( list ) ); } |
DeepTrimNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimNormalizer( String oid ); DeepTrimNormalizer(); @Override String normalize( String value ); @O... | @Test public void testDeepTrimNormalizerNull() throws LdapException { Normalizer normalizer = new DeepTrimNormalizer( "1.1.1" ); assertEquals( null, normalizer.normalize( ( String ) null ) ); }
@Test public void testDeepTrimNormalizerEmpty() throws LdapException { Normalizer normalizer = new DeepTrimNormalizer( "1.1.1"... |
Strings { public static String mapToString( Map<?, ?> map ) { if ( ( map == null ) || ( map.size() == 0 ) ) { return ""; } StringBuilder sb = new StringBuilder(); boolean isFirst = true; for ( Map.Entry<?, ?> entry : map.entrySet() ) { if ( isFirst ) { isFirst = false; } else { sb.append( ", " ); } sb.append( entry.get... | @Test public void testMapToString() { class Value { String name; int val; public Value( String name, int val ) { this.name = name; this.val = val; } public String toString() { return "[" + name + ", " + val + "]"; } } Map<String, Value> map = new HashMap<String, Value>(); map.put( "elem1", new Value( "name1", 1 ) ); ma... |
DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); @Override String normaliz... | @Test public void testDeepTrimToLowerNormalizerNull() throws LdapException { Normalizer normalizer = new DeepTrimToLowerNormalizer( "1.1.1" ); assertNull( normalizer.normalize( ( String ) null ) ); }
@Test public void testDeepTrimToLowerNormalizerEmpty() throws LdapException { Normalizer normalizer = new DeepTrimToLowe... |
Strings { public static String deepTrim( String str, boolean toLowerCase ) { if ( ( null == str ) || ( str.length() == 0 ) ) { return ""; } char ch; int length = str.length(); char[] newbuf = new char[length]; boolean wsSeen = false; boolean isStart = true; int pos = 0; for ( int i = 0; i < length; i++ ) { ch = str.cha... | @Test public void testDeepTrim() { assertEquals( "", Strings.deepTrim( " ", false ) ); assertEquals( "ab", Strings.deepTrim( " ab ", false ) ); assertEquals( "a b", Strings.deepTrim( " a b ", false ) ); assertEquals( "a b", Strings.deepTrim( " a b ", false ) ); assertEquals( "a b", Strings.deepTrim( " a b ", false ) );... |
Strings { public static String trim( String str ) { return isEmpty( str ) ? "" : str.trim(); } private Strings(); static String dumpBytes( byte[] buffer ); static String byteToString( byte b ); static String dumpByte( byte octet ); static char dumpHex( byte hex ); static String dumpHexPairs( byte[] buffer ); static St... | @Test public void testTrim() { assertEquals( "", Strings.trim( ( String ) null ) ); assertEquals( "", Strings.trim( "" ) ); assertEquals( "", Strings.trim( " " ) ); assertEquals( "", Strings.trim( " " ) ); assertEquals( "a", Strings.trim( "a " ) ); assertEquals( "a", Strings.trim( " a" ) ); assertEquals( "a", Strings.t... |
BooleanNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapInvalidDnException { if ( value == null ) { return null; } return Strings.upperCase( value.trim() ); } BooleanNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareStr... | @Test public void testNormalizeNullValue() throws Exception { assertNull( normalizer.normalize( null ) ); }
@Test public void testNormalizeNonNullValue() throws Exception { assertEquals( "TRUE", normalizer.normalize( "true" ) ); assertEquals( "ABC", normalizer.normalize( "aBc" ) ); assertEquals( "FALSE", normalizer.nor... |
TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } TelephoneNumberNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareStri... | @Test public void testTelephoneNumberNormalizerNull() throws LdapException { Normalizer normalizer = new TelephoneNumberNormalizer(); assertEquals( null, normalizer.normalize( ( String ) null ) ); }
@Test public void testTelephoneNumberNormalizerEmpty() throws LdapException { Normalizer normalizer = new TelephoneNumber... |
Strings { public static String trimLeft( String str ) { if ( isEmpty( str ) ) { return ""; } int start = 0; int end = str.length(); while ( ( start < end ) && ( str.charAt( start ) == ' ' ) ) { start++; } return start == 0 ? str : str.substring( start ); } private Strings(); static String dumpBytes( byte[] buffer ); s... | @Test public void testTrimLeft() { assertEquals( "", Strings.trimLeft( ( String ) null ) ); assertEquals( "", Strings.trimLeft( "" ) ); assertEquals( "", Strings.trimLeft( " " ) ); assertEquals( "", Strings.trimLeft( " " ) ); assertEquals( "a ", Strings.trimLeft( "a " ) ); assertEquals( "a", Strings.trimLeft( " a" ) );... |
SyntaxChecker extends LoadableSchemaObject { @Override public boolean equals( Object o ) { if ( !super.equals( o ) ) { return false; } return o instanceof SyntaxChecker; } protected SyntaxChecker( String oid ); protected SyntaxChecker(); boolean isValidSyntax( Object value ); void setSchemaManager( SchemaManager sche... | @Test public void testEqualsNull() throws Exception { assertFalse( objectClassA.equals( null ) ); }
@Test public void testNotEqualDiffValue() throws Exception { assertFalse( objectClassA.equals( objectClassC ) ); assertFalse( objectClassC.equals( objectClassA ) ); } |
Strings { public static String trimRight( String str ) { if ( isEmpty( str ) ) { return ""; } int length = str.length(); int end = length; while ( ( end > 0 ) && ( str.charAt( end - 1 ) == ' ' ) ) { if ( ( end > 1 ) && ( str.charAt( end - 2 ) == '\\' ) ) { break; } end--; } return end == length ? str : str.substring( 0... | @Test public void testTrimRight() { assertEquals( "", Strings.trimRight( ( String ) null ) ); assertEquals( "", Strings.trimRight( "" ) ); assertEquals( "", Strings.trimRight( " " ) ); assertEquals( "", Strings.trimRight( " " ) ); assertEquals( "a", Strings.trimRight( "a " ) ); assertEquals( " a", Strings.trimRight( " ... |
PrepareString { public static String normalize( String value ) { if ( !Normalizer.isNormalized( value, Normalizer.Form.NFKC ) ) { return Normalizer.normalize( value, Normalizer.Form.NFKC ); } else { return value; } } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String valu... | @Test public void testEscapeBackSlash() throws IOException { String result = PrepareString.normalize( "C:\\a\\b\\c" ); System.out.println( result ); } |
PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case S... | @Test public void insignificantSpacesStringInitialNull() throws InvalidCharacterException { char[] empty = null; assertEquals( " ", PrepareString.insignificantSpacesStringInitial( empty ) ); }
@Test public void insignificantSpacesStringInitialEmpty() throws InvalidCharacterException { char[] empty = new char[]{}; asser... |
Strings { public static boolean areEquals( String string, int index, String text ) { if ( ( string == null ) || ( text == null ) ) { return false; } int length1 = string.length(); int length2 = text.length(); if ( ( length1 == 0 ) || ( length1 <= index ) || ( index < 0 ) || ( length2 == 0 ) || ( length2 > ( length1 + i... | @Test public void testAreEqualsFull() { assertEquals( 6, Strings.areEquals( AZERTY, 0, "azerty" ) ); }
@Test public void testAreEqualsDiff() { assertEquals( -1, Strings.areEquals( AZERTY, 0, "Azerty" ) ); }
@Test public void testAreEqualsEmpty() { assertEquals( -1, Strings.areEquals( AZERTY, 0, "" ) ); }
@Test public v... |
PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case... | @Test public void insignificantSpacesStringFinalNull() throws InvalidCharacterException { char[] empty = null; assertEquals( " ", PrepareString.insignificantSpacesStringFinal( empty ) ); }
@Test public void insignificantSpacesStringFinalEmpty() throws InvalidCharacterException { char[] empty = new char[]{}; assertEqual... |
PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case S... | @Test public void insignificantSpacesStringAnyNull() throws InvalidCharacterException { char[] empty = null; assertEquals( " ", PrepareString.insignificantSpacesStringAny( empty ) ); }
@Test public void insignificantSpacesStringAnyEmpty() throws InvalidCharacterException { char[] empty = new char[]{}; assertEquals( " "... |
DitContentRule extends AbstractSchemaObject { @Override public String toString() { return SchemaObjectRenderer.OPEN_LDAP_SCHEMA_RENDERER.render( this ); } DitContentRule( String oid ); List<String> getAuxObjectClassOids(); void addAuxObjectClassOidOids( String oid ); void addAuxObjectClasses( ObjectClass objectClass );... | @Test public void testToString() throws Exception { String string = ditContentRule.toString(); assertNotNull( string ); assertTrue( string.startsWith( "ditcontentrule (" ) ); assertTrue( string.contains( " NAME " ) ); assertTrue( string.contains( "\n\tDESC " ) ); assertTrue( string.contains( "\n\tAUX " ) ); assertTrue(... |
MatchingRuleUse extends AbstractSchemaObject { @Override public String toString() { return SchemaObjectRenderer.OPEN_LDAP_SCHEMA_RENDERER.render( this ); } MatchingRuleUse( String oid ); List<String> getApplicableAttributeOids(); List<AttributeType> getApplicableAttributes(); void setApplicableAttributeOids( List<Strin... | @Test public void testToString() throws Exception { String string = matchingRuleUse.toString(); assertNotNull( string ); assertTrue( string.startsWith( "matchingruleuse (" ) ); assertTrue( string.contains( " NAME " ) ); assertTrue( string.contains( "\n\tDESC " ) ); assertTrue( string.contains( "\n\tAPPLIES " ) ); } |
Ava implements Externalizable, Cloneable, Comparable<Ava> { @Override public boolean equals( Object obj ) { if ( this == obj ) { return true; } if ( !( obj instanceof Ava ) ) { return false; } Ava instance = ( Ava ) obj; if ( attributeType == null ) { if ( normType == null ) { if ( instance.normType != null ) { return ... | @Test public void testEqualsAttributeEquals() throws LdapException { Ava atav1 = new Ava( schemaManager, "a", "b" ); Ava atav2 = new Ava( schemaManager, "a", "b" ); assertTrue( atav1.equals( atav2 ) ); }
@Test public void testEqualsAttributeIdSameCase() throws LdapException { Ava atav1 = new Ava( schemaManager, "a", "b... |
Ava implements Externalizable, Cloneable, Comparable<Ava> { public String getName() { return upName; } Ava(); Ava( SchemaManager schemaManager ); Ava( SchemaManager schemaManager, Ava ava ); Ava( String upType, byte[] upValue ); Ava( SchemaManager schemaManager, String upType, byte[] upValue ); Ava( SchemaManager ... | @Test public void testNormalize() throws LdapException { Ava atav = new Ava( schemaManager, " A ", "a" ); assertEquals( " A =a", atav.getName() ); } |
Rdn implements Cloneable, Externalizable, Iterable<Ava>, Comparable<Rdn> { @Override public String toString() { return upName == null ? "" : upName; } Rdn(); Rdn( SchemaManager schemaManager ); Rdn( SchemaManager schemaManager, String rdn ); Rdn( String rdn ); Rdn( SchemaManager schemaManager, String upType, String... | @Test public void testRdnNull() { assertEquals( "", new Rdn().toString() ); }
@Test public void testRdnEmpty() throws LdapException { assertEquals( "", new Rdn( "" ).toString() ); } |
Rdn implements Cloneable, Externalizable, Iterable<Ava>, Comparable<Rdn> { public String getName() { return upName; } Rdn(); Rdn( SchemaManager schemaManager ); Rdn( SchemaManager schemaManager, String rdn ); Rdn( String rdn ); Rdn( SchemaManager schemaManager, String upType, String upValue ); Rdn( String upType, ... | @Test public void testRdnSimple() throws LdapException { assertEquals( "a = b", new Rdn( "a = b" ).getName() ); }
@Test public void testRdnComposite() throws LdapException { assertEquals( "a = b + c = d", new Rdn( "a = b + c = d" ).getName() ); }
@Test public void testRdnCompositeWithSpace() throws LdapException { asse... |
Rdn implements Cloneable, Externalizable, Iterable<Ava>, Comparable<Rdn> { public Object getValue( String type ) throws LdapInvalidDnException { String normalizedType = Strings.lowerCaseAscii( Strings.trim( type ) ); if ( schemaManager != null ) { AttributeType attributeType = schemaManager.getAttributeType( normalized... | @Test public void testRdnCompositeMultivaluedAttribute() throws LdapException { Rdn rdn = new Rdn( "a =b+c=d + e=f + g =h + i =j " ); assertEquals( "b", rdn.getValue( "a" ) ); assertEquals( "d", rdn.getValue( "c" ) ); assertEquals( "f", rdn.getValue( " E " ) ); assertEquals( "h", rdn.getValue( "g" ) ); assertEquals( "j... |
Rdn implements Cloneable, Externalizable, Iterable<Ava>, Comparable<Rdn> { @Override public boolean equals( Object that ) { if ( this == that ) { return true; } Rdn rdn; if ( that instanceof String ) { try { rdn = new Rdn( schemaManager, ( String ) that ); } catch ( LdapInvalidDnException e ) { return false; } } else i... | @Test public void testRDNCompareToNull() throws LdapException { Rdn rdn1 = new Rdn( " a = b + c = d + e = f + g = h " ); Rdn rdn2 = null; assertFalse( rdn1.equals( rdn2 ) ); }
@Test public void testRDNCompareToNCS2NC() throws LdapException { Rdn rdn1 = new Rdn( " a = b + c = d + e = f + g = h " ); Rdn rdn2 = new Rdn( "... |
Oid { public static boolean isOid( String oidString ) { try { Oid.fromString( oidString ); return true; } catch ( DecoderException e ) { return false; } } private Oid( String oidString, byte[] oidBytes ); @Override boolean equals( Object other ); static Oid fromBytes( byte[] oidBytes ); static Oid fromString( String o... | @Test public void testNewOidStringBad() { assertFalse( Oid.isOid( "0" ) ); assertFalse( Oid.isOid( "1" ) ); assertFalse( Oid.isOid( "0." ) ); assertFalse( Oid.isOid( "1." ) ); assertFalse( Oid.isOid( "2." ) ); assertFalse( Oid.isOid( "2." ) ); assertFalse( Oid.isOid( "." ) ); assertFalse( Oid.isOid( "0.1.2." ) ); asser... |
Rdn implements Cloneable, Externalizable, Iterable<Ava>, Comparable<Rdn> { public String getType() { switch ( nbAvas ) { case 0: return null; case 1: return ava.getType(); default: return avas.get( 0 ).getType(); } } Rdn(); Rdn( SchemaManager schemaManager ); Rdn( SchemaManager schemaManager, String rdn ); Rdn( Stri... | @Test public void testGetType() throws LdapException { Rdn rdn = new Rdn( " a = b + b = f + g = h + c = d " ); assertEquals( "a", rdn.getNormType() ); } |
Rdn implements Cloneable, Externalizable, Iterable<Ava>, Comparable<Rdn> { public int size() { return nbAvas; } Rdn(); Rdn( SchemaManager schemaManager ); Rdn( SchemaManager schemaManager, String rdn ); Rdn( String rdn ); Rdn( SchemaManager schemaManager, String upType, String upValue ); Rdn( String upType, String... | @Test public void testGetSize() throws LdapException { Rdn rdn = new Rdn( " a = b + b = f + g = h + c = d " ); assertEquals( 4, rdn.size() ); }
@Test public void testGetSize0() { Rdn rdn = new Rdn(); assertEquals( 0, rdn.size() ); } |
Rdn implements Cloneable, Externalizable, Iterable<Ava>, Comparable<Rdn> { public static Object unescapeValue( String value ) { if ( Strings.isEmpty( value ) ) { return ""; } char[] chars = value.toCharArray(); if ( ( chars[0] == '\"' ) && ( chars[chars.length - 1] == '\"' ) ) { return new String( chars, 1, chars.lengt... | @Test public void testUnescapeValueHexa() { byte[] res = ( byte[] ) Rdn.unescapeValue( "#fF" ); assertEquals( "0xFF ", Strings.dumpBytes( res ) ); res = ( byte[] ) Rdn.unescapeValue( "#0123456789aBCDEF" ); assertEquals( "0x01 0x23 0x45 0x67 0x89 0xAB 0xCD 0xEF ", Strings.dumpBytes( res ) ); }
@Test public void testUnes... |
Rdn implements Cloneable, Externalizable, Iterable<Ava>, Comparable<Rdn> { public static String escapeValue( String value ) { if ( Strings.isEmpty( value ) ) { return ""; } char[] chars = value.toCharArray(); char[] newChars = new char[chars.length * 3]; int pos = 0; for ( int i = 0; i < chars.length; i++ ) { switch ( ... | @Test public void testEscapeValueString() { String res = Rdn.escapeValue( Strings.getBytesUtf8( "azerty" ) ); assertEquals( "azerty", res ); }
@Test public void testEscapeValueStringSpecial() { String res = Rdn.escapeValue( Strings.getBytesUtf8( "\\#,+;<>=\" " ) ); assertEquals( "\\\\#\\,\\+\\;\\<\\>\\=\\\"\\ ", res );... |
Rdn implements Cloneable, Externalizable, Iterable<Ava>, Comparable<Rdn> { @Override public Iterator<Ava> iterator() { if ( nbAvas < 2 ) { return new Iterator<Ava>() { private boolean hasMoreElement = nbAvas == 1; @Override public boolean hasNext() { return hasMoreElement; } @Override public Ava next() { Ava obj = ava;... | @Test public void testMultiValuedIterator() throws LdapException { Rdn rdn = new Rdn( "cn=Kate Bush+sn=Bush" ); Iterator<Ava> iterator = rdn.iterator(); assertNotNull( iterator ); assertTrue( iterator.hasNext() ); assertNotNull( iterator.next() ); assertTrue( iterator.hasNext() ); assertNotNull( iterator.next() ); asse... |
OsgiUtils { public static Set<String> splitIntoPackages( String exports, Set<String> pkgs ) { if ( pkgs == null ) { pkgs = new HashSet<>(); } int index = 0; boolean inPkg = true; boolean inProps = false; StringBuilder pkg = new StringBuilder(); while ( index < exports.length() ) { if ( inPkg && exports.charAt( index ) ... | @Test public void testSplitIntoPackageVersions() { Set<String> pkgs = OsgiUtils.splitIntoPackages( "org.ops4j.store.intern;uses:=\"org.ops4j.store,org.ops4j.io,org.apache.commons.logging\";" + "version=\"1.2.2\",org.ops4j.store;uses:=\"org.ops4j.store.intern\";version=\"1.2.2", null ); assertTrue( pkgs.contains( "org.o... |
LdifAttributesReader extends LdifReader { private Entry parseEntry( SchemaManager schemaManager ) throws LdapLdifException { if ( ( lines == null ) || lines.isEmpty() ) { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13408_END_OF_LDIF ) ); } return null; } Entry entry = new DefaultEntry( schemaManager ); ... | @Test public void testLdifNull() throws LdapLdifException, IOException { String ldif = null; LdifAttributesReader reader = new LdifAttributesReader(); Entry entry = reader.parseEntry( ldif ); assertEquals( 0, entry.size() ); reader.close(); }
@Test public void testLdifEmpty() throws LdapLdifException, IOException { Str... |
LdifAttributesReader extends LdifReader { private Attributes parseAttributes() throws LdapLdifException { if ( ( lines == null ) || lines.isEmpty() ) { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13408_END_OF_LDIF ) ); } return null; } Attributes attributes = new BasicAttributes( true ); for ( String li... | @Test public void testLdifParserRFC2849Sample3() throws LdapLdifException, Exception { String ldif = "objectclass: top\n" + "objectclass: person\n" + "objectclass: organizationalPerson\n" + "cn: Gern Jensen\n" + "cn: Gern O Jensen\n" + "sn: Jensen\n" + "uid: gernj\n" + "telephonenumber: +1 408 555 1212\n" + "descriptio... |
OsgiUtils { public static Set<File> getClasspathCandidates( FileFilter filter ) { Set<File> candidates = new HashSet<>(); String separator = System.getProperty( "path.separator" ); String[] cpElements = System.getProperty( "java.class.path" ).split( separator ); for ( String element : cpElements ) { File candidate = ne... | @Test public void testGetClasspathCandidates() { Set<File> candidates = OsgiUtils.getClasspathCandidates( REJECTION_FILTER ); assertEquals( 0, candidates.size(), "Should have no results with REJECTION_FILTER" ); candidates = OsgiUtils.getClasspathCandidates( ONLY_ONE_FILTER ); assertEquals( 1, candidates.size(), "Shoul... |
LdifRevertor { public static LdifEntry reverseAdd( Dn dn ) { LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Delete ); entry.setDn( dn ); return entry; } private LdifRevertor(); static LdifEntry reverseAdd( Dn dn ); static LdifEntry reverseDel( Dn dn, Entry deletedEntry ); static LdifEntry reverseMo... | @Test public void testReverseAdd() throws LdapInvalidDnException { Dn dn = new Dn( "dc=apache, dc=com" ); LdifEntry reversed = LdifRevertor.reverseAdd( dn ); assertNotNull( reversed ); assertEquals( dn.getName(), reversed.getDn().getName() ); assertEquals( ChangeType.Delete, reversed.getChangeType() ); assertNull( reve... |
LdifRevertor { public static LdifEntry reverseDel( Dn dn, Entry deletedEntry ) throws LdapException { LdifEntry entry = new LdifEntry(); entry.setDn( dn ); entry.setChangeType( ChangeType.Add ); for ( Attribute attribute : deletedEntry ) { entry.addAttribute( attribute ); } return entry; } private LdifRevertor(); stat... | @Test public void testReverseDel() throws LdapException { Dn dn = new Dn( "dc=apache, dc=com" ); Entry deletedEntry = new DefaultEntry( dn , "objectClass: top", "objectClass: person", "cn: test", "sn: apache", "dc: apache" ); LdifEntry reversed = LdifRevertor.reverseDel( dn, deletedEntry ); assertNotNull( reversed ); a... |
LdifRevertor { public static LdifEntry reverseModify( Dn dn, List<Modification> forwardModifications, Entry modifiedEntry ) throws LdapException { Entry clonedEntry = modifiedEntry.clone(); LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Modify ); entry.setDn( dn ); List<Modification> reverseModifica... | @Test public void testReverseModifyDelExistingOuValue() throws LdapException { Entry modifiedEntry = buildEntry(); modifiedEntry.put( "ou", "apache", "acme corp" ); Dn dn = new Dn( "cn=test, ou=system" ); Modification mod = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, new DefaultAttribute( "ou", "ac... |
OsgiUtils { public static Set<String> getAllBundleExports( FileFilter filter, Set<String> pkgs ) { if ( pkgs == null ) { pkgs = new HashSet<>(); } Set<File> candidates = getClasspathCandidates( filter ); for ( File candidate : candidates ) { String exports = getBundleExports( candidate ); if ( exports == null ) { if ( ... | @Test public void testGetAllBundleExports() { OsgiUtils.getAllBundleExports( null, null ); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.