You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@activemq.apache.org by GitBox <gi...@apache.org> on 2019/11/06 14:07:41 UTC

[GitHub] [activemq] tabish121 commented on a change in pull request #410: [AMQ-7327] Use maxFrameSize to limit HTTP content length

tabish121 commented on a change in pull request #410: [AMQ-7327] Use maxFrameSize to limit HTTP content length
URL: https://github.com/apache/activemq/pull/410#discussion_r343112507
 
 

 ##########
 File path: activemq-http/src/test/java/org/apache/activemq/transport/http/HttpMaxFrameSizeTest.java
 ##########
 @@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.activemq.transport.http;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.command.ActiveMQQueue;
+import org.apache.commons.lang.StringUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+public class HttpMaxFrameSizeTest {
+
+    protected BrokerService brokerService;
+
+    @Before
+    public void setup() throws Exception {
+        brokerService = new BrokerService();
+        brokerService.setPersistent(false);
+        brokerService.setUseJmx(false);
+        brokerService.deleteAllMessages();
+        brokerService.addConnector("http://localhost:8888?wireFormat.maxFrameSize=10");
+        brokerService.start();
+        brokerService.waitUntilStarted();
+    }
+
+    @After
+    public void teardown() throws Exception {
+        brokerService.stop();
+    }
+
+    @Test(expected = JMSException.class)
 
 Review comment:
   Expecting an JMSException on a test that calls many methods that can throw a JMSException doesn't actually test that the change does what you are expecting it to.  The producer send should be the point of test here so that you confirm that it does indeed fail when to large, but also you need some negative validation (send a smaller message) to test that your configuration doesn't get mistakenly applied to smaller messages.  

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services