author | Jaroslav Tulach <jaroslav.tulach@apidesign.org> |
Thu, 30 Oct 2014 21:30:10 +0100 | |
changeset 409 | 40cabcdcd2be |
permissions | -rw-r--r-- |
jtulach@324 | 1 |
package org.apidesign.sidemeanings.test; |
jtulach@324 | 2 |
|
jtulach@324 | 3 |
import org.apidesign.sidemeanings.PublicAbstract; |
jtulach@324 | 4 |
import org.junit.Assert; |
jtulach@324 | 5 |
import org.junit.Test; |
jtulach@324 | 6 |
|
jtulach@324 | 7 |
public class PublicAbstractTest { |
jtulach@324 | 8 |
|
jtulach@324 | 9 |
@Test public void testCallTenDoubleIncrementOnDirtyAPI() { |
jtulach@324 | 10 |
// BEGIN: sidemeanings.PublicAbstract.Dirty.test |
jtulach@324 | 11 |
class DoubleIncrement extends PublicAbstract.Dirty { |
jtulach@324 | 12 |
int counter; |
jtulach@324 | 13 |
|
jtulach@324 | 14 |
@Override |
jtulach@324 | 15 |
public void increment() { |
jtulach@324 | 16 |
counter += 2; |
jtulach@324 | 17 |
} |
jtulach@324 | 18 |
} |
jtulach@324 | 19 |
DoubleIncrement doubleIncr = new DoubleIncrement(); |
jtulach@324 | 20 |
doubleIncr.incrementTenTimes(); |
jtulach@324 | 21 |
Assert.assertEquals(20, doubleIncr.counter); |
jtulach@324 | 22 |
// END: sidemeanings.PublicAbstract.Dirty.test |
jtulach@324 | 23 |
} |
jtulach@324 | 24 |
|
jtulach@324 | 25 |
@Test public void testCallTenDoubleIncrementOnCleanAPI() { |
jtulach@324 | 26 |
// BEGIN: sidemeanings.PublicAbstract.Clean.test |
jtulach@324 | 27 |
class DoubleIncrement extends PublicAbstract.Clean { |
jtulach@324 | 28 |
int counter; |
jtulach@324 | 29 |
|
jtulach@324 | 30 |
@Override |
jtulach@324 | 31 |
protected void overridableIncrement() { |
jtulach@324 | 32 |
counter += 2; |
jtulach@324 | 33 |
} |
jtulach@324 | 34 |
} |
jtulach@324 | 35 |
DoubleIncrement doubleIncr = new DoubleIncrement(); |
jtulach@324 | 36 |
doubleIncr.incrementTenTimes(); |
jtulach@324 | 37 |
Assert.assertEquals(20, doubleIncr.counter); |
jtulach@324 | 38 |
// END: sidemeanings.PublicAbstract.Clean.test |
jtulach@324 | 39 |
} |
jtulach@324 | 40 |
|
jtulach@324 | 41 |
} |