author | Jaroslav Tulach <jtulach@netbeans.org> |
Wed, 08 Aug 2012 23:55:35 +0200 | |
changeset 399 | 06362e8bbcd9 |
parent 143 | 20dad4daf81b |
permissions | -rw-r--r-- |
jtulach@143 | 1 |
package org.apidesign.samples; |
jtulach@143 | 2 |
|
jtulach@143 | 3 |
public class CodeThatCanBeCalledOnlyByTest { |
jtulach@143 | 4 |
private static int number; |
jtulach@143 | 5 |
|
jtulach@143 | 6 |
public static int getNumber() { |
jtulach@143 | 7 |
return number; |
jtulach@143 | 8 |
} |
jtulach@143 | 9 |
|
jtulach@143 | 10 |
public static void setNumber(int n) { |
jtulach@143 | 11 |
// BEGIN: call.only.by.test |
jtulach@143 | 12 |
boolean assertionsOn = false; |
jtulach@143 | 13 |
assert assertionsOn = true; |
jtulach@399 | 14 |
if (!assertionsOn) { |
jtulach@143 | 15 |
throw new IllegalStateException("This is a testing method only!"); |
jtulach@143 | 16 |
} |
jtulach@143 | 17 |
// END: call.only.by.test |
jtulach@143 | 18 |
number = n; |
jtulach@143 | 19 |
} |
jtulach@143 | 20 |
} |