samples/individualsamples/src/org/apidesign/samples/CodeThatCanBeCalledOnlyByTest.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Thu, 30 Oct 2014 20:46:27 +0100
changeset 408 9a439a79c6d0
parent 143 20dad4daf81b
permissions -rw-r--r--
Use scala 2.10.4 to compile on JDK8
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
}