diff --git a/src/main/java/org/bench4q/agent/parameterization/impl/InstanceControler.java b/src/main/java/org/bench4q/agent/parameterization/impl/InstanceControler.java index 89b4b7ff..e14e9164 100644 --- a/src/main/java/org/bench4q/agent/parameterization/impl/InstanceControler.java +++ b/src/main/java/org/bench4q/agent/parameterization/impl/InstanceControler.java @@ -99,10 +99,10 @@ public class InstanceControler implements SessionObject { Object instance = pf.getObj(className); Object result = null; try { - Class[] argTypeArr = new Class[args.length + 1]; + Class[] argTypeArr = new Class[args.length + 2]; argTypeArr[0] = instandid.getClass(); argTypeArr[1] = this.cacheObjMap.getClass(); - Object[] totalArgs = new Object[args.length + 1]; + Object[] totalArgs = new Object[args.length + 2]; totalArgs[0] = instandid; totalArgs[1] = this.cacheObjMap; for (int i = 2; i < args.length + 2; i++) { diff --git a/src/main/java/org/bench4q/agent/parameterization/impl/Para_Table.java b/src/main/java/org/bench4q/agent/parameterization/impl/Para_Table.java index 0eaf3577..5a76d50d 100644 --- a/src/main/java/org/bench4q/agent/parameterization/impl/Para_Table.java +++ b/src/main/java/org/bench4q/agent/parameterization/impl/Para_Table.java @@ -6,6 +6,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.nio.CharBuffer; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Random; @@ -57,7 +58,7 @@ public class Para_Table { } } result = queue.poll(); - } while (result != null); + } while (result == null); return result; } @@ -84,7 +85,7 @@ public class Para_Table { } } result = queue.poll(); - } while (result != null); + } while (result == null); return result; } @@ -119,7 +120,12 @@ public class Para_Table { super(sourceValue, firstRow); this.splitChar = splitChar; this.lineChar = lineChar; - + try { + createBFR(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } private void createBFR() throws IOException { @@ -136,23 +142,26 @@ public class Para_Table { @Override public List readRows() { - CharBuffer target = CharBuffer.allocate(readCharSize); + StringBuilder target = new StringBuilder(); List result = new ArrayList(); TableRow tempTableRow = new TableRow(); try { for (int i = 0; i < cacheSize;) { - char readBuff = (char) bfr.read(); - if (readBuff == -1) { + int tt = bfr.read(); + char readBuff = (char)tt; + if (tt == -1) { createBFR(); break; } else if (readBuff == this.splitChar) { - tempTableRow.AddCell(target.toString()); - target.clear(); + String cellString = target.toString(); + tempTableRow.AddCell(cellString); + target = new StringBuilder(); continue; } else if (readBuff == this.lineChar) { tempTableRow.AddCell(target.toString()); result.add(tempTableRow); - target.clear(); + tempTableRow = new TableRow(); + target = new StringBuilder(); i++; continue; } @@ -164,7 +173,7 @@ public class Para_Table { if (target.length() > 0) { tempTableRow.AddCell(target.toString()); result.add(tempTableRow); - target.clear(); + target = new StringBuilder(); } return result; } @@ -209,7 +218,11 @@ public class Para_Table { } } - public String getTableColumnValue(UUID id, Map objCache, + // org.bench4q.agent.parameterization.impl.Para_Table.getTableColumnValue(java.util.UUID, + // java.util.HashMap, java.lang.String, java.lang.String, java.lang.String, + // java.lang.String, java.lang.String, java.lang.String, java.lang.String) + + public String getTableColumnValue(UUID id, HashMap objCache, String source, String sourceValue, String firstRow, String nextRow, String splitChar, String lineChar, String column) { int fRow = Integer.parseInt(firstRow); @@ -245,4 +258,8 @@ public class Para_Table { return resultRow.cells.get(col); } + + public void unreg(UUID id) { + + } } diff --git a/src/main/java/org/bench4q/agent/parameterization/impl/ParametersFactory.java b/src/main/java/org/bench4q/agent/parameterization/impl/ParametersFactory.java index 4902a66d..13795e4e 100644 --- a/src/main/java/org/bench4q/agent/parameterization/impl/ParametersFactory.java +++ b/src/main/java/org/bench4q/agent/parameterization/impl/ParametersFactory.java @@ -29,7 +29,7 @@ public class ParametersFactory { public Object getObj(String className) { Object result = null; mapRWLock.readLock().lock(); - objMap.get(className); + result = objMap.get(className); mapRWLock.readLock().unlock(); return result; } @@ -48,7 +48,7 @@ public class ParametersFactory { objMap.put(className, instance); } catch (Exception ex) { - + System.out.println(ex.getMessage()); } mapRWLock.writeLock().unlock(); return true; diff --git a/src/test/java/org/bench4q/agent/test/parameterization/TEST_UserName.java b/src/test/java/org/bench4q/agent/test/parameterization/TEST_UserName.java index 29156cfe..a023beb1 100644 --- a/src/test/java/org/bench4q/agent/test/parameterization/TEST_UserName.java +++ b/src/test/java/org/bench4q/agent/test/parameterization/TEST_UserName.java @@ -2,7 +2,10 @@ package org.bench4q.agent.test.parameterization; import static org.junit.Assert.*; +import java.util.HashMap; + import org.bench4q.agent.parameterization.impl.InstanceControler; +import org.bench4q.agent.parameterization.impl.Para_Table; import org.bench4q.share.helper.TestHelper; import org.junit.Test; @@ -10,11 +13,18 @@ public class TEST_UserName { @Test public void testGetParam() throws Exception { + Para_Table table = new Para_Table(); + String ret = table.getTableColumnValue(java.util.UUID.randomUUID(), + new HashMap(), "file", + "ScenarioParameters\\param1.txt", "0", "sequence", ";", "~", + "2"); + System.out.println(ret); InstanceControler ic = new InstanceControler(); String passwordName = ic - .getParam(""); + .getParam(""); System.out.println(passwordName); assertNotNull(passwordName); TestHelper.invokePrivate(ic, "releaseAll", null, null); + } }