@Test
public void testIdentityWithResize() {        

    KieBaseConfiguration kconf = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
    kconf.setOption( EqualityBehaviorOption.IDENTITY );
    KieBase kbase = KnowledgeBaseFactory.newKnowledgeBase(kconf);
    KieSession ksession = kbase.newKieSession();
    
    int length = 1 * 300 * 1000 ;
    
    List<FactHandle> handles = new ArrayList<FactHandle>(1000);
    List<String> objects = new ArrayList<String>(1000);
    for ( int i = 0; i < length; i++) { 
        String s = getPropertyName(i);
        FactHandle handle = ksession.insert( s );
        objects.add( s );
        handles.add( handle );
    }
    
    for ( int i = 0; i < length; i++) { 
        String s = objects.get(i);
        FactHandle handle = handles.get( i );
        assertEquals( s, ksession.getObject( handle ) );            
        assertSame( handle, ksession.getFactHandle( s ) );
        
        // now check with disconnected facthandle
        handle = DefaultFactHandle.createFromExternalFormat(((DefaultFactHandle)handle).toExternalForm());
        assertEquals( s, ksession.getObject( handle ) );            
    }
    
    for ( int i = 0; i < length; i++) { 
        FactHandle handle = handles.get( i );         
        
        // now retract with disconnected facthandle
        handle = DefaultFactHandle.createFromExternalFormat(((DefaultFactHandle)handle).toExternalForm());
        ksession.retract( handle );
        assertEquals( length - i -1, ksession.getObjects().size() );
        assertEquals( length - i -1, ksession.getFactHandles().size() );            
    }        
    
    assertEquals( 0, ksession.getObjects().size() );
    assertEquals( 0, ksession.getFactHandles().size() );         
}