Skip to content

Commit

Permalink
support NuGet v2 feeds
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnyzzz committed Dec 15, 2011
1 parent 6a91424 commit 9e7e08f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
* Date: 11.08.11 16:04
*/
public class FeedConstants {
public static final String MS_REF_FEED = "https://go.microsoft.com/fwlink/?LinkID=206669";
public static final String NUGET_FEED = "http://packages.nuget.org/v1/FeedService.svc";
public static final String MS_REF_FEED_V1 = "https://go.microsoft.com/fwlink/?LinkID=206669";
public static final String MS_REF_FEED_V2 = "https://go.microsoft.com/fwlink/?LinkID=230477";
public static final String NUGET_FEED_V1 = "http://packages.nuget.org/api/v1/FeedService.svc";
public static final String NUGET_FEED_V2 = "http://packages.nuget.org/api/v2";

public static final String NUGET_COMMANDLINE = "NuGet.CommandLine";
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import java.util.Arrays;
import java.util.Collection;

import static jetbrains.buildServer.nuget.common.FeedConstants.*;

/**
* Created by Eugene Petrenko (eugene.petrenko@gmail.com)
* Date: 15.08.11 16:33
Expand Down Expand Up @@ -82,7 +84,7 @@ public Collection<? extends NuGetTool> getAvailable(ToolsPolicy policy) throws F

private Collection<InstallableTool> fetchAvailable() throws FetchException {
FetchException exception = null;
for (String feedUrl : Arrays.asList(FeedConstants.MS_REF_FEED, FeedConstants.NUGET_FEED)) {
for (String feedUrl : Arrays.asList(MS_REF_FEED_V2, MS_REF_FEED_V1, NUGET_FEED_V2, NUGET_FEED_V1)) {
try {
final Collection<FeedPackage> packages = myReader.queryPackageVersions(feedUrl, FeedConstants.NUGET_COMMANDLINE);
return CollectionsUtil.filterAndConvertCollection(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public boolean accept(@NotNull PackageCheckRequest request) {
@NotNull
private String getUri(@NotNull SourcePackageReference request) {
String uri = request.getSource();
if (uri == null) uri = FeedConstants.MS_REF_FEED;
if (uri == null) uri = FeedConstants.MS_REF_FEED_V2;
return uri;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
import jetbrains.buildServer.nuget.server.feed.reader.impl.*;
import jetbrains.buildServer.util.FileUtil;
import jetbrains.buildServer.util.SimpleHttpServerBase;
import org.jetbrains.annotations.NotNull;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import java.io.*;
Expand Down Expand Up @@ -58,15 +60,20 @@ protected void tearDown() throws Exception {
myClient.dispose();
}

@Test
public void testRead_MS() throws IOException {
enableDebug();
readFeed(FeedConstants.MS_REF_FEED);
@DataProvider(name = "nuget-feeds")
public Object[][] nugetFeedsProvider() {
return new Object[][] {
{FeedConstants.MS_REF_FEED_V1},
{FeedConstants.MS_REF_FEED_V2},
{FeedConstants.NUGET_FEED_V1},
{FeedConstants.NUGET_FEED_V2},
};
}

@Test
public void testRead_NUGET() throws IOException {
readFeed(FeedConstants.NUGET_FEED);
@Test(dataProvider = "nuget-feeds")
public void testReadFeed(@NotNull final String feed) throws IOException {
enableDebug();
readFeed(feed);
}

private void readFeed(String msRefFeed) throws IOException {
Expand All @@ -81,14 +88,9 @@ private void readFeed(String msRefFeed) throws IOException {
}
}

@Test
public void testDownloadLatest_MS() throws IOException {
downloadLatest(FeedConstants.MS_REF_FEED);
}

@Test
public void testDownloadLatest_NUGET() throws IOException {
downloadLatest(FeedConstants.NUGET_FEED);
@Test(dataProvider = "nuget-feeds")
public void testDownloadLatest(@NotNull final String feed) throws IOException {
downloadLatest(feed);
}

private void downloadLatest(String feed) throws IOException {
Expand Down

0 comments on commit 9e7e08f

Please sign in to comment.