Debian Codegraph @

minidns-integration-test/src/main/java/org/minidns/integrationtest/IntegrationTestTools.java

raw
1 /*
2 * Copyright 2015-2020 the original author or authors
3 *
4 * This software is licensed under the Apache License, Version 2.0,
5 * the GNU Lesser General Public License version 2 or later ("LGPL")
6 * and the WTFPL.
7 * You may choose either license to govern your use of this software only
8 * upon the condition that you accept all of the terms of either
9 * the Apache License 2.0, the LGPL 2.1+ or the WTFPL.
10 */
11 package org.minidns.integrationtest;
12
13 import org.minidns.DnsCache;
14 import org.minidns.cache.ExtendedLruCache;
15 import org.minidns.cache.FullLruCache;
16 import org.minidns.cache.LruCache;
17 import org.minidns.dnssec.DnssecClient;
18 import org.minidns.source.NetworkDataSourceWithAccounting;
19
20 public class IntegrationTestTools {
21
22 public enum CacheConfig {
23 without,
24 normal,
25 extended,
26 full,
27 }
28
29 public static DnssecClient getClient(CacheConfig cacheConfig) {
30 DnsCache cache;
31 switch (cacheConfig) {
32 case without:
33 cache = null;
34 break;
35 case normal:
36 cache = new LruCache();
37 break;
38 case extended:
39 cache = new ExtendedLruCache();
40 break;
41 case full:
42 cache = new FullLruCache();
43 break;
44 default:
45 throw new IllegalStateException();
46 }
47
48 DnssecClient client = new DnssecClient(cache);
49 client.setDataSource(new NetworkDataSourceWithAccounting());
50 return client;
51 }
52
53 }