From c5ef494d1f2ce5324790a31291d06873ed76efbb Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Sun, 6 Dec 2009 20:15:40 +0000 Subject: [PATCH] Cosmetics. --- .../index/tests/IndexIncludeTest.java | 53 ++++++------------- .../core/testplugin/util/BaseTestCase.java | 48 ++++++++--------- 2 files changed, 40 insertions(+), 61 deletions(-) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexIncludeTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexIncludeTest.java index f6e4adf2834..5177be62996 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexIncludeTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexIncludeTest.java @@ -101,8 +101,7 @@ public class IndexIncludeTest extends IndexTestBase { try { IIndexBinding[] result= fIndex.findBindings(Pattern.compile(".*included"), true, IndexFilter.ALL, NPM); assertEquals(all ? 2 : 1, result.length); - } - finally { + } finally { fIndex.releaseReadLock(); } } @@ -132,8 +131,7 @@ public class IndexIncludeTest extends IndexTestBase { result= fIndex.findBindings("testInclude_cpp".toCharArray(), IndexFilter.ALL, NPM); assertEquals(1, result.length); - } - finally { + } finally { fIndex.releaseReadLock(); } } @@ -159,8 +157,7 @@ public class IndexIncludeTest extends IndexTestBase { checkInclude(includes[0], content, "user20061107.h", false); checkInclude(includes[1], content, "system20061107.h", true); - } - finally { + } finally { fIndex.releaseReadLock(); } } @@ -183,8 +180,7 @@ public class IndexIncludeTest extends IndexTestBase { assertEquals(1, includes.length); checkInclude(includes[0], content, "header20061107.h", false); - } - finally { + } finally { fIndex.releaseReadLock(); } } @@ -205,8 +201,7 @@ public class IndexIncludeTest extends IndexTestBase { assertFalse(includes[0].isActive()); checkInclude(includes[0], content, "inactive20070213.h", false); - } - finally { + } finally { fIndex.releaseReadLock(); } } @@ -228,8 +223,7 @@ public class IndexIncludeTest extends IndexTestBase { assertTrue(includes[0].isActive()); assertFalse(includes[0].isResolved()); checkInclude(includes[0], content, "unresolved20070213.h", false); - } - finally { + } finally { fIndex.releaseReadLock(); } } @@ -259,8 +253,7 @@ public class IndexIncludeTest extends IndexTestBase { IBinding[] bindings= fIndex.findBindings("ctx_20070404x".toCharArray(), IndexFilter.ALL, NPM); assertEquals(1, bindings.length); assertTrue(bindings[0] instanceof IVariable); - } - finally { + } finally { fIndex.releaseReadLock(); } @@ -277,11 +270,9 @@ public class IndexIncludeTest extends IndexTestBase { IBinding[] bindings= fIndex.findBindings("ctx_20070404y".toCharArray(), IndexFilter.ALL, NPM); assertEquals(1, bindings.length); assertTrue(bindings[0] instanceof IVariable); - } - finally { + } finally { fIndex.releaseReadLock(); } - } // #define SOME_MACRO1 ok_1_220358 @@ -308,8 +299,7 @@ public class IndexIncludeTest extends IndexTestBase { IIndexBinding[] binding= fIndex.findBindings("ok_1_220358".toCharArray(), IndexFilter.ALL_DECLARED, NPM); assertEquals(1, binding.length); assertTrue(binding[0] instanceof IVariable); - } - finally { + } finally { fIndex.releaseReadLock(); } @@ -321,13 +311,11 @@ public class IndexIncludeTest extends IndexTestBase { IIndexBinding[] binding= fIndex.findBindings("ok_2_220358".toCharArray(), IndexFilter.ALL_DECLARED, NPM); assertEquals(1, binding.length); assertTrue(binding[0] instanceof IVariable); - } - finally { + } finally { fIndex.releaseReadLock(); } } - // #include "resolved20070426.h" public void testFixedContext() throws Exception { TestScannerProvider.sIncludes= new String[]{fProject.getProject().getLocation().toOSString()}; @@ -355,8 +343,7 @@ public class IndexIncludeTest extends IndexTestBase { assertEquals(s1.getFullPath().toString(), includes[0].getIncludedByLocation().getFullPath()); assertEquals(s2.getFullPath().toString(), includes[1].getIncludedByLocation().getFullPath()); - } - finally { + } finally { fIndex.releaseReadLock(); } @@ -374,8 +361,7 @@ public class IndexIncludeTest extends IndexTestBase { IIndexInclude context= ifile.getParsedInContext(); assertNotNull(context); assertEquals(s1.getFullPath().toString(), context.getIncludedByLocation().getFullPath()); - } - finally { + } finally { fIndex.releaseReadLock(); } @@ -393,8 +379,7 @@ public class IndexIncludeTest extends IndexTestBase { IIndexInclude context= ifile.getParsedInContext(); assertNotNull(context); assertEquals(s1.getFullPath().toString(), context.getIncludedByLocation().getFullPath()); - } - finally { + } finally { fIndex.releaseReadLock(); } } @@ -500,8 +485,7 @@ public class IndexIncludeTest extends IndexTestBase { assertFalse(includes[2].isActive()); assertFalse(includes[2].isResolved()); assertFalse(includes[2].isSystemInclude()); - } - finally { + } finally { fIndex.releaseReadLock(); } } @@ -532,8 +516,7 @@ public class IndexIncludeTest extends IndexTestBase { assertFalse(includes[1].isActive()); assertFalse(includes[1].isResolved()); assertTrue(includes[1].isSystemInclude()); - } - finally { + } finally { fIndex.releaseReadLock(); } } @@ -568,8 +551,7 @@ public class IndexIncludeTest extends IndexTestBase { assertFalse(includes[1].isActive()); assertFalse(includes[1].isResolved()); assertTrue(includes[1].isSystemInclude()); - } - finally { + } finally { fIndex.releaseReadLock(); } } @@ -604,8 +586,7 @@ public class IndexIncludeTest extends IndexTestBase { assertTrue(includes[1].isActive()); assertFalse(includes[1].isResolved()); assertFalse(includes[1].isSystemInclude()); - } - finally { + } finally { fIndex.releaseReadLock(); } } diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java index 7574717f8d0..c97daa3dd8d 100644 --- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java +++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java @@ -123,7 +123,7 @@ public class BaseTestCase extends TestCase { final List statusLog= Collections.synchronizedList(new ArrayList()); ILogListener logListener= new ILogListener() { public void logging(IStatus status, String plugin) { - if(!status.isOK() && status.getSeverity() != IStatus.INFO) { + if (!status.isOK() && status.getSeverity() != IStatus.INFO) { switch (status.getCode()) { case IResourceStatus.NOT_FOUND_LOCAL: case IResourceStatus.NO_LOCATION_LOCAL: @@ -145,32 +145,32 @@ public class BaseTestCase extends TestCase { try { try { super.runBare(); - } catch(Throwable e) { + } catch (Throwable e) { testThrowable=e; } - if(statusLog.size()!=fExpectedLoggedNonOK) { + if (statusLog.size()!=fExpectedLoggedNonOK) { StringBuffer msg= new StringBuffer("Expected number ("+fExpectedLoggedNonOK+") of "); msg.append("non-OK status objects differs from actual ("+statusLog.size()+").\n"); Throwable cause= null; - if(!statusLog.isEmpty()) { - for(IStatus status : statusLog) { + if (!statusLog.isEmpty()) { + for (IStatus status : statusLog) { IStatus[] ss= {status}; - ss= status instanceof MultiStatus ? ((MultiStatus)status).getChildren() : ss; - for(IStatus s : ss) { - msg.append("\t"+s.getMessage()+" "); + ss= status instanceof MultiStatus ? ((MultiStatus) status).getChildren() : ss; + for (IStatus s : ss) { + msg.append("\t" + s.getMessage()+" "); Throwable t= s.getException(); - cause= (cause==null) ? t : cause; - if(t != null) { - msg.append(t.getMessage()!=null ? t.getMessage() : t.getClass().getCanonicalName()); + cause= cause != null ? cause : t; + if (t != null) { + msg.append(t.getMessage() != null ? t.getMessage() : t.getClass().getCanonicalName()); } msg.append("\n"); } } } - cause= (cause==null) ? testThrowable : cause; + cause= cause != null ? cause : testThrowable; AssertionFailedError afe= new AssertionFailedError(msg.toString()); afe.initCause(cause); throw afe; @@ -181,38 +181,36 @@ public class BaseTestCase extends TestCase { } } - if(testThrowable!=null) + if (testThrowable!=null) throw testThrowable; } @Override - public void run( TestResult result ) { + public void run(TestResult result) { if (!fExpectFailure || "true".equals(System.getProperty("SHOW_EXPECTED_FAILURES"))) { super.run(result); return; } - result.startTest( this ); + result.startTest(this); TestResult r = new TestResult(); - super.run( r ); + super.run(r); if (r.failureCount() == 1) { TestFailure failure= (TestFailure) r.failures().nextElement(); String msg= failure.exceptionMessage(); if (msg != null && msg.startsWith("Method \"" + getName() + "\"")) { result.addFailure(this, new AssertionFailedError(msg)); } - } - else if( r.errorCount() == 0 && r.failureCount() == 0 ) - { + } else if (r.errorCount() == 0 && r.failureCount() == 0) { String err = "Unexpected success of " + getName(); - if( fBugnumber > 0 ) { + if (fBugnumber > 0) { err += ", bug #" + fBugnumber; } - result.addFailure( this, new AssertionFailedError( err ) ); + result.addFailure(this, new AssertionFailedError(err)); } - result.endTest( this ); + result.endTest(this); } public void setExpectFailure(int bugnumber) { @@ -253,12 +251,12 @@ public class BaseTestCase extends TestCase { public void join() throws CoreException { try { synchronized(changed) { - while(!changed[0]) { + while (!changed[0]) { changed.wait(); } } - } catch(InterruptedException ie) { - throw new CoreException(CCorePlugin.createStatus("Interrupted", ie)); + } catch (InterruptedException e) { + throw new CoreException(CCorePlugin.createStatus("Interrupted", e)); } }