Skip to content

Commit 0543d39

Browse files
committed
Addition to 'Modification on version handler #13'
1 parent be0dae4 commit 0543d39

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

impl/src/main/java/com/jfrog/bintray/client/impl/handle/VersionHandleImpl.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,21 +146,19 @@ public VersionHandle upload(String path, InputStream content) throws BintrayCall
146146
return this;
147147
}
148148

149-
150149
@Override
151150
public VersionHandle publish() throws BintrayCallException {
152151
bintrayHandle.post(getCurrentVersionContentUri() + API_PUBLISH, null);
153152
return this;
154153
}
155154

156-
157155
@Override
158156
public VersionHandle publishSync() throws BintrayCallException {
159157
Map<String, String> headers = new HashMap<>();
160158
BintrayImpl.addContentTypeJsonHeader(headers);
161159
int timeout = -1;
162-
String wait = "{\n\"publish_wait_for_secs\":" + timeout + "\n}";
163-
bintrayHandle.post(getCurrentVersionContentUri() + API_PUBLISH, null, IOUtils.toInputStream(wait));
160+
String wait = "{\"publish_wait_for_secs\":" + timeout + "}";
161+
bintrayHandle.post(getCurrentVersionContentUri() + API_PUBLISH, headers, IOUtils.toInputStream(wait));
164162
return this;
165163
}
166164

impl/src/test/groovy/com/jfrog/bintray/client/test/spec/BintrayClientSpec.groovy

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,26 @@ class BintrayClientSpec extends Specification {
145145
response.getStatusLine().getStatusCode() == SC_OK
146146
}
147147

148+
def 'sync-publish artifacts'() {
149+
setup:
150+
files = ['com/bla/bintray-client-java-api.jar' : getClass().getResourceAsStream('/testJar1.jar'),
151+
'org/foo/bar/bintray-client-java-service.jar': getClass().getResourceAsStream('/testJar2.jar')]
152+
VersionHandle ver = bintray.subject(connectionProperties.username).repository(REPO_NAME).createPkg(pkgBuilder).createVersion(versionBuilder).upload(files)
153+
HttpClientConfigurator conf = new HttpClientConfigurator();
154+
155+
String url = getDownloadUrl()
156+
def anonymousDownloadServerClient = new BintrayImpl(conf.hostFromUrl(url).noRetry().getClient(), url, 5, 90000)
157+
158+
when:
159+
sleep(5000)
160+
ver.publishSync()
161+
sleep(20000)
162+
def response = anonymousDownloadServerClient.get("/" + connectionProperties.username + "/" + REPO_NAME + "/" + files.keySet().asList().get(0), null)
163+
164+
then:
165+
response.getStatusLine().getStatusCode() == SC_OK
166+
}
167+
148168
def 'discard artifacts'() {
149169
setup:
150170
files = ['com/bla/bintray-client-java-api.jar' : getClass().getResourceAsStream('/testJar1.jar'),

0 commit comments

Comments
 (0)