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

(-)test/src/org/apache/jmeter/protocol/http/sampler/HTTPSamplerFactoryTest.java (+15 lines)
Line 0 Link Here
1
package org.apache.jmeter.protocol.http.sampler;
2
3
import junit.framework.TestCase;
4
5
public class HTTPSamplerFactoryTest extends TestCase {
6
7
	public void testGetImplementation() throws Exception {
8
9
		HTTPAbstractImpl implementation = HTTPSamplerFactory.getImplementation(
10
				StubHTTPSamplerBase.class.getName(),
11
				HTTPSamplerFactory.newInstance());
12
13
		assertEquals(StubHTTPSamplerBase.class.getName(), implementation.getClass().getName());
14
	}
15
}
(-)src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerFactory.java (-2 / +8 lines)
Lines 65-71 Link Here
65
     *
65
     *
66
     * @param alias HTTP_SAMPLER or HTTP_SAMPLER_APACHE or IMPL_HTTP_CLIENT3_1 or IMPL_HTTP_CLIENT4
66
     * @param alias HTTP_SAMPLER or HTTP_SAMPLER_APACHE or IMPL_HTTP_CLIENT3_1 or IMPL_HTTP_CLIENT4
67
     * @return the appropriate sampler
67
     * @return the appropriate sampler
68
     * @throws UnsupportedOperationException if alias is not recognised
68
     * @throws UnsupportedOperationException if alias is not recognized
69
     */
69
     */
70
    public static HTTPSamplerBase newInstance(String alias) {
70
    public static HTTPSamplerBase newInstance(String alias) {
71
        if (alias ==null || alias.length() == 0) {
71
        if (alias ==null || alias.length() == 0) {
Lines 101-108 Link Here
101
        } else if (IMPL_HTTP_CLIENT4.equals(impl)) {
101
        } else if (IMPL_HTTP_CLIENT4.equals(impl)) {
102
            return new HTTPHC4Impl(base);
102
            return new HTTPHC4Impl(base);
103
        } else {
103
        } else {
104
            throw new IllegalArgumentException("Unknown implementation type: '"+impl+"'");
104
        	try {
105
        		Class<?> implClass = Class.forName(impl);
106
        		return  (HTTPAbstractImpl)implClass.getConstructor(HTTPSamplerBase.class).newInstance(base);
107
        	} catch(Exception e) {
108
        		e.printStackTrace();
109
            }
105
        }
110
        }
111
		throw new IllegalArgumentException("Unknown implementation type: '"+impl+"'");
106
    }
112
    }
107
113
108
}
114
}
(-)test/src/org/apache/jmeter/protocol/http/sampler/StubHTTPSamplerBase.java (+22 lines)
Line 0 Link Here
1
package org.apache.jmeter.protocol.http.sampler;
2
3
import java.net.URL;
4
5
public class StubHTTPSamplerBase extends HTTPAbstractImpl {
6
7
	public StubHTTPSamplerBase(HTTPSamplerBase testElement) {
8
		super(testElement);
9
	}
10
11
	@Override
12
	public boolean interrupt() {
13
		return false;
14
	}
15
16
	@Override
17
	protected HTTPSampleResult sample(URL url, String method,
18
			boolean areFollowingRedirect, int frameDepth) {
19
		return null;
20
	}
21
	
22
}

Return to bug 58279