@@ -87,7 +87,7 @@ def matcher(event_raw):
87
87
return True
88
88
return False
89
89
_ , test_class_prepare_event = self .jdwp .await_event (matcher )
90
- class_prepare_event = test_class_prepare_event ["events" ][0 ]["ClassPrepare" ]
90
+ return test_class_prepare_event ["events" ][0 ]["ClassPrepare" ]
91
91
92
92
def set_breakpoint_in_main (self , main_class_name ):
93
93
self .resume_and_await_class_load (main_class_name , self .jdwp .SuspendPolicy .ALL )
@@ -119,24 +119,7 @@ def matcher(event_raw):
119
119
return True
120
120
self .jdwp .VirtualMachine .Resume ()
121
121
_ , breakpoint_events = self .jdwp .await_event (matcher )
122
- return breakpoint_events
123
-
124
- def test_resume_and_await_class_load (self ):
125
- self .resume_and_await_class_load ("PyjdbTest" )
126
-
127
- def test_set_breakpoint_in_main (self ):
128
- breakpoint_events = self .set_breakpoint_in_main ("PyjdbTest" )
129
- self .assertIn ("events" , breakpoint_events )
130
- self .assertIn ("suspendPolicy" , breakpoint_events )
131
- self .assertEquals (len (breakpoint_events ["events" ]), 1 )
132
- self .assertIn ("Breakpoint" , breakpoint_events ["events" ][0 ])
133
- breakpoint_event = breakpoint_events ["events" ][0 ]["Breakpoint" ]
134
- self .assertIn ("classID" , breakpoint_event )
135
- self .assertIn ("index" , breakpoint_event )
136
- self .assertIn ("methodID" , breakpoint_event )
137
- self .assertIn ("thread" , breakpoint_event )
138
- self .assertIn ("requestID" , breakpoint_event )
139
- self .assertIn ("typeTag" , breakpoint_event )
122
+ return breakpoint_events ["events" ][0 ]["Breakpoint" ]
140
123
141
124
142
125
class VirtualMachineTest (PyjdbTestBase ):
@@ -517,8 +500,7 @@ def setUp(self):
517
500
"signature" : u"Ljava/lang/Integer;" })["classes" ][0 ]["typeID" ]
518
501
self .system_class_id = self .jdwp .VirtualMachine .ClassesBySignature ({
519
502
"signature" : u"Ljava/lang/System;" })["classes" ][0 ]["typeID" ]
520
- self .breakpoint_event = self .set_breakpoint_in_main (
521
- "ClassTypeTest" )["events" ][0 ]["Breakpoint" ]
503
+ self .breakpoint_event = self .set_breakpoint_in_main ("ClassTypeTest" )
522
504
523
505
def test_class_type_superclass (self ):
524
506
superclass_resp = self .jdwp .ClassType .Superclass ({
@@ -619,58 +601,52 @@ class MethodTest(PyjdbTestBase):
619
601
def setUpClass (cls ):
620
602
cls .debug_target_code = """
621
603
public class MethodTest {
604
+ public static int getNumber() {
605
+ int a = 10;
606
+ int b = 5;
607
+ int result = a + b;
608
+ return result;
609
+ }
610
+
622
611
public static void main(String[] args) throws Exception {
623
- Thing thing = new Thing();
624
612
while (true) {
625
613
Thread.sleep(1000);
626
614
}
627
615
}
628
-
629
- static class Thing {
630
- public int propertyA = 10;
631
- public int propertyB = 20;
632
-
633
- public int sumOfSquares() {
634
- int propertyASquared = propertyA * propertyA;
635
- int propertyBSquared = propertyB * propertyB;
636
- int result = propertyASquared + propertyBSquared;
637
- return result;
638
- }
639
- }
640
616
}
641
617
"""
642
618
cls .debug_target_main_class = "MethodTest"
643
619
super (MethodTest , cls ).setUpClass ()
644
620
645
621
def setUp (self ):
646
622
super (MethodTest , self ).setUp ()
647
- class_prepare_event = self .resume_and_await_class_load ("MethodTest$Thing " )
648
- self .thing_class_id = class_prepare_event ["typeID" ]
623
+ class_prepare_event = self .resume_and_await_class_load ("MethodTest" )
624
+ self .test_class_id = class_prepare_event ["typeID" ]
649
625
methods_resp = self .jdwp .ReferenceType .Methods ({
650
- "refType" : thing_class_id })
626
+ "refType" : self . test_class_id })
651
627
self .methods = methods_resp ["declared" ]
652
628
for method in methods_resp ["declared" ]:
653
- if method ["name" ] == u"sumOfSquares " :
654
- self .sum_of_squares_method_id = method ["methodID" ]
629
+ if method ["name" ] == u"getNumber " :
630
+ self .get_number_method_id = method ["methodID" ]
655
631
656
632
def test_method_line_table (self ):
657
633
line_table_resp = self .jdwp .Method .LineTable ({
658
- "refType" : self .thing_class_id ,
659
- "methodID" : self .sum_of_squares_method_id })
634
+ "refType" : self .test_class_id ,
635
+ "methodID" : self .get_number_method_id })
660
636
self .assertIn ("start" , line_table_resp )
661
637
self .assertIn ("end" , line_table_resp )
662
638
self .assertIn ("lines" , line_table_resp )
663
639
self .assertGreater (len (line_table_resp ["lines" ]), 0 )
664
- for line in line_table_resp ["lines" ]:
665
- self .assertIn ("lineCodeIndex" , line )
666
- self .assertIsInstance (line ["lineCodeIndex" ], int )
667
- self .assertIn ("lineNumber" , line )
668
- self .assertIsInstance (line ["lineNumber" ], int )
640
+ line = line_table_resp ["lines" ][ 0 ]
641
+ self .assertIn ("lineCodeIndex" , line )
642
+ self .assertIsInstance (line ["lineCodeIndex" ], int )
643
+ self .assertIn ("lineNumber" , line )
644
+ self .assertIsInstance (line ["lineNumber" ], int )
669
645
670
646
def test_method_variable_table (self ):
671
647
variable_table_resp = self .jdwp .Method .VariableTable ({
672
- "refType" : self .thing_class_id ,
673
- "methodID" : self .sum_of_squares_method_id })
648
+ "refType" : self .test_class_id ,
649
+ "methodID" : self .get_number_method_id })
674
650
self .assertIn ("slots" , variable_table_resp )
675
651
self .assertGreater (len (variable_table_resp ["slots" ]), 1 )
676
652
self .assertIn ("codeIndex" , variable_table_resp ["slots" ][0 ])
@@ -681,22 +657,22 @@ def test_method_variable_table(self):
681
657
682
658
def test_method_bytecodes (self ):
683
659
bytecode_resp = self .jdwp .Method .Bytecodes ({
684
- "refType" : self .thing_class_id ,
685
- "methodID" : self .sum_of_squares_method_id })
660
+ "refType" : self .test_class_id ,
661
+ "methodID" : self .get_number_method_id })
686
662
self .assertIn ("bytes" , bytecode_resp )
687
663
self .assertGreater (len (bytecode_resp ["bytes" ]), 0 )
688
664
self .assertIn ("bytecode" , bytecode_resp ["bytes" ][0 ])
689
665
690
666
def test_method_is_obsolete (self ):
691
667
is_obsolete_resp = self .jdwp .Method .IsObsolete ({
692
- "refType" : self .thing_class_id ,
693
- "methodID" : self .sum_of_squares_method_id })
668
+ "refType" : self .test_class_id ,
669
+ "methodID" : self .get_number_method_id })
694
670
self .assertIn ("isObsolete" , is_obsolete_resp )
695
671
696
672
def test_method_variable_table_with_generic (self ):
697
673
variable_table_resp = self .jdwp .Method .VariableTableWithGeneric ({
698
- "refType" : self .thing_class_id ,
699
- "methodID" : self .sum_of_squares_method_id })
674
+ "refType" : self .test_class_id ,
675
+ "methodID" : self .get_number_method_id })
700
676
self .assertIn ("slots" , variable_table_resp )
701
677
self .assertGreater (len (variable_table_resp ["slots" ]), 1 )
702
678
self .assertIn ("codeIndex" , variable_table_resp ["slots" ][0 ])
@@ -729,7 +705,7 @@ def setUpClass(cls):
729
705
def setUp (self ):
730
706
super (ObjectReferenceTest , self ).setUp ()
731
707
self .breakpoint_event = self .set_breakpoint_in_main (
732
- "ObjectReferenceTest" )[ "events" ][ 0 ][ "Breakpoint" ]
708
+ "ObjectReferenceTest" )
733
709
self .test_class_id = self .breakpoint_event ["classID" ]
734
710
methods_resp = self .jdwp .ReferenceType .Methods ({
735
711
"refType" : self .test_class_id })
@@ -857,7 +833,7 @@ class StringReferenceTest {
857
833
def setUp (self ):
858
834
super (StringReferenceTest , self ).setUp ()
859
835
self .breakpoint_event = self .set_breakpoint_in_main (
860
- "StringReferenceTest" )[ "events" ][ 0 ][ "Breakpoint" ]
836
+ "StringReferenceTest" )
861
837
self .test_class_id = self .breakpoint_event ["classID" ]
862
838
863
839
def test_string_reference_value (self ):
@@ -876,6 +852,7 @@ def test_string_reference_value(self):
876
852
class ThreadReferenceTest (PyjdbTestBase ):
877
853
def test_thread_reference_name (self ):
878
854
pass
855
+
879
856
#def test_thread_reference_suspend(self):
880
857
#def test_thread_reference_resume(self):
881
858
#def test_thread_reference_status(self):
0 commit comments