<commit_before>package test.com.qiniu.storage;

import com.qiniu.common.QiniuException;
import com.qiniu.common.Zone;
import com.qiniu.http.Client;
import com.qiniu.http.Response;
import com.qiniu.storage.BucketManager;
import com.qiniu.storage.Configuration;
import com.qiniu.storage.model.*;
import com.qiniu.util.Json;
import com.qiniu.util.StringUtils;
import okhttp3.Call;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import test.com.qiniu.ResCode;
import test.com.qiniu.TestConfig;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*;

import static org.junit.jupiter.api.Assertions.*;

public class BucketTest {

    List<Integer> batchStatusCode = Arrays.asList(200, 298);
    private BucketManager dummyBucketManager;

    /**
     * 初始化
     *
     * @throws Exception
     */
    @BeforeEach
    public void setUp() throws Exception {
        Configuration cfg = new Configuration(Zone.autoZone());
        cfg.useHttpsDomains = false;
        this.dummyBucketManager = new BucketManager(TestConfig.dummyAuth, new Configuration());
    }

    /**
     * 测试列举空间名
     */
    @Test
    @Tag("IntegrationTest")
    public void testBuckets() throws Exception {
        testFileWithHandler(new TestFileHandler() {
            @Override
            public void testFile(TestConfig.TestFile file, BucketManager bucketManager) throws IOException {
                try {
                    String[] buckets = bucketManager.buckets();
                    assertTrue(StringUtils.inStringArray(file.getBucketName(), buckets));
                } catch (QiniuException e) {
                    assertTrue(ResCode.find(e.code(), ResCode.getPossibleResCode()));
                }
            }
        });

        try {
            dummyBucketManager.buckets();
            fail();
        } catch (QiniuException e) {
            assertTrue(ResCode.find(e.code(), ResCode.getPossibleResCode(401)));
        }
    }

    /**
     * 测试列举空间域名
     */
    @Test
    @Tag("IntegrationTest")
    public void testDomains() throws Exception {
        testFileWithHandler(new TestFileHandler() {
            @Override
            public void testFile(TestConfig.TestFile file, BucketManager bucketManager) throws IOException {
                try {
                    String[] domains = bucketManager.domainList(file.getBucketName());
                    assertNotNull(domains);
                } catch (QiniuException e) {
                    assertTrue(ResCode.find(e.code(), ResCode.getPossibleResCode(401)));
                }
            }
        });
    }

    /**
     * 测试list接口，limit=2
     */
    @Test<commit_msg>api host test case: 5 region<commit_after>package test.com.qiniu.storage;

import com.qiniu.common.QiniuException;
import com.qiniu.common.Zone;
import com.qiniu.http.Client;
import com.qiniu.http.Response;
import com.qiniu.storage.BucketManager;
import com.qiniu.storage.Configuration;
import com.qiniu.storage.model.*;
import com.qiniu.util.Json;
import com.qiniu.util.StringUtils;
import okhttp3.Call;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import test.com.qiniu.ResCode;
import test.com.qiniu.TestConfig;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*;

import static org.junit.jupiter.api.Assertions.*;

public class BucketTest {

    List<Integer> batchStatusCode = Arrays.asList(200, 298);
    private BucketManager dummyBucketManager;

    /**
     * 初始化
     *
     * @throws Exception
     */
    @BeforeEach
    public void setUp() throws Exception {
        Configuration cfg = new Configuration(Zone.autoZone());
        cfg.useHttpsDomains = false;
        this.dummyBucketManager = new BucketManager(TestConfig.dummyAuth, new Configuration());
    }

    /**
     * 测试列举空间名
     */
    @Test
    @Tag("IntegrationTest")
    public void testBuckets() throws Exception {
        testFileWithHandler(new TestFileHandler() {
            @Override
            public void testFile(TestConfig.TestFile file, BucketManager bucketManager) throws IOException {
                try {
                    String[] buckets = bucketManager.buckets();
                    assertTrue(StringUtils.inStringArray(file.getBucketName(), buckets));
                } catch (QiniuException e) {
                    assertTrue(ResCode.find(e.code(), ResCode.getPossibleResCode()));
                }
            }
        });

        try {
            dummyBucketManager.buckets();
            fail();
        } catch (QiniuException e) {
            assertTrue(ResCode.find(e.code(), ResCode.getPossibleResCode(401)));
        }
    }

    /**
     * 测试列举空间域名
     */
    @Test
    @Tag("IntegrationTest")
    public void testDomains() throws Exception {
        testFileWithHandler(new TestFileHandler() {
            @Override
            public void testFile(TestConfig.TestFile file, BucketManager bucketManager) throws IOException {
                try {
                    String[] domains = bucketManager.domainList(file.getBucketName());
                    domains = bucketManager.domainList("sdk-z0");
                    assertNotNull(domains);
                    domains = bucketManager.domainList("sdk-z1");
                    assertNotNull(domains);
                    domains = bucketManager.domainList("sdk-z2");
                    assertNotNull(domains);
                    domains = bucketManager.domainList("sdk-na0");
                    assertNotNull(domains);
                    domains = bucketManager.domainList("sdk-as0");
                    assertNotNull(domains);
                } catch (QiniuException e) {
                    assertTrue(ResCode.find(e.code(), ResCode.getPossibleResCode(401)));
                }
            }
        });
    }

    /**
     * 测试list接口，limit=2
     */
    @Test
{'fraction_non_alphanumeric': 0.10719530102790015, 'fraction_numerical': 0.006200032631750694, 'mean_word_length': 2.28686327077748, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4622224', 'n_tokens_mistral': 1804, 'n_tokens_neox': 1745, 'n_words': 310}