geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jboy...@apache.org
Subject svn commit: r180468 - in /geronimo/trunk: modules/assembly/src/plan/ specs/activation/src/java/javax/activation/ specs/activation/src/test/javax/activation/ specs/javamail/src/java/javax/mail/internet/ specs/javamail/src/test/javax/mail/internet/
Date Mon, 06 Jun 2005 20:32:41 GMT
Author: jboynes
Date: Mon Jun  6 13:32:39 2005
New Revision: 180468

URL: http://svn.apache.org/viewcvs?rev=180468&view=rev
Log:
fix race condition setting up DataSource pump

Added:
    geronimo/trunk/specs/activation/src/test/javax/activation/DataHandlerTest.java
Modified:
    geronimo/trunk/modules/assembly/src/plan/j2ee-client-plan.xml
    geronimo/trunk/specs/activation/src/java/javax/activation/DataHandler.java
    geronimo/trunk/specs/javamail/src/java/javax/mail/internet/MimeMultipart.java
    geronimo/trunk/specs/javamail/src/test/javax/mail/internet/MimeMessageTest.java
    geronimo/trunk/specs/javamail/src/test/javax/mail/internet/MimeMultipartTest.java

Modified: geronimo/trunk/modules/assembly/src/plan/j2ee-client-plan.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/assembly/src/plan/j2ee-client-plan.xml?rev=180468&r1=180467&r2=180468&view=diff
==============================================================================
--- geronimo/trunk/modules/assembly/src/plan/j2ee-client-plan.xml (original)
+++ geronimo/trunk/modules/assembly/src/plan/j2ee-client-plan.xml Mon Jun  6 13:32:39 2005
@@ -43,6 +43,9 @@
         <uri>geronimo/jars/geronimo-security-${geronimo_version}.jar</uri>
     </dependency>
     <dependency>
+        <uri>geronimo/jars/geronimo-activation-${geronimo_version}.jar</uri>
+    </dependency>
+    <dependency>
         <uri>openejb/jars/openejb-core-${openejb_version}.jar</uri>
     </dependency>
 

Modified: geronimo/trunk/specs/activation/src/java/javax/activation/DataHandler.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/specs/activation/src/java/javax/activation/DataHandler.java?rev=180468&r1=180467&r2=180468&view=diff
==============================================================================
--- geronimo/trunk/specs/activation/src/java/javax/activation/DataHandler.java (original)
+++ geronimo/trunk/specs/activation/src/java/javax/activation/DataHandler.java Mon Jun  6
13:32:39 2005
@@ -73,7 +73,7 @@
             ObjectDataSource ods = (ObjectDataSource) ds;
             DataContentHandler dch = getDataContentHandler();
             if (dch == null) {
-                throw new UnsupportedDataTypeException();
+                throw new UnsupportedDataTypeException(ods.mimeType);
             }
             dch.writeTo(ods.data, ods.mimeType, os);
         } else {
@@ -185,11 +185,10 @@
                 throw new UnsupportedDataTypeException(mimeType);
             }
             final PipedInputStream is = new PipedInputStream();
