01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18:
19: package org.apache.jmeter.protocol.http.util.accesslog;
20:
21: import org.apache.jmeter.junit.JMeterTestCase;
22: import org.apache.jmeter.protocol.http.sampler.HTTPNullSampler;
23:
24: // TODO - more tests needed
25:
26: public class TestTCLogParser extends JMeterTestCase {
27: private static final TCLogParser tclp = new TCLogParser();
28:
29: private static final String URL1 = "127.0.0.1 - - [08/Jan/2003:07:03:54 -0500] \"GET /addrbook/ HTTP/1.1\" 200 1981";
30:
31: private static final String URL2 = "127.0.0.1 - - [08/Jan/2003:07:03:54 -0500] \"GET /addrbook?x=y HTTP/1.1\" 200 1981";
32:
33: public void testConstruct() throws Exception {
34: TCLogParser tcp;
35: tcp = new TCLogParser();
36: assertNull("Should not have set the filename", tcp.FILENAME);
37:
38: String file = "testfiles/access.log";
39: tcp = new TCLogParser(file);
40: assertEquals("Filename should have been saved", file,
41: tcp.FILENAME);
42: }
43:
44: public void testcleanURL() throws Exception {
45: String res = tclp.cleanURL(URL1);
46: assertEquals("/addrbook/", res);
47: assertNull(tclp.stripFile(res, new HTTPNullSampler()));
48: }
49:
50: public void testcheckURL() throws Exception {
51: assertFalse("URL is not have a query", tclp.checkURL(URL1));
52: assertTrue("URL is a query", tclp.checkURL(URL2));
53: }
54: }
|