#NEWLINE# @ patch . object ( Collector , 'flush' ) #NEWLINE# def test_mbean_blacklisting( self , publish_mock ) : #NEWLINE# #INDENT# def se( url ) : #NEWLINE# #INDENT# if ( url . find ( 'org.apache.cassandra.metrics' ) > 0 ) : #NEWLINE# #INDENT# return self . getFixture ( 'metrics.json' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( url . find ( 'list/org.apache.cassandra.db' ) > 0 ) : #NEWLINE# #INDENT# return self . getFixture ( 'cas_db.json' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( url . find ( 'org.apache.cassandra.db:type=StorageService' ) > 0 ) : #NEWLINE# #INDENT# return Exception ( 'storage service should be blacklisted' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( url . find ( 'list?ifModifiedSince' ) > 0 ) : #NEWLINE# #INDENT# return self . getFixture ( 'cas_list.json' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return self . getFixture ( 'storage_proc.json' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# patch_urlopen = patch ( 'urllib2.urlopen' , Mock ( side_effect = se ) ) #NEWLINE# self . collector . config [ 'mbean_blacklist' ] = [ 'org.apache.cassandra.db:type=StorageService' ] #NEWLINE# with patch_urlopen : #NEWLINE# #INDENT# self . collector . collect ( ) #NEWLINE# #UNINDENT# metrics = find_metric ( self . collector . payload , 'org.apache.cassandra.db.StorageProxy.cascontentiontimeout' ) #NEWLINE# self . assertNotEqual ( len ( metrics ) , 0 )