Skip to content

Commit

Permalink
[rewrite] #1281 important decision: karate-core will bundle apache
Browse files Browse the repository at this point in the history
and we will maven-shade it so that there will not be library conflicts in the wild
which means we can remove karate-jersey, it is not needed any more
we can focus on the one true http client and also look at armeria for the future and async
the build time has come down and the number of directories can be reduced in git
next we can try remove the karate-netty module, but the readme may have to remain
the size of the karate-core jar is around 10 mb now, but I think in this day and age it is ok
  • Loading branch information
ptrthomas committed Nov 14, 2020
1 parent 776404d commit c9d2172
Show file tree
Hide file tree
Showing 20 changed files with 32 additions and 665 deletions.
54 changes: 0 additions & 54 deletions karate-apache/pom.xml

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion karate-apache/src/main/resources/karate-http.properties

This file was deleted.

29 changes: 28 additions & 1 deletion karate-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,29 @@
<groupId>com.linecorp.armeria</groupId>
<artifactId>armeria</artifactId>
<version>1.2.0</version>
</dependency>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
<exclusion>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<!-- this is tied to logback-classic version in karate-parent -->
<version>1.7.25</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
Expand Down Expand Up @@ -152,6 +174,7 @@
<artifactSet>
<includes>
<include>io.netty:*</include>
<include>org.apache.httpcomponents:*</include>
<include>org.antlr:*</include>
</includes>
</artifactSet>
Expand All @@ -160,6 +183,10 @@
<pattern>io.netty</pattern>
<shadedPattern>io.netty.karate</shadedPattern>
</relocation>
<relocation>
<pattern>org.apache.httpcomponents</pattern>
<shadedPattern>org.apache.httpkarate</shadedPattern>
</relocation>
<relocation>
<pattern>org.antlr.v4</pattern>
<shadedPattern>org.antlr.karate</shadedPattern>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public SuiteRuntime(Runner.Builder rb) {
results = Results.startTimer(threadCount);
results.setReportDir(reportDir); // TODO unify
if (rb.clientFactory == null) {
clientFactory = HttpClientFactory.resolveClientFactory(classLoader);
clientFactory = HttpClientFactory.DEFAULT;
} else {
clientFactory = rb.clientFactory;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ private void configure(Config config) {
clientBuilder.setRedirectStrategy(new LaxRedirectStrategy());
}
clientBuilder.useSystemProperties();
clientBuilder.setDefaultCookieSpecRegistry(LenientCookieSpec.registry());
if (config.isSslEnabled()) {
// System.setProperty("jsse.enableSNIExtension", "false");
String algorithm = config.getSslAlgorithm(); // could be null
Expand Down Expand Up @@ -145,7 +144,6 @@ private void configure(Config config) {
}
}
RequestConfig.Builder configBuilder = RequestConfig.custom()
.setCookieSpec(LenientCookieSpec.KARATE)
.setConnectTimeout(config.getConnectTimeout())
.setSocketTimeout(config.getReadTimeout());
if (config.getLocalAddress() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,8 @@
*/
package com.intuit.karate.server;

import com.intuit.karate.Resource;
import com.intuit.karate.http.apache.ApacheHttpClient;
import com.intuit.karate.runtime.ScenarioEngine;
import java.io.InputStream;
import java.util.Properties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
*
Expand All @@ -39,34 +35,6 @@ public interface HttpClientFactory {

HttpClient create(ScenarioEngine engine);

public static final HttpClientFactory DEFAULT = engine -> new ArmeriaHttpClient(engine.getConfig(), engine.logger);

static final Logger logger = LoggerFactory.getLogger(HttpClientFactory.class);

static final String KARATE_HTTP_PROPERTIES = "classpath:karate-http.properties";
static final String CLIENT_FACTORY = "client.factory";

public static HttpClientFactory resolveClientFactory(ClassLoader classLoader) {
try {
Resource resource = new Resource(KARATE_HTTP_PROPERTIES, classLoader);
InputStream is = resource.getStream();
if (is == null) {
throw new RuntimeException(KARATE_HTTP_PROPERTIES + " not found");
}
Properties props = new Properties();
props.load(is);
String className = props.getProperty(CLIENT_FACTORY);
if (className == null) {
throw new RuntimeException("property " + CLIENT_FACTORY + " not found in " + KARATE_HTTP_PROPERTIES);
}
Class clazz = Class.forName(className);
HttpClientFactory factory = (HttpClientFactory) clazz.newInstance();
logger.info("using http client factory: {}", factory.getClass());
return factory;
} catch (Exception e) {
logger.warn("using built-in http client, {}", e.getMessage());
return HttpClientFactory.DEFAULT;
}
}
public static final HttpClientFactory DEFAULT = engine -> new ApacheHttpClient(engine);

}
71 changes: 0 additions & 71 deletions karate-jersey/pom.xml

This file was deleted.

Loading

0 comments on commit c9d2172

Please sign in to comment.