Exemplo n.º 1
0
        public void ShouldFindMavenPackageAlreadyUploaded()
        {
            var destinationFilePath = Path.Combine(downloadPath, PackageName.ToCachedFileName(mavenPackageId, VersionFactory.CreateMavenVersion(packageVersion), ".jar"));

            File.Copy(mavenPackage, destinationFilePath);

            var result = FindPackages(mavenPackageId, packageVersion, mavenPackageHash, VersionFormat.Maven);

            result.AssertSuccess();
            result.AssertServiceMessage(
                ServiceMessageNames.CalamariFoundPackage.Name,
                Is.True,
                message: "Expected service message '{0}' to be True",
                args: ServiceMessageNames.CalamariFoundPackage.Name);

            result.AssertOutput(
                "Package {0} {1} hash {2} has already been uploaded",
                mavenPackageId,
                packageVersion,
                mavenPackageHash);

            var foundPackage = result.CapturedOutput.FoundPackage;

            Assert.AreEqual(VersionFactory.CreateMavenVersion(packageVersion), foundPackage.Version);
            Assert.AreEqual(mavenPackageHash, foundPackage.Hash);
            Assert.AreEqual(destinationFilePath, foundPackage.RemotePath);
            Assert.AreEqual(".jar", foundPackage.FileExtension);
            Assert.AreEqual(mavenPackageId, foundPackage.PackageId);
        }
Exemplo n.º 2
0
        public void ShouldFindTheCorrectMavenPackageWhenSimilarPackageExist()
        {
            var destinationFilePath = Path.Combine(downloadPath, PackageName.ToCachedFileName(mavenPackageId, VersionFactory.CreateMavenVersion(packageVersion), ".jar"));

            File.Copy(mavenPackage, destinationFilePath);

            var destination2FilePath = Path.Combine(downloadPath, PackageName.ToCachedFileName(mavenPackageId + ".Test", VersionFactory.CreateMavenVersion(packageVersion), ".jar"));

            File.Copy(mavenPackage, destination2FilePath);

            var result = FindPackages(mavenPackageId, newpackageVersion, mavenPackageHash, VersionFormat.Maven);

            result.AssertSuccess();
            result.AssertOutput("Package {0} version {1} hash {2} has not been uploaded.",
                                mavenPackageId,
                                newpackageVersion,
                                mavenPackageHash);
            result.AssertOutput("Finding earlier packages that have been uploaded to this Tentacle");
            result.AssertOutput("Found 1 earlier version of {0} on this Tentacle", mavenPackageId);
            result.AssertOutput("  - {0}: {1}", packageVersion, destinationFilePath);

            result.AssertServiceMessage(ServiceMessageNames.FoundPackage.Name, Is.True);
            var foundPackage = result.CapturedOutput.FoundPackage;

            Assert.AreEqual(VersionFactory.CreateMavenVersion(packageVersion), foundPackage.Version);
            Assert.AreEqual(mavenPackageHash, foundPackage.Hash);
            Assert.AreEqual(destinationFilePath, foundPackage.RemotePath);
            Assert.AreEqual(".jar", foundPackage.FileExtension);
            Assert.AreEqual(mavenPackageId, foundPackage.PackageId);
        }
Exemplo n.º 3
0
        public void DownloadMavenPackage()
        {
            var downloader = GetDownloader();
            var pkg        = downloader.DownloadPackage("com.google.guava:guava", VersionFactory.CreateMavenVersion("22.0"), "feed-maven",
                                                        new Uri("https://repo.maven.apache.org/maven2/"), "", "", true, 3, TimeSpan.FromSeconds(3));

            Assert.AreEqual("com.google.guava:guava", pkg.PackageId);
        }
Exemplo n.º 4
0
        public void FromFile_MavenVersion()
        {
            var details = PackageName.FromFile("blah/[email protected]%[email protected]");

            Assert.AreEqual("pkg", details.PackageId);
            Assert.AreEqual(VersionFactory.CreateMavenVersion("1.0.0+CAT"), details.Version);
            Assert.AreEqual(".jar", details.Extension);
        }
Exemplo n.º 5
0
        public void ToCachedFileName_MavenEncodedChars()
        {
            var filename = PackageName.ToCachedFileName("My/Package", VersionFactory.CreateMavenVersion("12:8"), ".jar");

            var scrubbedFilename = Regex.Replace(filename, "[0-9A-F]{32}", "<CACHE-GUID>");

            Assert.AreEqual("My%2FPackage@M12%3A8@<CACHE-GUID>.jar", scrubbedFilename);
        }
Exemplo n.º 6
0
        public void DownloadMavenPackage()
        {
            var downloader = new MavenPackageDownloader(CalamariPhysicalFileSystem.GetPhysicalFileSystem(), new FreeSpaceChecker(CalamariPhysicalFileSystem.GetPhysicalFileSystem(), new CalamariVariables()));
            var pkg        = downloader.DownloadPackage("com.google.guava:guava", VersionFactory.CreateMavenVersion("22.0"), "feed-maven",
                                                        new Uri("https://repo.maven.apache.org/maven2/"), new NetworkCredential("", ""), true, 3, TimeSpan.FromSeconds(3));

            Assert.AreEqual("com.google.guava:guava", pkg.PackageId);
        }
Exemplo n.º 7
0
        static IVersion DecodeVersion(string input)
        {
            switch (input[0])
            {
            case 'S':
                return(VersionFactory.CreateSemanticVersion(Decode(input.Substring(1)), true));

            case 'M':
                return(VersionFactory.CreateMavenVersion(Decode(input.Substring(1))));
            }
            throw new Exception($"Unrecognised Version format `{input}`");
        }