#NEWLINE# def test_agent_manifest( self ) : #NEWLINE# #INDENT# self . add_to_build_file ( 'src/java/pants/agents' , dedent ( "\n        java_agent(\n          name='fake_agent',\n          premain='bob',\n          agent_class='fred',\n          can_redefine=True,\n          can_retransform=True,\n          can_set_native_method_prefix=True\n        )" ) . strip ( ) ) #NEWLINE# java_agent = self . target ( 'src/java/pants/agents:fake_agent' ) #NEWLINE# context = self . context ( target_roots = [ java_agent ] ) #NEWLINE# jar_builder_task = self . prepare_execute ( context ) #NEWLINE# self . add_to_runtime_classpath ( context , java_agent , { #NEWLINE# #INDENT# 'FakeAgent.class' : '0xCAFEBABE' , #NEWLINE# #UNINDENT# } ) #NEWLINE# with self . jarfile ( ) as existing_jarfile : #NEWLINE# #INDENT# with jar_builder_task . open_jar ( existing_jarfile ) as jar : #NEWLINE# #INDENT# with jar_builder_task . create_jar_builder ( jar ) as jar_builder : #NEWLINE# #INDENT# jar_builder . add_target ( java_agent ) #NEWLINE# #UNINDENT# #UNINDENT# with open_zip ( jar ) as jar : #NEWLINE# #INDENT# self . assert_listing ( jar , 'FakeAgent.class' ) #NEWLINE# self . assertEqual ( '0xCAFEBABE' , jar . read ( 'FakeAgent.class' ) ) #NEWLINE# manifest = jar . read ( 'META-INF/MANIFEST.MF' ) . strip ( ) #NEWLINE# all_entries = dict ( ( tuple ( re . split ( '\\s*:\\s*' , line , 1 ) ) for line in manifest . splitlines ( ) ) ) #NEWLINE# expected_entries = { #NEWLINE# #INDENT# 'Agent-Class' : 'fred' , #NEWLINE# 'Premain-Class' : 'bob' , #NEWLINE# 'Can-Redefine-Classes' : 'true' , #NEWLINE# 'Can-Retransform-Classes' : 'true' , #NEWLINE# 'Can-Set-Native-Method-Prefix' : 'true' , #NEWLINE# #UNINDENT# } #NEWLINE# self . assertEquals ( set ( expected_entries . items ( ) ) , set ( expected_entries . items ( ) ) . intersection ( set ( all_entries . items ( ) ) ) )