package io.github.kavahub.file.performance;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.options.ChainedOptionsBuilder;
import org.openjdk.jmh.runner.options.OptionsBuilder;

import io.github.kavahub.file.reader.AIOFileReader;
import io.github.kavahub.file.reader.NIOFileLineReader;


/**
 * 逐行读取性能测试
 * 
 * <p>
 * 测试结果：
 * 
 * <pre>
 * Benchmark                                          Mode  Cnt    Score    Error  Units
 * ReadLineBenchmark.readLineUsingAsyncReader        thrpt   10  373.187 ± 53.861  ops/s
 * ReadLineBenchmark.readLineUsingJavaFiles          thrpt   10  282.852 ± 41.247  ops/s
 * ReadLineBenchmark.readLineUsingNIOFileLineReader  thrpt   10  256.296 ± 10.875  ops/s
 * </pre>
 */
@State(Scope.Benchmark)
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.SECONDS)
@Measurement(iterations = 10, time = 1)
@Warmup(iterations = 1)
@Fork(1)
public class ReadLineBenchmark {
    private final static Path file = Paths.get("src", "test", "resources", "fileWithmanyOfLine.txt");
    
    public static void main(String[] args) throws Exception {
        ChainedOptionsBuilder opts = new OptionsBuilder().include(ReadLineBenchmark.class.getSimpleName());

        new Runner(opts.threads(8).build()).run();
    }

    @Benchmark
    public List<String> readLineUsingJavaFiles() throws IOException {
        return Files.readAllLines(file);
    }

    @Benchmark
    public List<String> readLineUsingAsyncReader(){
        List<String> result = new ArrayList<>();
        AIOFileReader.line(file).subscribe(data -> result.add(data), err -> err.printStackTrace()).join();

        return result;
    }

    @Benchmark
    public List<String> readLineUsingNIOFileLineReader(){
        List<String> result = new ArrayList<>();
        NIOFileLineReader.read(file).subscribe(data-> result.add(data), err -> err.printStackTrace()).join();
        return result;
    }
}
<filename>server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RecipientRewriteTableTest.java
/****************************************************************
 * Licensed to the Apache Software Foundation (ASF) under one   *
 * or more contributor license agreements.  See the NOTICE file *
 * distributed with this work for additional information        *
 * regarding copyright ownership.  The ASF licenses this file   *
 * to you under the Apache License, Version 2.0 (the            *
 * "License"); you may not use this file except in compliance   *
 * with the License.  You may obtain a copy of the License at   *
 *                                                              *
 *   http://www.apache.org/licenses/LICENSE-2.0                 *
 *                                                              *
 * Unless required by applicable law or agreed to in writing,   *
 * software distributed under the License is distributed on an  *
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
 * KIND, either express or implied.  See the License for the    *
 * specific language governing permissions and limitations      *
 * under the License.                                           *
 ****************************************************************/
package org.apache.james.transport.mailets;

import static org.assertj.core.api.Assertions.assertThat;

import javax.mail.internet.MimeMessage;

import org.apache.james.domainlist.api.DomainList;
import org.apache.james.util.MimeMessageUtil;
import org.apache.mailet.MailetContext;
import org.apache.mailet.base.MailAddressFixture;
import org.apache.mailet.base.test.FakeMail;
import org.apache.mailet.base.test.FakeMailContext;
import org.apache.mailet.base.test.FakeMailetConfig;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

public class RecipientRewriteTableTest {

    private RecipientRewriteTable mailet;

    @Mock org.apache.james.rrt.api.RecipientRewriteTable virtualTableStore;
    @Mock DomainList domainList;

    private FakeMail mail;
    private MimeMessage message;
    private FakeMailetConfig mailetConfig;
    private MailetContext mailetContext;

    @Before
    public void setUp() throws Exception {
        MockitoAnnotations.initMocks(this);
        
        mailet = new RecipientRewriteTable(virtualTableStore, domainList);

        message = MimeMessageUtil.defaultMimeMessage();

        mailetContext = FakeMailContext.defaultContext();

        mailetConfig = FakeMailetConfig.builder()
           .mailetName("vut")
           .mailetContext(mailetContext)
           .build();

        mail = FakeMail.builder().build();
    }

    @Test
    public void getMailetInfoShouldReturnCorrectInformation() throws Exception {
        assertThat(mailet.getMailetInfo()).isEqualTo("RecipientRewriteTable Mailet");
    }

    @Test(expected = NullPointerException.class)
    public void serviceShouldThrowExceptionWithNullMail() throws Exception {
        mailet.service(null);
    }

    @Test
    public void serviceShouldDoNothingIfAbsentMessageInMail() throws Exception {
        mailet.service(mail);
    }
    
    @Test
    public void serviceShouldWork() throws Exception {
        mailet.init(mailetConfig);
        mail = FakeMail.builder()
           .mimeMessage(message)
           .recipients(MailAddressFixture.ANY_AT_JAMES, MailAddressFixture.OTHER_AT_JAMES)
           .build();

        mailet.service(mail);

        assertThat(mail.getRecipients()).containsOnly(MailAddressFixture.ANY_AT_JAMES, MailAddressFixture.OTHER_AT_JAMES);
    }
}
The University of Maine at Machias Alumni Spotlight shines on Colleen Brown of Whiting, UMM Class of 2013, who is currently a special education teacher at Washington Academy in East Machias.
actively involved in Special Olympics and other local activities.
and to keep plugging away.
will be your friends.
and the Larsons as a business major and finishing with Dan Qualls, Gail Romei and Heather Ball. As an College Studies major with a focus on Secondary Education/Special Education, I was prepared for almost anything I have encountered as a Special Education Teacher.
Discover the symbol of Canali’s masculine elegance, this timeless suit is handcrafted in Italy. Masterfully tailored from pure wool in a subtle mélange crosshatch pattern, the elegant essential cuts a comfortably streamlined silhouette that isn't too constraining. An exceptionally versatile investment for your formal wardrobe, it ensures countless seasons of confident style.
Vertical Sleeve Gastrectomy, in which approximately three-fourths of the stomach is removed and a narrow gastric tube is created, is the most popular bariatric surgical procedure in the United States. It is considered a quicker,