View | Details | Raw Unified | Return to bug 44418
Collapse All | Expand All

(-)/home/franky/jmeterworkspace/jmeter620583/bin/i18nedit.properties (+10 lines)
Line 0 Link Here
1
#I18NEdit settings for project
2
locale.default=en
3
locales=de ja no tw
4
main.name=jakarta-jmeter
5
personal.Administrator.sourcelocale=en
6
personal.Administrator.targetlocale=tw
7
personal.Administrator.workmode=directed
8
personal.jordi.sourcelocale=en
9
personal.jordi.targetlocale=ja
10
personal.jordi.workmode=free
(-)/home/franky/jmeterworkspace/jmeter620583/src/components/org/apache/jmeter/config/CSVDataSet.java (-2 / +13 lines)
Lines 55-60 Link Here
55
    private transient boolean recycle = true;
55
    private transient boolean recycle = true;
56
    
56
    
57
    private transient boolean stopThread = false;
57
    private transient boolean stopThread = false;
58
    
59
    private transient boolean independent = false;
58
60
59
    transient private String[] vars;
61
    transient private String[] vars;
60
62
Lines 71-77 Link Here
71
		FileServer server = FileServer.getFileServer();
73
		FileServer server = FileServer.getFileServer();
72
		String _fileName = getFilename();
74
		String _fileName = getFilename();
73
		if (vars == null) {
75
		if (vars == null) {
74
			server.reserveFile(_fileName, getFileEncoding());
76
			server.reserveFile(this, _fileName, getFileEncoding(), getIndependent());
75
			vars = JOrphanUtils.split(getVariableNames(), ","); // $NON-NLS-1$
77
			vars = JOrphanUtils.split(getVariableNames(), ","); // $NON-NLS-1$
76
		}
78
		}
