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 * test in a separate thread and waits until all
* threads have terminated. * threads have terminated.
* -- Aarhus Radisson Scandinavian Center 11th floor * -- Aarhus Radisson Scandinavian Center 11th floor
*/ */
public class ActiveTestSuite extends TestSuite { public class ActiveTestSuite extends TestSuite {
private volatile int fActiveTestDeathCount; private volatile int fActiveTestDeathCount;


public ActiveTestSuite() { 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();
}


synchronized void waitUntilFinished() { public ActiveTestSuite(Class<? extends TestCase> theClass) {
while (fActiveTestDeathCount < testCount()) { super(theClass);
try { }
wait();
} catch (InterruptedException e) { public ActiveTestSuite(String name) {
return; // ignore super(name);
} }
}
} public ActiveTestSuite(Class<? extends TestCase> theClass, String name) {

super(theClass, name);
synchronized public void runFinished() { }
fActiveTestDeathCount++;
notifyAll(); @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. * A Decorator that runs a test repeatedly.
*
*/ */
public class RepeatedTest extends TestDecorator { public class RepeatedTest extends TestDecorator {
private int fTimesRepeat; private int fTimesRepeat;


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


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


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


@Override @Override
public String toString() { public String toString() {
return super.toString() + "(repeated)"; 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 * A Decorator for Tests. Use TestDecorator as the base class for defining new
* test decorators. Test decorator subclasses can be introduced to add behaviour * test decorators. Test decorator subclasses can be introduced to add behaviour
* before or after a test is run. * before or after a test is run.
*
*/ */
public class TestDecorator extends Assert implements Test { public class TestDecorator extends Assert implements Test {
protected Test fTest; protected Test fTest;


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


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


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


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


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


public Test getTest() { public Test getTest() {
return fTest; 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 class TestSetup extends TestDecorator {


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


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


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


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

0 comments on commit 30f2b16

Please sign in to comment.