source: other-projects/trunk/gs3-release-maker/apache-ant-1.6.5/src/testcases/org/apache/tools/ant/MockBuildListener.java@ 14627

Last change on this file since 14627 was 14627, checked in by oranfry, 17 years ago

initial import of the gs3-release-maker

File size: 2.2 KB
Line 
1/*
2 * Copyright 2001,2004 The Apache Software Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18package org.apache.tools.ant;
19
20import java.util.Vector;
21
22import junit.framework.Assert;
23
24public class MockBuildListener extends Assert implements BuildListener {
25
26 private final Vector buffer = new Vector();
27 private final Project project;
28
29 public MockBuildListener(final Project project) {
30 this.project = project;
31 }
32
33 public void buildStarted(BuildEvent event) {}
34 public void buildFinished(BuildEvent event) {}
35 public void targetStarted(BuildEvent event) {}
36 public void targetFinished(BuildEvent event) {}
37 public void taskStarted(BuildEvent event) {}
38 public void taskFinished(BuildEvent event) {}
39
40 public void messageLogged(final BuildEvent actual) {
41 if(actual.getPriority()==Project.MSG_DEBUG)
42 return;
43 assertTrue("unexpected messageLogged: "+actual.getMessage(), !buffer.isEmpty());
44 assertEquals("unexpected project ", project, actual.getProject());
45
46 BuildEvent expected = (BuildEvent) buffer.elementAt(0);
47 buffer.removeElementAt(0);
48 assertEquals("unexpected messageLogged ", expected.getMessage(), actual.getMessage());
49 assertEquals("unexpected priority ", expected.getPriority(), actual.getPriority());
50 }
51
52 public void assertEmpty() {
53 assertTrue("MockBuildListener is not empty", buffer.isEmpty());
54 }
55
56 public void addBuildEvent(final String message, final int priority) {
57 final BuildEvent be = new BuildEvent(project);
58 be.setMessage(message, priority);
59 buffer.addElement(be);
60 }
61
62}
Note: See TracBrowser for help on using the repository browser.