Search in sources :

Example 11 with Parser

use of org.fagu.fmv.soft.find.ExecSoftFoundFactory.Parser in project fmv by f-agu.

the class PdfInfoSoftProviderTestCase method testParseOnLinux_original.

/**
 * @throws IOException
 */
@Test
public void testParseOnLinux_original() throws IOException {
    Parser parser = newParser();
    parser.readLine("pdfinfo version 3.04");
    parser.readLine("Copyright 1996-2014 Glyph & Cog, LLC");
    assertInfo(parser, new Version(3, 4));
}
Also used : Version(org.fagu.version.Version) Parser(org.fagu.fmv.soft.find.ExecSoftFoundFactory.Parser) Test(org.junit.Test)

Example 12 with Parser

use of org.fagu.fmv.soft.find.ExecSoftFoundFactory.Parser in project fmv by f-agu.

the class PdfInfoSoftProviderTestCase method testParseOnWindows_original.

/**
 * @throws IOException
 */
@Test
public void testParseOnWindows_original() throws IOException {
    Parser parser = newParser();
    parser.readLine("pdfinfo version 3.04");
    parser.readLine("Copyright 1996-2014 Glyph & Cog, LLC");
    assertInfo(parser, new Version(3, 4));
}
Also used : Version(org.fagu.version.Version) Parser(org.fagu.fmv.soft.find.ExecSoftFoundFactory.Parser) Test(org.junit.Test)

Example 13 with Parser

use of org.fagu.fmv.soft.find.ExecSoftFoundFactory.Parser in project fmv by f-agu.

the class PdfInfoSoftProviderTestCase method testParseOnLinux_popplers.

/**
 * @throws IOException
 */
@Test
public void testParseOnLinux_popplers() throws IOException {
    Parser parser = newParser();
    parser.readLine("pdfinfo version 0.12.4");
    parser.readLine("Copyright 2005-2009 The Poppler Developers - http://poppler.freedesktop.org");
    parser.readLine("Copyright 1996-2004 Glyph & Cog, LLC");
    assertInfo(parser, new Version(0, 12, 4));
}
Also used : Version(org.fagu.version.Version) Parser(org.fagu.fmv.soft.find.ExecSoftFoundFactory.Parser) Test(org.junit.Test)

Example 14 with Parser

use of org.fagu.fmv.soft.find.ExecSoftFoundFactory.Parser in project fmv by f-agu.

the class SoftTestCase method test1.

@Test
@Ignore
public void test1() throws Exception {
    SoftFoundFactory ffSoftFoundFactory = ExecSoftFoundFactory.forProvider(new TestSoftProvider("ffprout")).withParameters("-version").parseFactory((file, softPolicy) -> new Parser() {

        private Integer build;

        @Override
        public void readLine(String line) {
            if (line.startsWith("ff")) {
                build = Integer.parseInt(StringUtils.substringBetween(line, "N-", "-"));
            }
        }

        @Override
        public SoftFound closeAndParse(String cmdLineStr, int exitValue) throws IOException {
            if (build == null) {
                return SoftFound.foundBadSoft(file);
            }
            // return SoftFound.found(file, new TestSoftInfo(build));
            return SoftFound.foundBadVersion(new TestSoftInfo(49), "85");
        }
    }).build();
    // SoftFoundFactory identifyFoundFactory = ExecSoftFoundFactory.withParameters("-version").parseFactory(file ->
    // new Parser() {
    // 
    // @Override
    // public void readLine(String line) {}
    // 
    // @Override
    // public SoftFound closeAndParse(String cmdLineStr, int exitValue) throws IOException {
    // return SoftFound.foundBadVersion(new TestSoftInfo(49), "85");
    // }
    // }).build();
    Soft soft = Soft.with(new TestSoftProvider("ffprout")).search(ffSoftFoundFactory);
    // Soft ffprobeSoft = Soft.with("ffprobe").search(ffSoftFoundFactory);
    // Soft identifySoft = Soft.withName("identify").search(identifyFoundFactory);
    SoftLogger softFormatter = new SoftLogger(Arrays.asList(soft));
    // SoftLogger softFormatter = new SoftLogger(Arrays.asList(ffprobeSoft, identifySoft, ffmpegSoft));
    softFormatter.logDetails(System.out::println);
    // System.out.println(soft.getFounds());
    // System.out.println(soft.getFile());
    soft.withParameters("").execute();
}
Also used : SoftFoundFactory(org.fagu.fmv.soft.find.SoftFoundFactory) Arrays(java.util.Arrays) ExecSoftFoundFactory(org.fagu.fmv.soft.find.ExecSoftFoundFactory) Date(java.util.Date) SoftFound(org.fagu.fmv.soft.find.SoftFound) IOException(java.io.IOException) Test(org.junit.Test) StringUtils(org.apache.commons.lang3.StringUtils) Executors(java.util.concurrent.Executors) Future(java.util.concurrent.Future) Executed(org.fagu.fmv.soft.SoftExecutor.Executed) Parser(org.fagu.fmv.soft.find.ExecSoftFoundFactory.Parser) Ignore(org.junit.Ignore) ExecutorService(java.util.concurrent.ExecutorService) SoftFoundFactory(org.fagu.fmv.soft.find.SoftFoundFactory) ExecSoftFoundFactory(org.fagu.fmv.soft.find.ExecSoftFoundFactory) Parser(org.fagu.fmv.soft.find.ExecSoftFoundFactory.Parser) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 15 with Parser

use of org.fagu.fmv.soft.find.ExecSoftFoundFactory.Parser in project fmv by f-agu.

the class JavaSoftProviderTestCase method testParse18OnLinux.

/**
 * @throws IOException
 */
@Test
public void testParse18OnLinux() throws IOException {
    Parser parser = newParser();
    parser.readLine("openjdk version \"1.8.0_45\"");
    parser.readLine("OpenJDK Runtime Environment (build 1.8.0_45-b13)");
    parser.readLine("OpenJDK 64-Bit Server VM (build 25.45-b02, mixed mode)");
    assertInfo(parser, new Version(1, 8, 0, 45));
}
Also used : Version(org.fagu.version.Version) Parser(org.fagu.fmv.soft.find.ExecSoftFoundFactory.Parser) Test(org.junit.Test)

Aggregations

Parser (org.fagu.fmv.soft.find.ExecSoftFoundFactory.Parser)20 Test (org.junit.Test)18 Version (org.fagu.version.Version)14 Calendar (java.util.Calendar)3 Date (java.util.Date)2 SoftFound (org.fagu.fmv.soft.find.SoftFound)2 IOException (java.io.IOException)1 Arrays (java.util.Arrays)1 HashMap (java.util.HashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 Map (java.util.Map)1 Set (java.util.Set)1 ExecutorService (java.util.concurrent.ExecutorService)1 Executors (java.util.concurrent.Executors)1 Future (java.util.concurrent.Future)1 Matcher (java.util.regex.Matcher)1 StringUtils (org.apache.commons.lang3.StringUtils)1 Executed (org.fagu.fmv.soft.SoftExecutor.Executed)1 ExecSoftFoundFactory (org.fagu.fmv.soft.find.ExecSoftFoundFactory)1 SoftFoundFactory (org.fagu.fmv.soft.find.SoftFoundFactory)1