001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.activemq.maven;
018
019 import org.apache.activemq.tool.JMSMemtest;
020 import org.apache.maven.plugin.AbstractMojo;
021 import org.apache.maven.plugin.MojoExecutionException;
022
023 /**
024 * Goal which does a memory usage test to check for any memory leak
025 *
026 * @goal memtest
027 * @phase process-sources
028 */
029 public class MemtestMojo extends AbstractMojo {
030
031 /**
032 * @parameter expression="${url}
033 */
034 private String url;
035
036 /**
037 * @parameter expression="${topic}" default-value="true"
038 * @required
039 */
040 private String topic;
041
042 /**
043 * @parameter expression="${connectionCheckpointSize}" default-value="-1"
044 * @required
045 */
046 private String connectionCheckpointSize;
047
048 /**
049 * @parameter expression="${durable}" default-value="false"
050 * @required
051 */
052 private String durable;
053
054 /**
055 * @parameter expression="${producerCount}" default-value="1"
056 * @required
057 */
058 private String producerCount;
059
060 /**
061 * @parameter expression="${prefetchSize}" default-value="-1"
062 * @required
063 */
064 private String prefetchSize;
065
066 /**
067 * @parameter expression="${consumerCount}" default-value="1"
068 * @required
069 */
070 private String consumerCount;
071
072 /**
073 * @parameter expression="${messageCount}" default-value="100000"
074 * @required
075 */
076 private String messageCount;
077
078 /**
079 * @parameter expression="${messageSize}" default-value="10240"
080 * @required
081 */
082 private String messageSize;
083
084 /**
085 * @parameter expression="${checkpointInterval}" default-value="2"
086 * @required
087 */
088 private String checkpointInterval;
089
090 /**
091 * @parameter expression="${destinationName}" default-value="FOO.BAR"
092 * @required
093 */
094 private String destinationName;
095
096 /**
097 * @parameter expression="${reportName}"
098 * default-value="activemq-memory-usage-report"
099 * @required
100 */
101 private String reportName;
102
103 /**
104 * @parameter expression="${reportDirectory}"
105 * default-value="${project.build.directory}/test-memtest"
106 * @required
107 */
108 private String reportDirectory;
109
110 public void execute() throws MojoExecutionException {
111
112 JMSMemtest.main(createArgument());
113 }
114
115 public String[] createArgument() {
116 String[] options = {
117 "url=" + url, "topic=" + topic, "durable=" + durable, "connectionCheckpointSize=" + connectionCheckpointSize, "producerCount=" + producerCount, "consumerCount=" + consumerCount,
118 "messageCount=" + messageCount, "messageSize=" + messageSize, "checkpointInterval=" + checkpointInterval, "destinationName=" + destinationName, "reportName=" + reportName,
119 "prefetchSize=" + prefetchSize, "reportDirectory=" + reportDirectory,
120 };
121 return options;
122 }
123 }