CSE 5 xx Object Oriented Programming and Design
CSE 5 xx – Object Oriented Programming and Design CSE/ECE 5 oo
CSE 5 xx – Object Oriented Programming and Design Discussion Items • Unit Tests using JMock 2 • Java Memory Management • Garbage Collection in Java ▪ http: //www. oracle. com/webfolder/technetwork/tutorials/obe/java/ gc 01/index. html 2 by Manish Shrotriya
CSE 5 xx – Object Oriented Programming and Design Unit Test • Testing a class in isolation: ▪ All external dependencies of target class are mocked. Dependencies could be at class level or method level. ▪ Exceptions on mock objects are defined. ▪ Expectation Syntax ◦ ◦ ◦ invocation-count (mock-object). method(argument-constraints); in. Sequence(sequence-name); // sequence clause when(state-machine. is(state-name)); // sequence clause will(action); // sequence clause then(state-machine. is(new-state-name)); // sequence clause 3 by Manish Shrotriya
CSE 5 xx – Object Oriented Programming and Design Unit Test • Testing a class in isolation: ▪ All external dependencies of target class are mocked. Dependencies could be at class level or method level. ▪ Exceptions on mock objects are defined. ▪ Expectation Syntax ◦ ◦ ◦ invocation-count (mock-object). method(argument-constraints); in. Sequence(sequence-name); // sequence clause when(state-machine. is(state-name)); // when clause will(action); // will clause then(state-machine. is(new-state-name)); // then clause 4 by Manish Shrotriya
CSE 5 xx – Object Oriented Programming and Design Unit Test • Testing a class in isolation: ▪ Every interaction with dependencies is put as expectations. ▪ Target method is called ▪ Exceptions are verified along with any other verifications. 5 by Manish Shrotriya
CSE 5 xx – Object Oriented Programming and Design Java Memory Model From http: //www. artima. com/insidejvm/ed 2/jvm 6. html 6 by Manish Shrotriya
CSE 5 xx – Object Oriented Programming and Design Java Memory Model -Xms, -Xmx Java. lang. Out. Of. Memory. Error: Java heap space Perm. Gen space -XX: Perm. Size -XX: Max. Perm. Size From http: //www. artima. com/insidejvm/ed 2/jvm 6. html 7 by Manish Shrotriya
CSE 5 xx – Object Oriented Programming and Design Java Memory Model From http: //www. artima. com/insidejvm/ed 2/jvm 6. html 8 by Manish Shrotriya
CSE 5 xx – Object Oriented Programming and Design Java Method Stack Frame method's parameters local variables Local variable Data about method logic ( normal or exceptional return, other objects) Frame Data Operand Stack Working area -XX: Thread. Stack. Size option to configure size of stackframe: if this is full java. lang. Stack. Over. Flow. Error 9 by Manish Shrotriya
CSE 5 xx – Object Oriented Programming and Design Java Method Stack Frame method 1 is calling method 2 Java Stack Frame Memory Local variable Frame Data Method 1() Operand Stack Local variable Method 2() Frame Data Operand Stack 10 by Manish Shrotriya
CSE 5 xx – Object Oriented Programming and Design Java Memory Model From http: //www. artima. com/insidejvm/ed 2/jvm 6. html 11 by Manish Shrotriya
- Slides: 11