Skip to content

Commit

Permalink
Issue junit-team#426 Applied new coding style
Browse files Browse the repository at this point in the history
Applied the new coding style to the code base for issue junit-team#426.
  • Loading branch information
awulder committed Oct 4, 2012
1 parent 68cc61e commit 30f2b16
Show file tree
Hide file tree
Showing 305 changed files with 23,023 additions and 21,586 deletions.
108 changes: 54 additions & 54 deletions src/main/java/junit/extensions/ActiveTestSuite.java
Expand Up @@ -10,61 +10,61 @@
* test in a separate thread and waits until all
* threads have terminated.
* -- Aarhus Radisson Scandinavian Center 11th floor
*/
*/
public class ActiveTestSuite extends TestSuite {
private volatile int fActiveTestDeathCount;
private volatile int fActiveTestDeathCount;

public ActiveTestSuite() {
}

public ActiveTestSuite(Class<? extends TestCase> theClass) {
super(theClass);
}

public ActiveTestSuite(String name) {
super (name);
}

public ActiveTestSuite(Class<? extends TestCase> theClass, String name) {
super(theClass, name);
}

@Override
public void run(TestResult result) {
fActiveTestDeathCount= 0;
super.run(result);
waitUntilFinished();
}

@Override
public void runTest(final Test test, final TestResult result) {
Thread t= new Thread() {
@Override
public void run() {
try {
// inlined due to limitation in VA/Java
//ActiveTestSuite.super.runTest(test, result);
test.run(result);
} finally {
ActiveTestSuite.this.runFinished();
}
}
};
t.start();
}
public ActiveTestSuite() {
}

synchronized void waitUntilFinished() {
while (fActiveTestDeathCount < testCount()) {
try {
wait();
} catch (InterruptedException e) {
return; // ignore
}
}
}

synchronized public void runFinished() {
fActiveTestDeathCount++;
notifyAll();
}
public ActiveTestSuite(Class<? extends TestCase> theClass) {
super(theClass);
}

public ActiveTestSuite(String name) {
super(name);
}

public ActiveTestSuite(Class<? extends TestCase> theClass, String name) {
super(theClass, name);
}

@Override
public void run(TestResult result) {
fActiveTestDeathCount = 0;
super.run(result);
waitUntilFinished();
}

@Override
public void runTest(final Test test, final TestResult result) {
Thread t = new Thread() {
@Override
public void run() {
try {
// inlined due to limitation in VA/Java
//ActiveTestSuite.super.runTest(test, result);
test.run(result);
} finally {
ActiveTestSuite.this.runFinished();
}
}
};
t.start();
}

synchronized void waitUntilFinished() {
while (fActiveTestDeathCount < testCount()) {
try {
wait();
} catch (InterruptedException e) {
return; // ignore
}
}
}

synchronized public void runFinished() {
fActiveTestDeathCount++;
notifyAll();
}
}
49 changes: 25 additions & 24 deletions src/main/java/junit/extensions/RepeatedTest.java
Expand Up @@ -5,34 +5,35 @@

/**
* A Decorator that runs a test repeatedly.
*
*/
public class RepeatedTest extends TestDecorator {
private int fTimesRepeat;
private int fTimesRepeat;

public RepeatedTest(Test test, int repeat) {
super(test);
if (repeat < 0)
throw new IllegalArgumentException("Repetition count must be >= 0");
fTimesRepeat= repeat;
}
public RepeatedTest(Test test, int repeat) {
super(test);
if (repeat < 0) {
throw new IllegalArgumentException("Repetition count must be >= 0");
}
fTimesRepeat = repeat;
}

@Override
public int countTestCases() {
return super.countTestCases() * fTimesRepeat;
}
@Override
public int countTestCases() {
return super.countTestCases() * fTimesRepeat;
}

@Override
public void run(TestResult result) {
for (int i= 0; i < fTimesRepeat; i++) {
if (result.shouldStop())
break;
super.run(result);
}
}
@Override
public void run(TestResult result) {
for (int i = 0; i < fTimesRepeat; i++) {
if (result.shouldStop()) {
break;
}
super.run(result);
}
}

@Override
public String toString() {
return super.toString() + "(repeated)";
}
@Override
public String toString() {
return super.toString() + "(repeated)";
}
}
59 changes: 29 additions & 30 deletions src/main/java/junit/extensions/TestDecorator.java
Expand Up @@ -8,36 +8,35 @@
* A Decorator for Tests. Use TestDecorator as the base class for defining new
* test decorators. Test decorator subclasses can be introduced to add behaviour
* before or after a test is run.
*
*/
public class TestDecorator extends Assert implements Test {
protected Test fTest;

public TestDecorator(Test test) {
fTest= test;
}

/**
* The basic run behaviour.
*/
public void basicRun(TestResult result) {
fTest.run(result);
}

public int countTestCases() {
return fTest.countTestCases();
}

public void run(TestResult result) {
basicRun(result);
}

@Override
public String toString() {
return fTest.toString();
}

public Test getTest() {
return fTest;
}
protected Test fTest;

public TestDecorator(Test test) {
fTest = test;
}

/**
* The basic run behaviour.
*/
public void basicRun(TestResult result) {
fTest.run(result);
}

public int countTestCases() {
return fTest.countTestCases();
}

public void run(TestResult result) {
basicRun(result);
}

@Override
public String toString() {
return fTest.toString();
}

public Test getTest() {
return fTest;
}
}
50 changes: 25 additions & 25 deletions src/main/java/junit/extensions/TestSetup.java
Expand Up @@ -11,32 +11,32 @@
*/
public class TestSetup extends TestDecorator {

public TestSetup(Test test) {
super(test);
}
public TestSetup(Test test) {
super(test);
}

@Override
public void run(final TestResult result) {
Protectable p= new Protectable() {
public void protect() throws Exception {
setUp();
basicRun(result);
tearDown();
}
};
result.runProtected(this, p);
}
@Override
public void run(final TestResult result) {
Protectable p = new Protectable() {
public void protect() throws Exception {
setUp();
basicRun(result);
tearDown();
}
};
result.runProtected(this, p);
}

/**
* Sets up the fixture. Override to set up additional fixture state.
*/
protected void setUp() throws Exception {
}
/**
* Sets up the fixture. Override to set up additional fixture state.
*/
protected void setUp() throws Exception {
}

/**
* Tears down the fixture. Override to tear down the additional fixture
* state.
*/
protected void tearDown() throws Exception {
}
/**
* Tears down the fixture. Override to tear down the additional fixture
* state.
*/
protected void tearDown() throws Exception {
}
}

0 comments on commit 30f2b16

Please sign in to comment.