activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1489994 - in /activemq/trunk: activemq-client/src/main/java/org/apache/activemq/blob/ activemq-client/src/main/java/org/apache/activemq/command/ activemq-unit-tests/src/test/java/org/apache/activemq/blob/
Date Wed, 05 Jun 2013 18:29:35 GMT
Author: tabish
Date: Wed Jun  5 18:29:35 2013
New Revision: 1489994

URL: http://svn.apache.org/r1489994
Log:
Fix test failure after recent MessageId changes.

Modified:
    activemq/trunk/activemq-client/src/main/java/org/apache/activemq/blob/FTPBlobUploadStrategy.java
    activemq/trunk/activemq-client/src/main/java/org/apache/activemq/command/MessageId.java
    activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/blob/FTPBlobUploadStrategyTest.java

Modified: activemq/trunk/activemq-client/src/main/java/org/apache/activemq/blob/FTPBlobUploadStrategy.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-client/src/main/java/org/apache/activemq/blob/FTPBlobUploadStrategy.java?rev=1489994&r1=1489993&r2=1489994&view=diff
==============================================================================
--- activemq/trunk/activemq-client/src/main/java/org/apache/activemq/blob/FTPBlobUploadStrategy.java
(original)
+++ activemq/trunk/activemq-client/src/main/java/org/apache/activemq/blob/FTPBlobUploadStrategy.java
Wed Jun  5 18:29:35 2013
@@ -32,41 +32,43 @@ import org.apache.commons.net.ftp.FTPCli
  * A FTP implementation of {@link BlobUploadStrategy}.
  */
 public class FTPBlobUploadStrategy extends FTPStrategy implements BlobUploadStrategy {
-	
-	public FTPBlobUploadStrategy(BlobTransferPolicy transferPolicy) throws MalformedURLException
{
-		super(transferPolicy);
-	}
-
-	public URL uploadFile(ActiveMQBlobMessage message, File file) throws JMSException, IOException
{
-		return uploadStream(message, new FileInputStream(file));
-	}
-
-	public URL uploadStream(ActiveMQBlobMessage message, InputStream in)
-			throws JMSException, IOException {
-
-	    FTPClient ftp = createFTP();
-	    try {
-    		String path = url.getPath();
+
+    public FTPBlobUploadStrategy(BlobTransferPolicy transferPolicy) throws MalformedURLException
{
+        super(transferPolicy);
+    }
+
+    @Override
+    public URL uploadFile(ActiveMQBlobMessage message, File file) throws JMSException, IOException
{
+        return uploadStream(message, new FileInputStream(file));
+    }
+
+    @Override
+    public URL uploadStream(ActiveMQBlobMessage message, InputStream in)
+            throws JMSException, IOException {
+
+        FTPClient ftp = createFTP();
+        try {
+            String path = url.getPath();
             String workingDir = path.substring(0, path.lastIndexOf("/"));
-    		String filename = message.getMessageId().toString().replaceAll(":", "_");
+            String filename = message.getMessageId().toString().replaceAll(":", "_");
             ftp.setFileType(FTPClient.BINARY_FILE_TYPE);
-            
+
             String url;
             if(!ftp.changeWorkingDirectory(workingDir)) {
-            	url = this.url.toString().replaceFirst(this.url.getPath(), "")+"/";
+                url = this.url.toString().replaceFirst(this.url.getPath(), "")+"/";
             } else {
-            	url = this.url.toString();
+                url = this.url.toString();
+            }
+
+            if (!ftp.storeFile(filename, in)) {
+                throw new JMSException("FTP store failed: " + ftp.getReplyString());
             }
-            
-    		if (!ftp.storeFile(filename, in)) {
-    		    throw new JMSException("FTP store failed: " + ftp.getReplyString());
-    		}
-    		return new URL(url + filename);
-	    } finally {
-    		ftp.quit();
-    		ftp.disconnect();
-	    }
-		
-	}
+            return new URL(url + filename);
+        } finally {
+            ftp.quit();
+            ftp.disconnect();
+        }
+
+    }
 
 }

