activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r412364 - in /incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src: main/java/org/apache/activemq/tool/ test/ test/java/ test/java/org/ test/java/org/apache/ test/java/org/apache/activemq/ test/java/org/apache/activemq/tool/
Date Wed, 07 Jun 2006 10:58:34 GMT
Author: aco
Date: Wed Jun  7 03:58:34 2006
New Revision: 412364

URL: http://svn.apache.org/viewvc?rev=412364&view=rev
Log:
- Added fix for 1.4/1.5 compatibility issue
- Added fix for wrong counting of tokens
- Added test case for ReflectionUtil.java

Added:
    incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/test/
    incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/test/java/
    incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/test/java/org/
    incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/test/java/org/apache/
    incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/test/java/org/apache/activemq/
    incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/test/java/org/apache/activemq/tool/
    incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/test/java/org/apache/activemq/tool/ReflectionUtilTest.java
Modified:
    incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsClientSystemSupport.java
    incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/ReflectionUtil.java

Modified: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsClientSystemSupport.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsClientSystemSupport.java?rev=412364&r1=412363&r2=412364&view=diff
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsClientSystemSupport.java
(original)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsClientSystemSupport.java
Wed Jun  7 03:58:34 2006
@@ -50,7 +50,7 @@
         performanceSampler.setSamplerSettings(samplerSettings);
 
         PerfReportGenerator report = new PerfReportGenerator();
-        report.setReportName(this.getClass().getCanonicalName());
+        report.setReportName(this.getClass().getName());
         report.setTestSettings(getSettings());
         report.startGenerateReport();
 

Modified: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/ReflectionUtil.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/ReflectionUtil.java?rev=412364&r1=412363&r2=412364&view=diff
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/ReflectionUtil.java
(original)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/ReflectionUtil.java
Wed Jun  7 03:58:34 2006
@@ -43,12 +43,13 @@
             debugInfo = "Invoking: " + targetClass.getName();
 
             StringTokenizer tokenizer = new StringTokenizer(key, ".");
+            int tokenCount = tokenizer.countTokens();
 
             // NOTE: Skip the first token, it is assume that this is an indicator for the
object itself
             tokenizer.nextToken();
 
