001/*
002 * Copyright 2015-2020 the original author or authors
003 *
004 * This software is licensed under the Apache License, Version 2.0,
005 * the GNU Lesser General Public License version 2 or later ("LGPL")
006 * and the WTFPL.
007 * You may choose either license to govern your use of this software only
008 * upon the condition that you accept all of the terms of either
009 * the Apache License 2.0, the LGPL 2.1+ or the WTFPL.
010 */
011package org.minidns.integrationtest;
012
013import org.minidns.DnsCache;
014import org.minidns.cache.ExtendedLruCache;
015import org.minidns.cache.FullLruCache;
016import org.minidns.cache.LruCache;
017import org.minidns.dnssec.DnssecClient;
018import org.minidns.source.NetworkDataSourceWithAccounting;
019
020public class IntegrationTestTools {
021
022    public enum CacheConfig {
023        without,
024        normal,
025        extended,
026        full,
027    }
028
029    public static DnssecClient getClient(CacheConfig cacheConfig) {
030        DnsCache cache;
031        switch (cacheConfig) {
032        case without:
033            cache = null;
034            break;
035        case normal:
036            cache = new LruCache();
037            break;
038        case extended:
039            cache = new ExtendedLruCache();
040            break;
041        case full:
042            cache = new FullLruCache();
043            break;
044        default:
045            throw new IllegalStateException();
046        }
047
048        DnssecClient client = new DnssecClient(cache);
049        client.setDataSource(new NetworkDataSourceWithAccounting());
050        return client;
051    }
052
053}