Modified: activemq/trunk/activemq-client/src/main/java/org/apache/activemq/command/MessageId.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-client/src/main/java/org/apache/activemq/command/MessageId.java?rev=1489994&r1=1489993&r2=1489994&view=diff
==============================================================================
--- activemq/trunk/activemq-client/src/main/java/org/apache/activemq/command/MessageId.java
(original)
+++ activemq/trunk/activemq-client/src/main/java/org/apache/activemq/command/MessageId.java
Wed Jun  5 18:29:35 2013
@@ -77,9 +77,8 @@ public class MessageId implements DataSt
     }
 
     /**
-     * Sets the transient text view of the message which will be ignored if the
-     * message is marshaled on a transport; so is only for in-JVM changes to
-     * accommodate foreign JMS message IDs
+     * Sets the transient text view of the message which will be ignored if the message is
marshaled on a transport; so
+     * is only for in-JVM changes to accommodate foreign JMS message IDs
      */
     public void setTextView(String key) {
         this.textView = key;
@@ -107,20 +106,20 @@ public class MessageId implements DataSt
             return false;
         }
 
-        MessageId id = (MessageId)o;
+        MessageId id = (MessageId) o;
         return producerSequenceId == id.producerSequenceId && producerId.equals(id.producerId);
     }
 
     @Override
     public int hashCode() {
         if (hashCode == 0) {
-            hashCode = producerId.hashCode() ^ (int)producerSequenceId;
+            hashCode = producerId.hashCode() ^ (int) producerSequenceId;
         }
         return hashCode;
     }
 
     public String toProducerKey() {
-        if( textView==null ) {
+        if (textView == null) {
             return toString();
         } else {
             return producerId.toString() + ":" + producerSequenceId;
@@ -130,11 +129,11 @@ public class MessageId implements DataSt
     @Override
     public String toString() {
         if (key == null) {
-            if( textView!=null ) {
-                if( textView.startsWith("ID:") ) {
+            if (textView != null) {
+                if (textView.startsWith("ID:")) {
                     key = textView;
                 } else {
-                    key = "ID:"+textView;
+                    key = "ID:" + textView;
                 }
             } else {
                 key = producerId.toString() + ":" + producerSequenceId;
@@ -207,16 +206,14 @@ public class MessageId implements DataSt
     }
 
     /**
-     * @return a locator which aids a message store in loading a message faster.  Only used
-     * by the message stores.
+     * @return a locator which aids a message store in loading a message faster. Only used
by the message stores.
      */
     public Object getDataLocator() {
         return dataLocator.get();
     }
 
     /**
-     * Sets a locator which aids a message store in loading a message faster.  Only used
-     * by the message stores.
+     * Sets a locator which aids a message store in loading a message faster. Only used by
the message stores.
      */
     public void setDataLocator(Object value) {
         this.dataLocator.set(value);

Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/blob/FTPBlobUploadStrategyTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/blob/FTPBlobUploadStrategyTest.java?rev=1489994&r1=1489993&r2=1489994&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/blob/FTPBlobUploadStrategyTest.java
(original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/blob/FTPBlobUploadStrategyTest.java
Wed Jun  5 18:29:35 2013
@@ -26,7 +26,6 @@ import javax.jms.Session;
 import org.apache.activemq.ActiveMQConnection;
 import org.apache.activemq.ActiveMQSession;
 import org.apache.activemq.command.ActiveMQBlobMessage;
-import org.apache.activemq.command.MessageId;
 
 
 public class FTPBlobUploadStrategyTest extends FTPTestSupport {
@@ -43,10 +42,10 @@ public class FTPBlobUploadStrategyTest e
         ((ActiveMQConnection)connection).setCopyMessageOnSend(false);
 
         ActiveMQBlobMessage message = (ActiveMQBlobMessage) ((ActiveMQSession)session).createBlobMessage(file);
-        message.setMessageId(new MessageId("testmessage"));
+        message.setJMSMessageID("testmessage");
         message.onSend();
-        assertEquals(ftpUrl + "testmessage", message.getURL().toString());
-        File uploaded = new File(ftpHomeDirFile, "testmessage");
+        assertEquals(ftpUrl + "ID_testmessage", message.getURL().toString());
+        File uploaded = new File(ftpHomeDirFile, "ID_testmessage");
         assertTrue("File doesn't exists", uploaded.exists());
     }
 
@@ -63,7 +62,7 @@ public class FTPBlobUploadStrategyTest e
         ((ActiveMQConnection)connection).setCopyMessageOnSend(false);
 
         ActiveMQBlobMessage message = (ActiveMQBlobMessage) ((ActiveMQSession)session).createBlobMessage(file);
-        message.setMessageId(new MessageId("testmessage"));
+        message.setJMSMessageID("testmessage");
         try {
             message.onSend();
         } catch (JMSException e) {



Mime
View raw message