geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jboy...@apache.org
Subject svn commit: r123542 - /geronimo/trunk/specs/activation/src/java/javax/activation/MailcapCommandMap.java /geronimo/trunk/specs/activation/src/test/javax/activation/MailcapCommandMapTest.java
Date Tue, 28 Dec 2004 19:58:12 GMT
Author: jboynes
Date: Tue Dec 28 11:58:10 2004
New Revision: 123542

URL: http://svn.apache.org/viewcvs?view=rev&rev=123542
Log:
add simple test for mailcap parser
Added:
   geronimo/trunk/specs/activation/src/test/javax/activation/MailcapCommandMapTest.java
Modified:
   geronimo/trunk/specs/activation/src/java/javax/activation/MailcapCommandMap.java

Modified: geronimo/trunk/specs/activation/src/java/javax/activation/MailcapCommandMap.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/specs/activation/src/java/javax/activation/MailcapCommandMap.java?view=diff&rev=123542&p1=geronimo/trunk/specs/activation/src/java/javax/activation/MailcapCommandMap.java&r1=123541&p2=geronimo/trunk/specs/activation/src/java/javax/activation/MailcapCommandMap.java&r2=123542
==============================================================================
--- geronimo/trunk/specs/activation/src/java/javax/activation/MailcapCommandMap.java	(original)
+++ geronimo/trunk/specs/activation/src/java/javax/activation/MailcapCommandMap.java	Tue Dec
28 11:58:10 2004
@@ -45,12 +45,12 @@
         // process /META-INF/mailcap.default
         try {
             InputStream is = MailcapCommandMap.class.getResourceAsStream("/META-INF/mailcap.default");
-            try {
-                if (is != null) {
+            if (is != null) {
+                try {
                     parseMailcap(is);
+                } finally {
+                    is.close();
                 }
-            } finally {
-                is.close();
             }
         } catch (IOException e) {
             // ignore
@@ -187,7 +187,7 @@
         }
 
         // parse fields
-        while (index < mail_cap.length() || mail_cap.charAt(index) == ';') {
+        while (index < mail_cap.length() && mail_cap.charAt(index) == ';') {
             index = skipSpace(mail_cap, index + 1);
             start = index;
             index = getToken(mail_cap, index);

Added: geronimo/trunk/specs/activation/src/test/javax/activation/MailcapCommandMapTest.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/specs/activation/src/test/javax/activation/MailcapCommandMapTest.java?view=auto&rev=123542
==============================================================================
--- (empty file)
+++ geronimo/trunk/specs/activation/src/test/javax/activation/MailcapCommandMapTest.java	Tue
Dec 28 11:58:10 2004
@@ -0,0 +1,48 @@
+/**
+ *
+ * Copyright 2003-2004 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.
+ */
+
+//
+// This source code implements specifications defined by the Java
+// Community Process. In order to remain compliant with the specification
+// DO NOT add / change / or delete method signatures!
+//
+package javax.activation;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MailcapCommandMapTest extends TestCase {
+    private MailcapCommandMap map;
+
+    public void testAdd() {
+        map.addMailcap("foo/bar ;; x-java-view=Foo; x-java-edit=Bar");
+        CommandInfo info = map.getCommand("foo/bar", "view");
+        assertEquals("view", info.getCommandName());
+        assertEquals("Foo", info.getCommandClass());
+        info = map.getCommand("foo/bar", "edit");
+        assertEquals("edit", info.getCommandName());
+        assertEquals("Bar", info.getCommandClass());
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        map = new MailcapCommandMap();
+    }
+
+}

Mime
View raw message