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 */
017package org.apache.activemq.maven;
018
019import org.apache.activemq.tool.JMSMemtest;
020import org.apache.maven.plugin.AbstractMojo;
021import 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 */
029public class MemtestMojo extends AbstractMojo {
030
031    /**
032     * @parameter property="url"
033     */
034    private String url;
035
036    /**
037     * @parameter property="topic" default-value="true"
038     * @required
039     */
040    private String topic;
041
042    /**
043     * @parameter property="connectionCheckpointSize" default-value="-1"
044     * @required
045     */
046    private String connectionCheckpointSize;
047
048    /**
049     * @parameter property="durable" default-value="false"
050     * @required
051     */
052    private String durable;
053
054    /**
055     * @parameter property="producerCount" default-value="1"
056     * @required
057     */
058    private String producerCount;
059
060    /**
061     * @parameter property="prefetchSize" default-value="-1"
062     * @required
063     */
064    private String prefetchSize;
065
066    /**
067     * @parameter property="consumerCount" default-value="1"
068     * @required
069     */
070    private String consumerCount;
071
072    /**
073     * @parameter property="messageCount" default-value="100000"
074     * @required
075     */
076    private String messageCount;
077
078    /**
079     * @parameter property="messageSize" default-value="10240"
080     * @required
081     */
082    private String messageSize;
083
084    /**
085     * @parameter property="checkpointInterval" default-value="2"
086     * @required
087     */
088    private String checkpointInterval;
089
090    /**
091     * @parameter property="destinationName" default-value="FOO.BAR"
092     * @required
093     */
094    private String destinationName;
095
096    /**
097     * @parameter property="$reportName"
098     *            default-value="activemq-memory-usage-report"
099     * @required
100     */
101    private String reportName;
102
103    /**
104     * @parameter property="reportDirectory"
105     *            default-value="${project.build.directory}/test-memtest"
106     * @required
107     */
108    private String reportDirectory;
109
110    @Override
111    public void execute() throws MojoExecutionException {
112
113        JMSMemtest.main(createArgument());
114    }
115
116    public String[] createArgument() {
117        String[] options = {
118            "url=" + url, "topic=" + topic, "durable=" + durable, "connectionCheckpointSize=" + connectionCheckpointSize, "producerCount=" + producerCount, "consumerCount=" + consumerCount,
119            "messageCount=" + messageCount, "messageSize=" + messageSize, "checkpointInterval=" + checkpointInterval, "destinationName=" + destinationName, "reportName=" + reportName,
120            "prefetchSize=" + prefetchSize, "reportDirectory=" + reportDirectory,
121        };
122        return options;
123    }
124}