-            // For nested settings, get the object first
-            for (int j=0; j<tokenizer.countTokens()-1; j++) {
+            // For nested settings, get the object first. -2, do not count the first and
last token
+            for (int j=0; j<tokenCount-2; j++) {
                 // Find getter method first
                 String name = tokenizer.nextToken();
                 String getMethod = "get" + name.substring(0,1).toUpperCase() + name.substring(1);
@@ -96,6 +97,7 @@
                 // For unknown object type, try to call the valueOf method of the object
                 // to convert the string to the target object type
                 } else {
+                    // Note valueOf method should be public and static
                     Object param = propertyType.getMethod("valueOf", new Class[] {String.class}).invoke(null,
new Object[] {val});
                     targetClass.getMethod(setterMethod, new Class[] {propertyType}).invoke(target,
new Object[] {param});
                 }

Added: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/test/java/org/apache/activemq/tool/ReflectionUtilTest.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/test/java/org/apache/activemq/tool/ReflectionUtilTest.java?rev=412364&view=auto
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/test/java/org/apache/activemq/tool/ReflectionUtilTest.java
(added)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/test/java/org/apache/activemq/tool/ReflectionUtilTest.java
Wed Jun  7 03:58:34 2006
@@ -0,0 +1,189 @@
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * Licensed 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.tool;
+
+import junit.framework.TestCase;
+
+import java.util.Properties;
+
+public class ReflectionUtilTest extends TestCase {
+    private boolean booleanData;
+    private int     intData;
+    private long    longData;
+    private short   shortData;
+    private double  doubleData;
+    private float   floatData;
+    private byte    byteData;
+    private char    charData;
+    private String  stringData;
+    private ReflectionUtilTest testData;
+
+    public void testDataTypeConfig() {
+        // Initialize variables;
+        booleanData = false;
+        intData     = 0;
+        longData    = 0;
+        shortData   = 0;
+        doubleData  = 0.0;
+        floatData   = 0.0F;
+        byteData    = 0;
+        charData    = '0';
+        stringData  = "false";
+
+        Object targetObj = new ReflectionUtilTest();
+
+        // Set properties
+        Properties props = new Properties();
+        props.setProperty("test.booleanData", "true");
+        props.setProperty("test.intData", "1000");
+        props.setProperty("test.longData", "2000");
+        props.setProperty("test.shortData", "3000");
+        props.setProperty("test.doubleData", "1234.567");
+        props.setProperty("test.floatData", "9876.543");
+        props.setProperty("test.byteData", "127");
+        props.setProperty("test.charData", "A");
+        props.setProperty("test.stringData", "true");
+        props.setProperty("test.testData", "TEST.FOO.BAR");
+
+        ReflectionUtil.configureClass(targetObj, props);
+
+        // Check config
+        assertEquals(true, ((ReflectionUtilTest)targetObj).isBooleanData());
+        assertEquals(1000, ((ReflectionUtilTest)targetObj).getIntData());
+        assertEquals(2000, ((ReflectionUtilTest)targetObj).getLongData());
+        assertEquals(3000, ((ReflectionUtilTest)targetObj).getShortData());
+        assertEquals(1234.567, ((ReflectionUtilTest)targetObj).getDoubleData(), 0.0001);
+        assertEquals(9876.543, ((ReflectionUtilTest)targetObj).getFloatData(), 0.0001);
+        assertEquals(127, ((ReflectionUtilTest)targetObj).getByteData());
+        assertEquals('A', ((ReflectionUtilTest)targetObj).getCharData());
+        assertEquals("true", ((ReflectionUtilTest)targetObj).getStringData());
+        assertEquals("TEST.FOO.BAR", ((ReflectionUtilTest)targetObj).getTestData().getStringData());
+    }
+
+    public void testNestedConfig() {
+        ReflectionUtilTest t1 = new ReflectionUtilTest();
+        ReflectionUtilTest t2 = new ReflectionUtilTest();
+        ReflectionUtilTest t3 = new ReflectionUtilTest();
+        ReflectionUtilTest t4 = new ReflectionUtilTest();
+        ReflectionUtilTest t5 = new ReflectionUtilTest();
+
+        ReflectionUtil.configureClass(t1, "test.stringData", "t1");
+        assertEquals("t1", t1.getStringData());
+
+        t1.setTestData(t2);
+        ReflectionUtil.configureClass(t1, "test.testData.stringData", "t2");
+        assertEquals("t2", t2.getStringData());
+
+        t2.setTestData(t3);
+        ReflectionUtil.configureClass(t1, "test.testData.testData.stringData", "t3");
+        assertEquals("t3", t3.getStringData());
+
+        t3.setTestData(t4);
+        ReflectionUtil.configureClass(t1, "test.testData.testData.testData.stringData", "t4");
+        assertEquals("t4", t4.getStringData());
+
+        t4.setTestData(t5);
+        ReflectionUtil.configureClass(t1, "test.testData.testData.testData.testData.stringData",
"t5");
+        assertEquals("t5", t5.getStringData());
+    }
+
+    public boolean isBooleanData() {
+        return booleanData;
+    }
+
+    public void setBooleanData(boolean booleanData) {
+        this.booleanData = booleanData;
+    }
+
+    public int getIntData() {
+        return intData;
+    }
+
+    public void setIntData(int intData) {
+        this.intData = intData;
+    }
+
+    public long getLongData() {
+        return longData;
+    }
+
+    public void setLongData(long longData) {
+        this.longData = longData;
+    }
+
+    public short getShortData() {
+        return shortData;
+    }
+
+    public void setShortData(short shortData) {
+        this.shortData = shortData;
+    }
+
+    public double getDoubleData() {
+        return doubleData;
+    }
+
+    public void setDoubleData(double doubleData) {
+        this.doubleData = doubleData;
+    }
+
+    public float getFloatData() {
+        return floatData;
+    }
+
+    public void setFloatData(float floatData) {
+        this.floatData = floatData;
+    }
+
+    public byte getByteData() {
+        return byteData;
+    }
+
+    public void setByteData(byte byteData) {
+        this.byteData = byteData;
+    }
+
+    public char getCharData() {
+        return charData;
+    }
+
+    public void setCharData(char charData) {
+        this.charData = charData;
+    }
+
+    public String getStringData() {
+        return stringData;
+    }
+
+    public void setStringData(String stringData) {
+        this.stringData = stringData;
+    }
+
+    public ReflectionUtilTest getTestData() {
+        return testData;
+    }
+
+    public void setTestData(ReflectionUtilTest testData) {
+        this.testData = testData;
+    }
+
+    public static ReflectionUtilTest valueOf(String data) {
+        ReflectionUtilTest obj = new ReflectionUtilTest();
+        obj.setStringData(data);
+        return obj;
+    }
+}



Mime
View raw message