77
		try {
79
		try {
Lines 79-85 Link Here
79
			if (delim.equals("\\t")) // $NON-NLS-1$
81
			if (delim.equals("\\t")) // $NON-NLS-1$
80
				delim = "\t";// Make it easier to enter a Tab // $NON-NLS-1$
82
				delim = "\t";// Make it easier to enter a Tab // $NON-NLS-1$
81
            JMeterVariables threadVars = this.getThreadContext().getVariables();
83
            JMeterVariables threadVars = this.getThreadContext().getVariables();
82
			String line = server.readLine(_fileName,getRecycle());
84
			String line = server.readLine(this, _fileName, getRecycle(), getIndependent());
83
            if (line!=null) {// i.e. not EOF
85
            if (line!=null) {// i.e. not EOF
84
                String[] lineValues = JOrphanUtils.split(line, delim,false);
86
                String[] lineValues = JOrphanUtils.split(line, delim,false);
85
    			for (int a = 0; a < vars.length && a < lineValues.length; a++) {
87
    			for (int a = 0; a < vars.length && a < lineValues.length; a++) {
Lines 167-171 Link Here
167
    public void setStopThread(boolean value) {
169
    public void setStopThread(boolean value) {
168
        this.stopThread = value;
170
        this.stopThread = value;
169
    }
171
    }
172
    
173
    public boolean getIndependent() {
174
        return independent;
175
    }
176
177
    public void setIndependent(boolean value) {
178
        this.independent = value;
179
    }
170
180
181
171
}
182
}
(-)/home/franky/jmeterworkspace/jmeter620583/src/components/org/apache/jmeter/config/CSVDataSetBeanInfo.java (-2 / +8 lines)
Lines 35-40 Link Here
35
    private static final String DELIMITER = "delimiter";             //$NON-NLS-1$
35
    private static final String DELIMITER = "delimiter";             //$NON-NLS-1$
36
    private static final String RECYCLE = "recycle";                 //$NON-NLS-1$
36
    private static final String RECYCLE = "recycle";                 //$NON-NLS-1$
37
    private static final String STOPTHREAD = "stopThread";           //$NON-NLS-1$
37
    private static final String STOPTHREAD = "stopThread";           //$NON-NLS-1$
38
   private static final String INDEPENDENT = "independent";         //$NON-NLS-1$
38
39
39
	public CSVDataSetBeanInfo() {
40
	public CSVDataSetBeanInfo() {
40
		super(CSVDataSet.class);
41
		super(CSVDataSet.class);
Lines 39-46 Link Here
39
	public CSVDataSetBeanInfo() {
40
	public CSVDataSetBeanInfo() {
40
		super(CSVDataSet.class);
41
		super(CSVDataSet.class);
41
		createPropertyGroup("csv_data",             //$NON-NLS-1$
42
		createPropertyGroup("csv_data",             //$NON-NLS-1$
42
                new String[] { FILENAME, FILE_ENCODING, VARIABLE_NAMES, DELIMITER, RECYCLE, STOPTHREAD });
43
               new String[] { FILENAME, FILE_ENCODING, VARIABLE_NAMES, DELIMITER, RECYCLE, STOPTHREAD,INDEPENDENT });
43
        
44
		
44
		PropertyDescriptor p = property(FILENAME);
45
		PropertyDescriptor p = property(FILENAME);
45
		p.setValue(NOT_UNDEFINED, Boolean.TRUE);
46
		p.setValue(NOT_UNDEFINED, Boolean.TRUE);
46
		p.setValue(DEFAULT, "");        //$NON-NLS-1$
47
		p.setValue(DEFAULT, "");        //$NON-NLS-1$
Lines 70-74 Link Here
70
        p.setValue(NOT_UNDEFINED, Boolean.TRUE);
71
        p.setValue(NOT_UNDEFINED, Boolean.TRUE);
71
        p.setValue(DEFAULT, Boolean.FALSE);
72
        p.setValue(DEFAULT, Boolean.FALSE);
72
        p.setValue(NOT_EXPRESSION, Boolean.TRUE);
73
        p.setValue(NOT_EXPRESSION, Boolean.TRUE);
74
        
75
        p = property(INDEPENDENT);
76
        p.setValue(NOT_UNDEFINED, Boolean.TRUE);
77
        p.setValue(DEFAULT, Boolean.FALSE);
78
        p.setValue(NOT_EXPRESSION, Boolean.TRUE);
73
	}
79
	}
74
}
80
}
(-)/home/franky/jmeterworkspace/jmeter620583/src/core/org/apache/jmeter/services/FileServer.java (-35 / +75 lines)
Lines 63-69 Link Here
63
63
64
    //TODO - make "files" and "random" static as the class is a singleton?
64
    //TODO - make "files" and "random" static as the class is a singleton?
65
    
65
    
66
	private final Map files = new HashMap();
66
	private final Map keys = new HashMap();
67
    
67
    
68
	private static final FileServer server = new FileServer();
68
	private static final FileServer server = new FileServer();
69
69
Lines 73-78 Link Here
73
		base = new File(DEFAULT_BASE);
73
		base = new File(DEFAULT_BASE);
74
		log.info("Default base="+DEFAULT_BASE);
74
		log.info("Default base="+DEFAULT_BASE);
75
	}
75
	}
76
	
77
	private FileEntry getFileEntrybyFilename(Map map, String filename){
78
		FileEntry fileEntry = null;
79
		Iterator it;
80
		boolean found = false;
81
		if (map != null){
82
			it = map.values().iterator();
83
		    while (it.hasNext() && !found) {
84
		    	fileEntry = (FileEntry) it.next();	
85
		        if (fileEntry.file.getName().equals(filename)){	
86
		    		 found = true;
87
		    	}
88
		    }
89
	    }
90
		return fileEntry;
91
	}
76
92
77
	public static FileServer getFileServer() {
93
	public static FileServer getFileServer() {
78
		return server;
94
		return server;
Lines 86-92 Link Here
86
		if (filesOpen()) {
102
		if (filesOpen()) {
87
			throw new IOException("Files are still open, cannot change base directory");
103
			throw new IOException("Files are still open, cannot change base directory");
88
		}
104
		}
89
		files.clear();
105
		keys.clear();
90
		if (basedir != null) {
106
		if (basedir != null) {
91
			base = new File(basedir);
107
			base = new File(basedir);
92
			if (!base.isDirectory()) {
108
			if (!base.isDirectory()) {
Lines 103-113 Link Here
103
    /**
119
    /**
104
     * Creates an association between a filename and a File inputOutputObject,
120
     * Creates an association between a filename and a File inputOutputObject,
105
     * and stores it for later use - unless it is already stored.
121
     * and stores it for later use - unless it is already stored.
106
     * 
122
     * @param key - use a given object as the key for the HashMap
107
     * @param filename - relative (to base) or absolute file name
123
     * @param filename - relative (to base) or absolute file name
108
     */
124
     */
109
	public synchronized void reserveFile(String filename) {
125
	public synchronized void reserveFile(Object key, String filename) {
110
		reserveFile(filename,null);
126
		reserveFile(key, filename, null, false);
111
	}
127
	}
112
128
113
    /**
129
    /**
Lines 114-130 Link Here
114
     * Creates an association between a filename and a File inputOutputObject,
130
     * Creates an association between a filename and a File inputOutputObject,
115
     * and stores it for later use - unless it is already stored.
131
     * and stores it for later use - unless it is already stored.
116
     * 
132
     * 
133
     * @param key - use a given object as the key for the HashMap 
117
     * @param filename - relative (to base) or absolute file name
134
     * @param filename - relative (to base) or absolute file name
118
     * @param charsetName - the character set encoding to use for the file
135
     * @param charsetName - the character set encoding to use for the file
119
     */
136
     */
120
	public synchronized void reserveFile(String filename, String charsetName) {
137
	public synchronized void reserveFile(Object key, String filename, String charsetName, boolean independent) {	
121
		if (!files.containsKey(filename)) {
138
	   Iterator it;
122
            File f = new File(filename); 
139
	   FileEntry existFileentry;
123
            FileEntry file = 
140
	   boolean b = false;
124
                new FileEntry(f.isAbsolute() ? f : new File(base, filename),null,charsetName);
141
       it = keys.values().iterator();
125
            log.info("Stored: "+filename);
142
       while (it.hasNext() && !b) {
126
			files.put(filename, file);
143
    	 existFileentry = (FileEntry) it.next();
127
		}
144
    	 if (existFileentry.file.getName().equals(filename)){
145
    		 b = true;
146
    	 }
147
       }
148
      
149
       if (!b || independent){
150
           File f = new File(filename); 
151
           FileEntry file = 
152
               new FileEntry(f.isAbsolute() ? f : new File(base, filename), null, charsetName);
153
           
154
       log.info("Stored: "+ filename);
155
		keys.put(key, file);
156
       }
157
	
128
	}
158
	}
129
159
130
   /**
160
   /**
Lines 130-136 Link Here
130
   /**
160
   /**
131
	 * Get the next line of the named file, recycle by default.
161
	 * Get the next line of the named file, recycle by default.
132
	 *
162
	 *
133
     * @param filename
163
	 *@param filename - name of the file
134
	 * @return String containing the next line in the file
164
	 * @return String containing the next line in the file
135
	 * @throws IOException
165
	 * @throws IOException
136
	 */
166
	 */
Lines 135-141 Link Here
135
	 * @throws IOException
165
	 * @throws IOException
136
	 */
166
	 */
137
    public String readLine(String filename) throws IOException {
167
    public String readLine(String filename) throws IOException {
138
      return readLine(filename, true);
168
      return readLine(null, filename, true, false);
139
    }
169
    }
140
170
141
   /**
171
   /**
Lines 141-147 Link Here
141
   /**
171
   /**
142
	 * Get the next line of the named file.
172
	 * Get the next line of the named file.
143
	 * 
173
	 * 
144
     * @param filename
174
     * @param key - use a given object as the key for the HashMap
175
     * @param filename - name of the file
145
     * @param recycle - should file be restarted at EOF?
176
     * @param recycle - should file be restarted at EOF?
146
	 * @return String containing the next line in the file (null if EOF reached and not recycle)
177
	 * @return String containing the next line in the file (null if EOF reached and not recycle)
147
	 * @throws IOException
178
	 * @throws IOException
Lines 146-158 Link Here
146
	 * @return String containing the next line in the file (null if EOF reached and not recycle)
177
	 * @return String containing the next line in the file (null if EOF reached and not recycle)
147
	 * @throws IOException
178
	 * @throws IOException
148
	 */
179
	 */
149
	public synchronized String readLine(String filename, boolean recycle) throws IOException {
180
	public synchronized String readLine(Object key, String filename, boolean recycle, boolean independent) throws IOException {
150
		FileEntry fileEntry = (FileEntry) files.get(filename);
181
		FileEntry fileEntry = null;
182
		
183
		if (independent){
184
			// get FileEntry by key if the same file is more than once in the HashMap (independent = true)
185
			fileEntry = (FileEntry) keys.get(key);
186
		} else {
187
			// get FileEntry by filename if a file is only once in the HashMap (independent = false)
188
			fileEntry = (FileEntry) getFileEntrybyFilename(keys, filename);
189
		}
190
		
151
		if (fileEntry != null) {
191
		if (fileEntry != null) {
152
			if (fileEntry.inputOutputObject == null) {
192
			if (fileEntry.inputOutputObject == null) {
153
				fileEntry.inputOutputObject = createBufferedReader(fileEntry, filename);
193
				fileEntry.inputOutputObject = createBufferedReader(fileEntry);
154
            } else if (!(fileEntry.inputOutputObject instanceof Reader)) {
194
            } else if (!(fileEntry.inputOutputObject instanceof Reader)) {
155
                throw new IOException("File " + filename + " already in use");
195
                throw new IOException("File " + fileEntry.file.getName() + " already in use");
156
            }
196
            }
157
			BufferedReader reader = (BufferedReader) fileEntry.inputOutputObject;
197
			BufferedReader reader = (BufferedReader) fileEntry.inputOutputObject;
158
			String line = reader.readLine();
198
			String line = reader.readLine();
Lines 158-164 Link Here
158
			String line = reader.readLine();
198
			String line = reader.readLine();
159
			if (line == null && recycle) {
199
			if (line == null && recycle) {
160
				reader.close();
200
				reader.close();
161
				reader = createBufferedReader(fileEntry, filename);
201
				reader = createBufferedReader(fileEntry);
162
				fileEntry.inputOutputObject = reader;
202
				fileEntry.inputOutputObject = reader;
163
				line = reader.readLine();
203
				line = reader.readLine();
164
			}
204
			}
Lines 165-174 Link Here
165
            if (log.isDebugEnabled()) log.debug("Read:"+line);
205
            if (log.isDebugEnabled()) log.debug("Read:"+line);
166
			return line;
206
			return line;
167
		}
207
		}
168
		throw new IOException("File never reserved: "+filename);
208
		throw new IOException("File never reserved: "+ filename);
169
	}
209
	}
170
	
210
	
171
	private BufferedReader createBufferedReader(FileEntry fileEntry, String filename) throws IOException { 
211
	private BufferedReader createBufferedReader(FileEntry fileEntry) throws IOException { 
172
		FileInputStream fis = new FileInputStream(fileEntry.file);				
212
		FileInputStream fis = new FileInputStream(fileEntry.file);				
173
		InputStreamReader isr = null;
213
		InputStreamReader isr = null;
174
        // If file encoding is specified, read using that encoding, otherwise use default platform encoding
214
        // If file encoding is specified, read using that encoding, otherwise use default platform encoding
Lines 182-191 Link Here
182
	}
222
	}
183
223
184
	public synchronized void write(String filename, String value) throws IOException {
224
	public synchronized void write(String filename, String value) throws IOException {
185
		FileEntry fileEntry = (FileEntry) files.get(filename);
225
		FileEntry fileEntry = (FileEntry) getFileEntrybyFilename(keys, filename);
186
		if (fileEntry != null) {
226
		if (fileEntry != null) {
187
			if (fileEntry.inputOutputObject == null) {
227
			if (fileEntry.inputOutputObject == null) {
188
				fileEntry.inputOutputObject = createBufferedWriter(fileEntry, filename);
228
				fileEntry.inputOutputObject = createBufferedWriter(fileEntry);
189
			} else if (!(fileEntry.inputOutputObject instanceof Writer)) {
229
			} else if (!(fileEntry.inputOutputObject instanceof Writer)) {
190
				throw new IOException("File " + filename + " already in use");
230
				throw new IOException("File " + filename + " already in use");
191
			}
231
			}
Lines 197-203 Link Here
197
        }
237
        }
198
	}
238
	}
199
239
200
	private BufferedWriter createBufferedWriter(FileEntry fileEntry, String filename) throws IOException { 
240
	private BufferedWriter createBufferedWriter(FileEntry fileEntry) throws IOException { 
201
		FileOutputStream fos = new FileOutputStream(fileEntry.file);				
241
		FileOutputStream fos = new FileOutputStream(fileEntry.file);				
202
		OutputStreamWriter osw = null;
242
		OutputStreamWriter osw = null;
203
        // If file encoding is specified, write using that encoding, otherwise use default platform encoding
243
        // If file encoding is specified, write using that encoding, otherwise use default platform encoding
Lines 211-222 Link Here
211
	}
251
	}
212
252
213
	public void closeFiles() throws IOException {
253
	public void closeFiles() throws IOException {
214
		Iterator iter = files.entrySet().iterator();
254
		Iterator iter = keys.entrySet().iterator();
215
		while (iter.hasNext()) {
255
		while (iter.hasNext()) {
216
            Map.Entry me = (Map.Entry) iter.next();
256
            Map.Entry me = (Map.Entry) iter.next();
217
			closeFile((String)me.getKey(),(FileEntry)me.getValue() );
257
			closeFile((Object)me.getKey(),(FileEntry)me.getValue() );
218
		}
258
		}
219
		files.clear();
259
		keys.clear();
220
	}
260
	}
221
261
222
	/**
262
	/**
Lines 223-236 Link Here
223
	 * @param name
263
	 * @param name
224
	 * @throws IOException
264
	 * @throws IOException
225
	 */
265
	 */
226
	public synchronized void closeFile(String name) throws IOException {
266
	public synchronized void closeFile(Object key) throws IOException {
227
		FileEntry fileEntry = (FileEntry) files.get(name);
267
		FileEntry fileEntry = (FileEntry) keys.get(key);
228
		closeFile(name, fileEntry);
268
		closeFile(keys.get(key), fileEntry);
229
	}
269
	}
230
270
231
    private void closeFile(String name, FileEntry fileEntry) throws IOException {
271
    private void closeFile(Object key, FileEntry fileEntry) throws IOException {
232
        if (fileEntry != null && fileEntry.inputOutputObject != null) {
272
        if (fileEntry != null && fileEntry.inputOutputObject != null) {
233
            log.info("Close: "+name);
273
            log.info("Close: "+fileEntry.file.getName());
234
            if (fileEntry.inputOutputObject instanceof Reader) {
274
            if (fileEntry.inputOutputObject instanceof Reader) {
235
                ((Reader) fileEntry.inputOutputObject).close();
275
                ((Reader) fileEntry.inputOutputObject).close();
236
            } else if (fileEntry.inputOutputObject instanceof Writer) {
276
            } else if (fileEntry.inputOutputObject instanceof Writer) {
Lines 243-249 Link Here
243
    }
283
    }
244
284
245
	protected boolean filesOpen() {
285
	protected boolean filesOpen() {
246
		Iterator iter = files.values().iterator();
286
		Iterator iter = keys.values().iterator();
247
		while (iter.hasNext()) {
287
		while (iter.hasNext()) {
248
			FileEntry fileEntry = (FileEntry) iter.next();
288
			FileEntry fileEntry = (FileEntry) iter.next();
249
            if (fileEntry.inputOutputObject != null) {
289
            if (fileEntry.inputOutputObject != null) {
(-)/home/franky/jmeterworkspace/jmeter620583/src/core/org/apache/jmeter/util/JMeterVersion.java (-1 / +1 lines)
Lines 44-50 Link Here
44
	 * This ensures that JMeterUtils always gets the correct
44
	 * This ensures that JMeterUtils always gets the correct
45
	 * version, even if JMeterUtils is not re-compiled during the build.
45
	 * version, even if JMeterUtils is not re-compiled during the build.
46
	 */
46
	 */
47
	private static final String VERSION = "2.3.2";
47
	private static final String VERSION = "2.3.20080222";
48
48
49
	static final String COPYRIGHT = "Copyright (c) 1998-2008 The Apache Software Foundation";
49
	static final String COPYRIGHT = "Copyright (c) 1998-2008 The Apache Software Foundation";
50
50
(-)/home/franky/jmeterworkspace/jmeter620583/src/protocol/http/org/apache/jmeter/protocol/http/util/accesslog/SharedTCLogParser.java (-1 / +1 lines)
Lines 49-55 Link Here
49
	 */
49
	 */
50
	public int parse(TestElement el, int parseCount) {
50
	public int parse(TestElement el, int parseCount) {
51
		FileServer fileServer = FileServer.getFileServer();
51
		FileServer fileServer = FileServer.getFileServer();
52
		fileServer.reserveFile(FILENAME);
52
		fileServer.reserveFile(this, FILENAME);
53
		try {
53
		try {
54
			return parse(fileServer, el, parseCount);
54
			return parse(fileServer, el, parseCount);
55
		} catch (Exception exception) {
55
		} catch (Exception exception) {
(-)/home/franky/jmeterworkspace/jmeter620583/test/src/org/apache/jmeter/services/TestFileServer.java (-2 / +2 lines)
Lines 59-65 Link Here
59
        FS.closeFile("xxx"); // Unrecognised files are ignored
59
        FS.closeFile("xxx"); // Unrecognised files are ignored
60
        assertFalse("Should not have any files open",FS.filesOpen());
60
        assertFalse("Should not have any files open",FS.filesOpen());
61
        String infile="testfiles/test.csv";
61
        String infile="testfiles/test.csv";
62
        FS.reserveFile(infile); // Does not open file
62
        FS.reserveFile(this, infile); // Does not open file
63
        assertFalse("Should not have any files open",FS.filesOpen());
63
        assertFalse("Should not have any files open",FS.filesOpen());
64
        assertEquals("a1,b1,c1,d1",FS.readLine(infile));
64
        assertEquals("a1,b1,c1,d1",FS.readLine(infile));
65
        assertTrue("Should have some files open",FS.filesOpen());
65
        assertTrue("Should have some files open",FS.filesOpen());
Lines 86-92 Link Here
86
        }
86
        }
87
        String base=FS.getBaseDir();
87
        String base=FS.getBaseDir();
88
        infile=base+"/testfiles/test.csv";
88
        infile=base+"/testfiles/test.csv";
89
        FS.reserveFile(infile); // Does not open file
89
        FS.reserveFile(this, infile); // Does not open file
90
        assertFalse("Should not have any files open",FS.filesOpen());
90
        assertFalse("Should not have any files open",FS.filesOpen());
91
        assertEquals("a1,b1,c1,d1",FS.readLine(infile));
91
        assertEquals("a1,b1,c1,d1",FS.readLine(infile));
92
        try {
92
        try {

Return to bug 44418