From 5b0b6666eab6e0728d4553394c472efc0662460b Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Thu, 5 Jan 2012 11:09:34 +0100 Subject: [PATCH] Remove JUnit output to stdout. --- .../tests/ast2/ClassTypeHelperTests.java | 9 ----- .../cdt/internal/pdom/tests/BTreeTests.java | 23 +++++++---- .../cdt/internal/pdom/tests/ClassTests.java | 4 +- .../cdt/internal/pdom/tests/DBTest.java | 4 +- .../tests/GeneratePDOMApplicationTest.java | 40 ++++++++++++++++++- 5 files changed, 57 insertions(+), 23 deletions(-) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ClassTypeHelperTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ClassTypeHelperTests.java index e45445d956a..f3454e8e5cd 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ClassTypeHelperTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ClassTypeHelperTests.java @@ -14,9 +14,7 @@ import java.io.IOException; import junit.framework.TestSuite; -import org.eclipse.cdt.core.dom.ast.IVariable; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; -import org.eclipse.cdt.core.parser.util.ASTPrinter; import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper; import org.eclipse.cdt.internal.core.parser.ParserException; @@ -41,13 +39,6 @@ public class ClassTypeHelperTests extends AST2BaseTest { return new BindingAssertionHelper(code, true); } - // int a; - // const int& b; - public void testTemp() throws Exception { - BindingAssertionHelper helper = getAssertionHelper(); - ASTPrinter.print(helper.getTranslationUnit()); - } - // struct A { // A(const A& a); // }; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/BTreeTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/BTreeTests.java index c2094d3d1ba..967720e93cb 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/BTreeTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/BTreeTests.java @@ -36,13 +36,13 @@ import org.eclipse.core.runtime.CoreException; * */ public class BTreeTests extends BaseTestCase { + private static int DEBUG= 0; protected File dbFile; protected Database db; protected BTree btree; protected int rootRecord; protected IBTreeComparator comparator; - protected boolean debugMode = false; public static Test suite() { return suite(BTreeTests.class); @@ -80,7 +80,8 @@ public class BTreeTests extends BaseTestCase { for(int i=0; i 0) + System.out.println("Iteration #"+i); trial(seed, false); } } @@ -95,7 +96,8 @@ public class BTreeTests extends BaseTestCase { for(int i=0; i<6; i++) { int seed = seeder.nextInt(); - System.out.println("Iteration #"+i); + if (DEBUG > 0) + System.out.println("Iteration #"+i); trialImp(seed, false, new Random(seed*2), 1); } } @@ -124,7 +126,8 @@ public class BTreeTests extends BaseTestCase { init(degree); - System.out.print("\t "+seed+" "+(nIterations/1000)+"K: "); + if (DEBUG > 0) + System.out.print("\t "+seed+" "+(nIterations/1000)+"K: "); for(int i=0; i 1) System.out.println("Add: "+value+" @ "+btValue.record); btree.insert(btValue.getRecord()); } @@ -142,12 +145,12 @@ public class BTreeTests extends BaseTestCase { BTMockRecord btValue = (BTMockRecord) history.get(index); history.remove(index); expected.remove(new Integer(btValue.intValue())); - if(debugMode) + if(DEBUG > 1) System.out.println("Remove: "+btValue.intValue()+" @ "+btValue.record); btree.delete(btValue.getRecord()); } } - if(i % 1000 == 0) { + if(i % 1000 == 0 && DEBUG > 0) { System.out.print("."); } if(checkCorrectnessEachIteration) { @@ -155,7 +158,8 @@ public class BTreeTests extends BaseTestCase { assertBTreeInvariantsHold("[iteration "+i+"] "); } } - System.out.println(); + if (DEBUG > 0) + System.out.println(); assertBTreeMatchesSortedSet("[Trial end] ", btree, expected); assertBTreeInvariantsHold("[Trial end]"); @@ -174,9 +178,11 @@ public class BTreeTests extends BaseTestCase { final Iterator i = expected.iterator(); btree.accept(new IBTreeVisitor(){ int k; + @Override public int compare(long record) throws CoreException { return 0; } + @Override public boolean visit(long record) throws CoreException { if(record!=0) { BTMockRecord btValue = new BTMockRecord(record, db); @@ -227,6 +233,7 @@ public class BTreeTests extends BaseTestCase { } private class BTMockRecordComparator implements IBTreeComparator { + @Override public int compare(long record1, long record2) throws CoreException { return db.getInt(record1) - db.getInt(record2); } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/ClassTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/ClassTests.java index 94e0e04b9f8..19bf1599cdf 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/ClassTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/ClassTests.java @@ -117,8 +117,8 @@ public class ClassTests extends PDOMTestBase { bindings = ns.find("testRef"); assertEquals(1, bindings.length); IName[] refs = pdom.findNames(bindings[0], IIndex.FIND_REFERENCES); - for (int i = 0; i < refs.length; ++i) - System.out.println(refs[i].getFileLocation().getNodeOffset()); +// for (int i = 0; i < refs.length; ++i) +// System.out.println(refs[i].getFileLocation().getNodeOffset()); assertEquals(5, refs.length); } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/DBTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/DBTest.java index 08275ed495a..8f847e99362 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/DBTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/DBTest.java @@ -255,8 +255,8 @@ public class DBTest extends BaseTestCase { int expected = caseSensitive ? a.compareTo(b) : a.compareToIgnoreCase(b); assertCMP(a, expected, b, caseSensitive); } - System.out.print("Trials: "+n+" Max length: "+max+" ignoreCase: "+!caseSensitive); - System.out.println(" Time: "+(System.currentTimeMillis()-start)); +// System.out.print("Trials: "+n+" Max length: "+max+" ignoreCase: "+!caseSensitive); +// System.out.println(" Time: "+(System.currentTimeMillis()-start)); } private String randomString(int min, int max, Random r) { diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/GeneratePDOMApplicationTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/GeneratePDOMApplicationTest.java index f4d05da9f5e..6d63cdcc3e4 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/GeneratePDOMApplicationTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/GeneratePDOMApplicationTest.java @@ -274,6 +274,7 @@ public class GeneratePDOMApplicationTest extends PDOMTestBase { IIndexerStateListener listener= null; if(stateCount != null) { listener= new IIndexerStateListener() { + @Override public void indexChanged(IIndexerStateEvent event) { stateCount[0]++; } @@ -299,8 +300,14 @@ public class GeneratePDOMApplicationTest extends PDOMTestBase { } private void doGenerate(String[] args) throws CoreException { - GeneratePDOMApplication app = new GeneratePDOMApplication(); - IApplicationContext ac= new MockApplicationContext(args); + GeneratePDOMApplication app = new GeneratePDOMApplication() { + @Override + protected void output(String s) {} + }; + String[] newArgs= new String[args.length+1]; + newArgs[0]= GeneratePDOMApplication.OPT_QUIET; + System.arraycopy(args, 0, newArgs, 1, args.length); + IApplicationContext ac= new MockApplicationContext(newArgs); app.start(ac); } @@ -309,73 +316,93 @@ public class GeneratePDOMApplicationTest extends PDOMTestBase { */ public static class TestProjectProvider1 implements IExportProjectProvider { + @Override public ICProject createProject() throws CoreException {return null;} + @Override public Map getExportProperties() {return null;} + @Override public IIndexLocationConverter getLocationConverter(ICProject cproject) {return null;} + @Override public void setApplicationArguments(String[] arguments) {} } public static class TestProjectProvider2 implements IExportProjectProvider { + @Override public ICProject createProject() throws CoreException { ICProject cproject= CProjectHelper.createCCProject("test"+System.currentTimeMillis(), null, IPDOMManager.ID_NO_INDEXER); toDeleteOnTearDown.add(cproject); CProjectHelper.importSourcesFromPlugin(cproject, CTestPlugin.getDefault().getBundle(), LOC_TSTPRJ1); return cproject; } + @Override public Map getExportProperties() {return null;} + @Override public IIndexLocationConverter getLocationConverter(ICProject cproject) {return null;} + @Override public void setApplicationArguments(String[] arguments) {} } public static class TestProjectProvider3 implements IExportProjectProvider { + @Override public ICProject createProject() throws CoreException { ICProject cproject= CProjectHelper.createCCProject("test"+System.currentTimeMillis(), null, IPDOMManager.ID_NO_INDEXER); toDeleteOnTearDown.add(cproject); CProjectHelper.importSourcesFromPlugin(cproject, CTestPlugin.getDefault().getBundle(), LOC_TSTPRJ1); return cproject; } + @Override public Map getExportProperties() {return null;} + @Override public IIndexLocationConverter getLocationConverter(ICProject cproject) { return new ResourceContainerRelativeLocationConverter(cproject.getProject()); } + @Override public void setApplicationArguments(String[] arguments) {} } public static class TestProjectProvider4 implements IExportProjectProvider { + @Override public ICProject createProject() throws CoreException { ICProject cproject= CProjectHelper.createCCProject("test"+System.currentTimeMillis(), null, IPDOMManager.ID_NO_INDEXER); toDeleteOnTearDown.add(cproject); CProjectHelper.importSourcesFromPlugin(cproject, CTestPlugin.getDefault().getBundle(), LOC_TSTPRJ1); return cproject; } + @Override public Map getExportProperties() { Map map= new HashMap(); map.put(SDK_VERSION, "4.0.1"); map.put(IIndexFragment.PROPERTY_FRAGMENT_ID, ACME_SDK_ID); return map; } + @Override public IIndexLocationConverter getLocationConverter(ICProject cproject) { return new ResourceContainerRelativeLocationConverter(cproject.getProject()); } + @Override public void setApplicationArguments(String[] arguments) {} } public static class TestProjectProvider5 implements IExportProjectProvider { + @Override public ICProject createProject() throws CoreException { ICProject cproject= CProjectHelper.createCProject("test"+System.currentTimeMillis(), null, IPDOMManager.ID_NO_INDEXER); toDeleteOnTearDown.add(cproject); CProjectHelper.importSourcesFromPlugin(cproject, CTestPlugin.getDefault().getBundle(), LOC_TSTPRJ3); return cproject; } + @Override public Map getExportProperties() { Map map= new HashMap(); map.put(SDK_VERSION, "4.0.1"); map.put(IIndexFragment.PROPERTY_FRAGMENT_ID, ACME_SDK_ID); return map; } + @Override public IIndexLocationConverter getLocationConverter(ICProject cproject) { return new ResourceContainerRelativeLocationConverter(cproject.getProject()); } + @Override public void setApplicationArguments(String[] arguments) {} } } @@ -386,13 +413,22 @@ class MockApplicationContext implements IApplicationContext { arguments= new HashMap(); arguments.put(APPLICATION_ARGS, appArgs); } + @Override public void applicationRunning() {} + @Override public Map getArguments() {return arguments;} + @Override public String getBrandingApplication() {return null;} + @Override public Bundle getBrandingBundle() {return null;} + @Override public String getBrandingDescription() {return null;} + @Override public String getBrandingId() {return null;} + @Override public String getBrandingName() {return null;} + @Override public String getBrandingProperty(String key) {return null;} + @Override public void setResult(Object result, IApplication application) {} }