| ←Older revision |
Revision as of 05:34, 20 October 2018 |
| Line 28: |
Line 28: |
| | * What if there is a file left from a previous (killed) execution? | | * What if there is a file left from a previous (killed) execution? |
| | * What happens when a test for file existence fails, but when trying to create it the file already exists? | | * What happens when a test for file existence fails, but when trying to create it the file already exists? |
| - | All these questions have to be asked when one wants to have really good confidence in the application code. In order to get the confidence we wanted, we inserted a lot of check points into our [https://github.com/jtulach/incubator-netbeans/blob/9.0-vc3/o.n.bootstrap/src/org/netbeans/CLIHandler.java implementation of locking ] so the code became a modified version of the previous snippet: | + | All these questions have to be asked when one wants to have really good confidence in the application code. |
| | + | |
| | + | == Simple [[FlowControlingTest]] written manually == |
| | + | |
| | + | In order to get the confidence we wanted, we inserted a lot of check points into our [https://github.com/jtulach/incubator-netbeans/blob/9.0-vc3/o.n.bootstrap/src/org/netbeans/CLIHandler.java#L514 implementation of locking ] so the code became a modified version of the previous snippet: |
| | <source lang="java"> | | <source lang="java"> |
| | enterState(10, block); | | enterState(10, block); |
| Line 47: |
Line 51: |
| | enterState(22, block); | | enterState(22, block); |
| | os.writeInt(p); | | os.writeInt(p); |
| - | enterState(23, block); | + | enterState(23, block); |
| | + | os.close(); |
| | </source> | | </source> |
| | + | |
| | The '''enterState''' method does nothing in real production environment, but in test it can be instructed to block at a specific check point. So we can write a test which starts two threads and instruct one of them to stop at 22 and then let the second one run and observe how it handles the case when a file already exists, but the port is not yet written in. | | The '''enterState''' method does nothing in real production environment, but in test it can be instructed to block at a specific check point. So we can write a test which starts two threads and instruct one of them to stop at 22 and then let the second one run and observe how it handles the case when a file already exists, but the port is not yet written in. |
| | | | |