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