-            Thread thread = new Thread() {
+            final PipedOutputStream os = new PipedOutputStream(is);
+            Thread thread = new Thread("DataHandler Pipe Pump") {
                 public void run() {
                     try {
-                        PipedOutputStream os = new PipedOutputStream(is);
-                        is.connect(os);
                         try {
                             dch.writeTo(data, mimeType, os);
                         } finally {

Added: geronimo/trunk/specs/activation/src/test/javax/activation/DataHandlerTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/specs/activation/src/test/javax/activation/DataHandlerTest.java?rev=180468&view=auto
==============================================================================
--- geronimo/trunk/specs/activation/src/test/javax/activation/DataHandlerTest.java (added)
+++ geronimo/trunk/specs/activation/src/test/javax/activation/DataHandlerTest.java Mon Jun
 6 13:32:39 2005
@@ -0,0 +1,75 @@
+/**
+ *
+ * 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.
+ */
+
+//
+// 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 java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.UnsupportedFlavorException;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class DataHandlerTest extends TestCase {
+    private CommandMap defaultMap;
+
+    public void testObjectInputStream() throws IOException {
+        DataHandler handler = new DataHandler("Hello World", "text/plain");
+        InputStream is = handler.getInputStream();
+        byte[] bytes = new byte[128];
+        assertEquals(11, is.read(bytes));
+        assertEquals("Hello World", new String(bytes, 0, 11));
+    }
+
+    protected void setUp() throws Exception {
+        defaultMap = CommandMap.getDefaultCommandMap();
+        MailcapCommandMap myMap = new MailcapCommandMap();
+        myMap.addMailcap("text/plain;;    x-java-content-handler=" + DummyTextHandler.class.getName());
+        CommandMap.setDefaultCommandMap(myMap);
+    }
+
+    protected void tearDown() throws Exception {
+        CommandMap.setDefaultCommandMap(defaultMap);
+    }
+
+    public static class DummyTextHandler implements DataContentHandler {
+        public DataFlavor[] getTransferDataFlavors() {
+            throw new UnsupportedOperationException();
+        }
+
+        public Object getTransferData(DataFlavor df, DataSource ds) throws UnsupportedFlavorException,
IOException {
+            throw new UnsupportedOperationException();
+        }
+
+        public Object getContent(DataSource ds) throws IOException {
+            throw new UnsupportedOperationException();
+        }
+
+        public void writeTo(Object obj, String mimeType, OutputStream os) throws IOException
{
+            os.write(((String)obj).getBytes());
+        }
+    }
+}

Modified: geronimo/trunk/specs/javamail/src/java/javax/mail/internet/MimeMultipart.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/specs/javamail/src/java/javax/mail/internet/MimeMultipart.java?rev=180468&r1=180467&r2=180468&view=diff
==============================================================================
--- geronimo/trunk/specs/javamail/src/java/javax/mail/internet/MimeMultipart.java (original)
+++ geronimo/trunk/specs/javamail/src/java/javax/mail/internet/MimeMultipart.java Mon Jun
 6 13:32:39 2005
@@ -20,7 +20,6 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.io.PrintStream;
 import javax.activation.DataSource;
 import javax.mail.BodyPart;
 import javax.mail.MessagingException;
@@ -129,6 +128,7 @@
         }
         out.write(dash);
         out.write(bytes);
+        out.write(dash);
         out.write(crlf);
         out.flush();
     }

Modified: geronimo/trunk/specs/javamail/src/test/javax/mail/internet/MimeMessageTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/specs/javamail/src/test/javax/mail/internet/MimeMessageTest.java?rev=180468&r1=180467&r2=180468&view=diff
==============================================================================
--- geronimo/trunk/specs/javamail/src/test/javax/mail/internet/MimeMessageTest.java (original)
+++ geronimo/trunk/specs/javamail/src/test/javax/mail/internet/MimeMessageTest.java Mon Jun
 6 13:32:39 2005
@@ -34,22 +34,25 @@
     private Session session;
 
     public void testWriteTo() throws MessagingException, IOException {
-/*
         MimeMessage msg = new MimeMessage(session);
         msg.setSender(new InternetAddress("foo"));
         MimeMultipart mp = new MimeMultipart();
         MimeBodyPart part1 = new MimeBodyPart();
+        part1.setHeader("foo", "bar");
         part1.setContent("Hello World", "text/plain");
         mp.addBodyPart(part1);
+        MimeBodyPart part2 = new MimeBodyPart();
+        part2.setContent("Hello Again", "text/plain");
+        mp.addBodyPart(part2);
         msg.setContent(mp);
         msg.writeTo(System.out);
-*/
     }
 
     protected void setUp() throws Exception {
         defaultMap = CommandMap.getDefaultCommandMap();
         MailcapCommandMap myMap = new MailcapCommandMap();
         myMap.addMailcap("text/plain;;    x-java-content-handler=" + MimeMultipartTest.DummyTextHandler.class.getName());
+        myMap.addMailcap("multipart/*;;    x-java-content-handler=" + MimeMultipartTest.DummyMultipartHandler.class.getName());
         CommandMap.setDefaultCommandMap(myMap);
         session = Session.getDefaultInstance(new Properties());
     }

Modified: geronimo/trunk/specs/javamail/src/test/javax/mail/internet/MimeMultipartTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/specs/javamail/src/test/javax/mail/internet/MimeMultipartTest.java?rev=180468&r1=180467&r2=180468&view=diff
==============================================================================
--- geronimo/trunk/specs/javamail/src/test/javax/mail/internet/MimeMultipartTest.java (original)
+++ geronimo/trunk/specs/javamail/src/test/javax/mail/internet/MimeMultipartTest.java Mon
Jun  6 13:32:39 2005
@@ -28,7 +28,6 @@
 import java.awt.datatransfer.UnsupportedFlavorException;
 import javax.mail.MessagingException;
 import javax.activation.CommandMap;
-import javax.activation.DataHandler;
 import javax.activation.MailcapCommandMap;
 import javax.activation.DataContentHandler;
 import javax.activation.DataSource;
@@ -44,6 +43,7 @@
     public void testWriteTo() throws MessagingException, IOException {
         MimeMultipart mp = new MimeMultipart();
         MimeBodyPart part1 = new MimeBodyPart();
+        part1.setHeader("foo", "bar");
         part1.setContent("Hello World", "text/plain");
         mp.addBodyPart(part1);
         MimeBodyPart part2 = new MimeBodyPart();
@@ -56,6 +56,7 @@
         defaultMap = CommandMap.getDefaultCommandMap();
         MailcapCommandMap myMap = new MailcapCommandMap();
         myMap.addMailcap("text/plain;;    x-java-content-handler=" + DummyTextHandler.class.getName());
+        myMap.addMailcap("multipart/*;;    x-java-content-handler=" + DummyMultipartHandler.class.getName());
         CommandMap.setDefaultCommandMap(myMap);
     }
 
@@ -83,19 +84,24 @@
 
     public static class DummyMultipartHandler implements DataContentHandler {
         public DataFlavor[] getTransferDataFlavors() {
-            return new DataFlavor[0];  //To change body of implemented methods use File |
Settings | File Templates.
+            throw new UnsupportedOperationException();
         }
 
         public Object getTransferData(DataFlavor df, DataSource ds) throws UnsupportedFlavorException,
IOException {
-            return null;  //To change body of implemented methods use File | Settings | File
Templates.
+            throw new UnsupportedOperationException();
         }
 
         public Object getContent(DataSource ds) throws IOException {
-            return null;  //To change body of implemented methods use File | Settings | File
Templates.
+            throw new UnsupportedOperationException();
         }
 
         public void writeTo(Object obj, String mimeType, OutputStream os) throws IOException
{
-            os.write(((String)obj).getBytes());
+            MimeMultipart mp = (MimeMultipart) obj;
+            try {
+                mp.writeTo(os);
+            } catch (MessagingException e) {
+                throw (IOException) new IOException(e.getMessage()).initCause(e);
+            }
         }
     }
 }



Mime
View raw message