Project

General

Profile

« Previous | Next » 

Revision f1a25720

Added by Katja Luther over 6 years ago

  • ID f1a25720755daa96e8838a617a660dfced7b9f31
  • Parent 23e50194

first implementation for change from joda time to java8 time

View differences:

cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/parser/NonViralNameParserImplTest.java
17 17

  
18 18
import java.lang.reflect.InvocationTargetException;
19 19
import java.lang.reflect.Method;
20
import java.time.Duration;
21
import java.time.ZonedDateTime;
20 22
import java.util.List;
21 23
import java.util.regex.Matcher;
22 24
import java.util.regex.Pattern;
23 25

  
24 26
import org.apache.log4j.Logger;
25
import org.joda.time.DateTime;
26
import org.joda.time.Duration;
27 27
import org.junit.Assert;
28 28
import org.junit.Before;
29 29
import org.junit.BeforeClass;
......
1787 1787

  
1788 1788
    @Test  //#5072
1789 1789
    public final void testLongRunningParsingCapitals(){
1790
        DateTime start = DateTime.now();
1790
        ZonedDateTime start = ZonedDateTime.now();
1791 1791
        String nameStr = "Nazeris fujianensis JIAYAO HU, LIZHEN LI, MEIJUN ZHAO,2010";  //name from CoL that created problems
1792 1792
        INonViralName name = parser.parseReferencedName(nameStr, NomenclaturalCode.ICZN, null);
1793
        DateTime end = DateTime.now();
1794
        Duration duration = new Duration(start, end);
1795
        long seconds = duration.getStandardSeconds();
1793
        ZonedDateTime end = ZonedDateTime.now();
1794
        Duration duration = Duration.between(start, end);
1795
        long seconds = duration.getSeconds();
1796 1796
        //this is the critical part of the test that must not be changed
1797 1797
        Assert.assertTrue("Parsing of name should take less then 3 seconds but took " + seconds, seconds < 3);
1798 1798

  
......
1804 1804

  
1805 1805
        //name only
1806 1806
        String nameStr = "Dictyocoela berillonum R.S. Terry, J.E. Sm., R.G. Sharpe, T. Rigaud, D.T.J. Littlewood, J.E. Ironside, D. Rollinson & D. Bou";
1807
        DateTime start = DateTime.now();
1807
        ZonedDateTime start = ZonedDateTime.now();
1808 1808
        INonViralName name = parser.parseReferencedName(nameStr, NomenclaturalCode.ICNAFP, null);
1809
        DateTime end = DateTime.now();
1810
        Duration duration = new Duration(start, end);
1811
        long seconds = duration.getStandardSeconds();
1809
        ZonedDateTime end = ZonedDateTime.now();
1810
        Duration duration = Duration.between(start, end);
1811
        long seconds = duration.getSeconds();
1812 1812
        //this is the critical part of the test that must not be changed
1813 1813
        Assert.assertTrue("Parsing of name should take less then 3 seconds but took " + seconds, seconds < 3);
1814 1814
        //the following may be discussed
......
1817 1817

  
1818 1818
        //with reference
1819 1819
        nameStr = "Dictyocoela berillonum R.S. Terry, J.E. Sm., R.G. Sharpe, T. Rigaud, D.T.J. Littlewood, J.E. Ironside, D. Rollinson & D. Bou in Species Fauna Atlantica Of Blues Animals 3: p.345. 1758.";
1820
        start = DateTime.now();
1820
        start = ZonedDateTime.now();
1821 1821
        name = parser.parseReferencedName(nameStr, NomenclaturalCode.ICNAFP, null);
1822
        end = DateTime.now();
1823
        duration = new Duration(start, end);
1824
        seconds = duration.getStandardSeconds();
1822
        end = ZonedDateTime.now();
1823
        duration = Duration.between(start, end);
1824
        seconds = duration.getSeconds();
1825 1825
        //this is the critical part of the test that must not be changed
1826 1826
        Assert.assertTrue("Parsing of name should take less then 3 seconds but took " + seconds, seconds < 3);
1827 1827
        //the following may be discussed
......
1839 1839
        String authorStr = "R.S. Terry J.E. Sm. R.G. Sharpe T. Rigaud T.H. Rigseaud D.T. Li, R.G. Sharpe, T. Rigaud, D.T.J. Littlewood & D. Bou";
1840 1840
        TeamOrPersonBase[] authorArray = new TeamOrPersonBase[4];
1841 1841
        try {
1842
            DateTime start = DateTime.now();
1842
            ZonedDateTime start = ZonedDateTime.now();
1843 1843
            parser.fullAuthors(authorStr, authorArray, new Integer[]{1800, null, null, null}, NomenclaturalCode.ICNAFP);
1844
            DateTime end = DateTime.now();
1845
            Duration duration = new Duration(start, end);
1846
            long seconds = duration.getStandardSeconds();
1844
            ZonedDateTime end = ZonedDateTime.now();
1845
            Duration duration = Duration.between(start, end);
1846
            long seconds = duration.getSeconds();
1847 1847
//            System.out.println(seconds);
1848 1848
            //this is the critical part of the test that must not be changed
1849 1849
            Assert.assertTrue("Parsing of name should take less then 3 seconds but took " + seconds, seconds < 3);

Also available in: Unified diff