1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-24 03:27:59 +01:00

sinttest: add 'dnsResolver' setting

This commit is contained in:
Florian Schmaus 2020-04-07 20:59:32 +02:00
parent 5b805336ce
commit a564620383
4 changed files with 46 additions and 0 deletions

View file

@ -80,6 +80,7 @@ debugger=console
| disabledConnections | List of disabled connection's nicknames |
| testPackages | List of packages with tests |
| verbose | If `true` set output to verbose |
| dnsResolver | One of 'minidns', 'javax' or 'dnsjava'. Defaults to 'minidns'. |
### Where to place the properties file

View file

@ -8,6 +8,7 @@ applicationDefaultJvmArgs = ["-enableassertions"]
dependencies {
api project(':smack-java8-full')
api project(':smack-resolver-dnsjava')
compile 'org.reflections:reflections:0.9.11'
compile 'eu.geekplace.javapinning:java-pinning-java7:1.1.0-alpha1'
compile group: 'commons-io', name: 'commons-io', version: "$commonsIoVersion"

View file

@ -62,6 +62,12 @@ public final class Configuration {
enhanced,
}
public enum DnsResolver {
minidns,
javax,
dnsjava,
}
public final DomainBareJid service;
public final String serviceTlsPin;
@ -108,6 +114,8 @@ public final class Configuration {
public final boolean verbose;
public final DnsResolver dnsResolver;
private Configuration(Configuration.Builder builder) throws KeyManagementException, NoSuchAlgorithmException {
service = Objects.requireNonNull(builder.service,
"'service' must be set. Either via 'properties' files or via system property 'sinttest.service'.");
@ -180,6 +188,8 @@ public final class Configuration {
};
this.verbose = builder.verbose;
this.dnsResolver = builder.dnsResolver;
}
public boolean isAccountRegistrationPossible() {
@ -232,6 +242,8 @@ public final class Configuration {
private boolean verbose;
private DnsResolver dnsResolver = DnsResolver.minidns;
private Builder() {
}
@ -399,6 +411,20 @@ public final class Configuration {
return setVerbose(verbose);
}
public Builder setDnsResolver(DnsResolver dnsResolver) {
this.dnsResolver = Objects.requireNonNull(dnsResolver);
return this;
}
public Builder setDnsResolver(String dnsResolverString) {
if (dnsResolverString == null) {
return this;
}
DnsResolver dnsResolver = DnsResolver.valueOf(dnsResolverString);
return setDnsResolver(dnsResolver);
}
public Configuration build() throws KeyManagementException, NoSuchAlgorithmException {
return new Configuration(this);
}
@ -470,6 +496,8 @@ public final class Configuration {
builder.setVerbose(properties.getProperty("verbose"));
builder.setDnsResolver(properties.getProperty("dnsResolver"));
return builder.build();
}

View file

@ -57,6 +57,9 @@ import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smack.util.TLSUtils;
import org.jivesoftware.smack.util.dns.dnsjava.DNSJavaResolver;
import org.jivesoftware.smack.util.dns.javax.JavaxResolver;
import org.jivesoftware.smack.util.dns.minidns.MiniDnsResolver;
import org.jivesoftware.smackx.debugger.EnhancedDebuggerWindow;
import org.jivesoftware.smackx.iqregister.AccountManager;
@ -149,6 +152,19 @@ public class SmackIntegrationTestFramework {
public synchronized TestRunResult run()
throws KeyManagementException, NoSuchAlgorithmException, SmackException, IOException, XMPPException,
InterruptedException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
// The DNS resolver is not really a per sinttest run setting. It is not even a per connection setting. Instead
// it is a global setting, but we treat it like a per sinttest run setting.
switch (config.dnsResolver) {
case minidns:
MiniDnsResolver.setup();
break;
case javax:
JavaxResolver.setup();
break;
case dnsjava:
DNSJavaResolver.setup();
break;
}
testRunResult = new TestRunResult();
// Create a connection manager *after* we created the testRunId (in testRunResult).