12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- /********************************************************************
- * Copyright (c) 2007 Contributors. All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- * Helen Hawkins - initial version
- *******************************************************************/
- package org.aspectj.ajde.core;
-
- import java.util.ArrayList;
- import java.util.List;
-
- /**
- * Test implementation of IBuildProgressMonitor which prints out
- * progress to the console and enables users to cancel the build process
- * after a specified string has been printed.
- */
- public class TestBuildProgressMonitor implements IBuildProgressMonitor {
-
- private static boolean debugTests = false;
-
- public int numWovenClassMessages = 0;
- public int numWovenAspectMessages = 0;
- public int numCompiledMessages = 0;
-
- private String programmableString;
- private int count;
- private List<String> messagesReceived = new ArrayList<String>();
- private int currentVal;
- private boolean isCancelRequested = false;
-
- public void finish(boolean wasFullBuild) {
- System.out.println("build finished. Was full build: " + wasFullBuild);
- }
-
- public boolean isCancelRequested() {
- return isCancelRequested;
- }
-
- public void setProgress(double percentDone) {
- System.out.println("progress. Completed " + percentDone + " percent");
- }
-
- public void setProgressText(String text) {
- System.out.println("progress text: " + text);
- String newText = text+" [Percentage="+currentVal+"%]";
- messagesReceived.add(newText);
- if (text.startsWith("woven aspect ")) numWovenAspectMessages++;
- if (text.startsWith("woven class ")) numWovenClassMessages++;
- if (text.startsWith("compiled:")) numCompiledMessages++;
- if (programmableString != null
- && text.indexOf(programmableString) != -1) {
- count--;
- if (count==0) {
- if (debugTests) System.out.println("Just got message '"+newText+"' - asking build to cancel");
- isCancelRequested = true;
- programmableString = null;
- }
- }
- }
-
- public void begin() {
- System.out.println("build started");
- currentVal = 0;
- }
-
- // ------------- methods to help with testing -------------
- public void cancelOn(String string,int count) {
- programmableString = string;
- this.count = count;
- }
-
- public boolean containsMessage(String prefix,String distinguishingMarks) {
- for (String element: messagesReceived) {
- if (element.startsWith(prefix) &&
- element.indexOf(distinguishingMarks)!=-1) return true;
- }
- return false;
- }
-
- public void dumpMessages() {
- System.out.println("ProgressMonitorMessages");
- for (String element: messagesReceived) {
- System.out.println(element);
- }
- }
-
- }
|