Skip to content
This repository has been archived by the owner on Feb 11, 2022. It is now read-only.

Commit

Permalink
Merge pull request #185 from novoda/develop
Browse files Browse the repository at this point in the history
Develop to Release
  • Loading branch information
Xavi Rigau authored Nov 16, 2018
2 parents 8b3278b + e9e8451 commit 74e8bf2
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
allprojects {
version = '1.2.0'
version = '1.2.1'
repositories {
mavenCentral()
google()
Expand Down
8 changes: 6 additions & 2 deletions core/src/main/java/com/novoda/merlin/HttpRequestMaker.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ class HttpRequestMaker implements RequestMaker {

@Override
public Request head(Endpoint endpoint) {
HttpURLConnection urlConnection = null;
try {
HttpURLConnection urlConnection = connectTo(endpoint);
urlConnection = connectTo(endpoint);
urlConnection.setRequestProperty("Accept-Encoding", "");

setConnectionToHeadRequest(urlConnection);
Expand All @@ -21,6 +22,10 @@ public Request head(Endpoint endpoint) {
return new MerlinHttpRequest(urlConnection);
} catch (IOException e) {
throw new RequestException(e);
} finally {
if (urlConnection != null) {
urlConnection.disconnect();
}
}
}

Expand Down Expand Up @@ -55,7 +60,6 @@ public int getResponseCode() {
request.disconnect();
}
}

}

}
2 changes: 1 addition & 1 deletion core/src/main/java/com/novoda/merlin/Register.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void register(T registerable) {
}

List<T> registerables() {
return registerables;
return new ArrayList<>(registerables);
}

void clear() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.junit.Test;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;

public class ConnectCallbackManagerTest {
Expand Down Expand Up @@ -40,6 +41,15 @@ public void givenMultipleRegisteredConnectables_whenCallingOnConnect_thenCallsCo
}
}

@Test
public void givenRegisteredConnectable_whenCallingOnConnectAndAddingConnectable_thenCallsConnectForConnectable() {
Connectable connectable = givenRegisteredConnectableModifyingConnectables();

connectCallbackManager.onConnect();

verify(connectable).onConnect();
}

private List<Connectable> givenMultipleRegisteredConnectables() {
List<Connectable> connectables = new ArrayList<>();

Expand All @@ -57,4 +67,17 @@ private Connectable givenRegisteredConnectable() {
return connectable;
}

private Connectable givenRegisteredConnectableModifyingConnectables() {
Connectable connectable = new Connectable() {

@Override
public void onConnect() {
connectables.register(mock(Connectable.class));
}
};
Connectable spyConnectable = spy(connectable);
connectables.register(spyConnectable);
return spyConnectable;
}

}
Binary file removed releases/merlin-core-v0.2.jar
Binary file not shown.
Binary file removed releases/merlin-core-v0.4.1.jar
Binary file not shown.
Binary file removed releases/merlin-core-v0.5.aar
Binary file not shown.
Binary file removed releases/res/on_connect.jpg
Binary file not shown.
Binary file removed releases/res/on_disconnect.jpg
Binary file not shown.

0 comments on commit 74e8bf2

Please sign in to comment.