You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bo...@apache.org on 2005/07/04 15:35:48 UTC
svn commit: r209074 -
/ant/sandbox/antlibs/antunit/trunk/src/testcases/org/apache/ant/antunit/LogCapturerTest.java
Author: bodewig
Date: Mon Jul 4 06:35:46 2005
New Revision: 209074
URL: http://svn.apache.org/viewcvs?rev=209074&view=rev
Log:
forgot to add testcase
Added:
ant/sandbox/antlibs/antunit/trunk/src/testcases/org/apache/ant/antunit/LogCapturerTest.java (with props)
Added: ant/sandbox/antlibs/antunit/trunk/src/testcases/org/apache/ant/antunit/LogCapturerTest.java
URL: http://svn.apache.org/viewcvs/ant/sandbox/antlibs/antunit/trunk/src/testcases/org/apache/ant/antunit/LogCapturerTest.java?rev=209074&view=auto
==============================================================================
--- ant/sandbox/antlibs/antunit/trunk/src/testcases/org/apache/ant/antunit/LogCapturerTest.java (added)
+++ ant/sandbox/antlibs/antunit/trunk/src/testcases/org/apache/ant/antunit/LogCapturerTest.java Mon Jul 4 06:35:46 2005
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.ant.antunit;
+
+import org.apache.tools.ant.BuildEvent;
+import org.apache.tools.ant.Project;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+public class LogCapturerTest extends TestCase {
+
+ public LogCapturerTest(String name) {
+ super(name);
+ }
+
+ public void testAddAsReference() {
+ Project p = new Project();
+ LogCapturer c = new LogCapturer(p);
+ assertSame(c, p.getReference(LogCapturer.REFERENCE_ID));
+ }
+
+ public void testMessagePriorities() {
+ Project p = new Project();
+ LogCapturer c = new LogCapturer(p);
+
+ String[] messages = new String[] {"err", "warn", "info", "verbose",
+ "debug"};
+ for (int i = 0; i < messages.length; i++) {
+ BuildEvent be = new BuildEvent(p);
+ be.setMessage(messages[i], i);
+ c.messageLogged(be);
+ }
+ assertMessages(c.getErrLog(), messages, Project.MSG_ERR);
+ assertMessages(c.getWarnLog(), messages, Project.MSG_WARN);
+ assertMessages(c.getInfoLog(), messages, Project.MSG_INFO);
+ assertMessages(c.getVerboseLog(), messages, Project.MSG_VERBOSE);
+ assertMessages(c.getDebugLog(), messages, Project.MSG_DEBUG);
+ }
+
+ private static void assertMessages(String actual, String[] messages,
+ int upTo) {
+ for (int i = 0; i <= upTo && i < messages.length; i++) {
+ Assert.assertTrue("checking for " + messages[i] + " in " + actual,
+ actual.indexOf(messages[i]) > -1);
+ }
+ for (int i = upTo + 1; i < messages.length; i++) {
+ Assert.assertTrue("checking for " + messages[i] + " in " + actual,
+ actual.indexOf(messages[i]) == -1);
+ }
+ }
+}
\ No newline at end of file
Propchange: ant/sandbox/antlibs/antunit/trunk/src/testcases/org/apache/ant/antunit/LogCapturerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org