use of com.synopsys.integration.detectable.detectables.clang.packagemanager.resolver.ApkArchitectureResolver in project synopsys-detect by blackducksoftware.
the class ClangPackageManagerFactory method createPackageManagers.
public List<ClangPackageManager> createPackageManagers() {
List<ClangPackageManager> packageManagers = new ArrayList<>();
packageManagers.add(new ClangPackageManager(packageManagerInfoFactory.apk(), new ApkPackageManagerResolver(new ApkArchitectureResolver())));
packageManagers.add(new ClangPackageManager(packageManagerInfoFactory.dpkg(), new DpkgPackageManagerResolver(new DpkgPkgDetailsResolver())));
packageManagers.add(new ClangPackageManager(packageManagerInfoFactory.rpm(), new RpmPackageManagerResolver(new Gson())));
return packageManagers;
}
use of com.synopsys.integration.detectable.detectables.clang.packagemanager.resolver.ApkArchitectureResolver in project synopsys-detect by blackducksoftware.
the class ClangPackageManagerRunnerTest method testApkNonPkgOwnedIncludeFile.
@Test
public void testApkNonPkgOwnedIncludeFile() throws ExecutableRunnerException {
ClangPackageManagerInfoFactory factory = ClangPackageManagerInfoFactory.standardFactory();
ClangPackageManagerInfo packageManagerInfo = factory.apk();
ApkArchitectureResolver archResolver = new ApkArchitectureResolver();
ClangPackageManagerResolver packageResolver = new ApkPackageManagerResolver(archResolver);
String pkgOwnerPattern = "ERROR: %s: Could not find owner package";
testNonPkgOwnedIncludeFile(packageManagerInfo, packageResolver, pkgOwnerPattern);
}
use of com.synopsys.integration.detectable.detectables.clang.packagemanager.resolver.ApkArchitectureResolver in project synopsys-detect by blackducksoftware.
the class ApkPackageManagerTest method canParsePackages.
@Test
public void canParsePackages() throws ExecutableRunnerException, NotOwnedByAnyPkgException {
StringBuilder sb = new StringBuilder();
sb.append("garbage\n");
sb.append("nonsense\n");
sb.append("this line has the is owned by substring\n");
sb.append(" is owned by \n");
// This is the one valid line; rest should be discarded
sb.append("/usr/include/stdlib.h is owned by musl-dev-1.1.18-r3\n");
sb.append("/usr/include/stdlib.h is owned by .musl-dev-1.1.18-r99\n");
String pkgMgrOwnedByOutput = sb.toString();
ApkArchitectureResolver architectureResolver = Mockito.mock(ApkArchitectureResolver.class);
Mockito.when(architectureResolver.resolveArchitecture(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(Optional.of("x86_64"));
ApkPackageManagerResolver apkPackageManagerResolver = new ApkPackageManagerResolver(architectureResolver);
ClangPackageManagerInfo apk = new ClangPackageManagerInfoFactory().apk();
List<PackageDetails> pkgs = apkPackageManagerResolver.resolvePackages(apk, null, null, pkgMgrOwnedByOutput);
Assertions.assertEquals(1, pkgs.size());
Assertions.assertEquals("musl-dev", pkgs.get(0).getPackageName());
Assertions.assertEquals("1.1.18-r3", pkgs.get(0).getPackageVersion());
Assertions.assertEquals("x86_64", pkgs.get(0).getPackageArch());
}
use of com.synopsys.integration.detectable.detectables.clang.packagemanager.resolver.ApkArchitectureResolver in project synopsys-detect by blackducksoftware.
the class ApkPackageManagerTest method canParseArchitecture.
@Test
public void canParseArchitecture() throws ExecutableRunnerException {
final String exampleOutput = "x86_64\n";
DetectableExecutableRunner executableRunner = Mockito.mock(DetectableExecutableRunner.class);
Mockito.when(executableRunner.execute(null, "apk", Arrays.asList("info", "--print-arch"))).thenReturn(new ExecutableOutput(0, exampleOutput, ""));
ApkArchitectureResolver architectureResolver = new ApkArchitectureResolver();
Optional<String> architecture = architectureResolver.resolveArchitecture(new ClangPackageManagerInfoFactory().apk(), null, executableRunner);
assertTrue(architecture.isPresent());
Assertions.assertEquals("x86_64", architecture.get());
}
Aggregations