Skip to content

Commit

Permalink
1. Updated to use web3j 3.2.0.
Browse files Browse the repository at this point in the history
2. Updated to Spring Boot 1.5.9.
3. Updated to gradle 4.4.
4. Cleaned up health indicator code.
5. Added Travis CI build.
  • Loading branch information
conor10 committed Dec 14, 2017
1 parent 2dd7dd6 commit ece20a3
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 23 deletions.
20 changes: 20 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
language: java

jdk:
- oraclejdk8

sudo: false # as per http://blog.travis-ci.com/2014-12-17-faster-builds-with-container-based-infrastructure/

# Avoid uploading cache after every build with Gradle - see https://docs.travis-ci.com/user/languages/java/#Caching
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/

# Don't run integrationTests as they require a live Ethereum client to be running
# Add --info to view details of test failures
script: ./gradlew --info check

6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# web3j Spring Boot Starter

[![Build Status](https://travis-ci.org/web3j/web3j-spring-boot-starter.svg?branch=master)](https://travis-ci.org/web3j/web3j-spring-boot-starter)

Integrate web3j into your Spring Boot applications via Spring's dependency injection.


Expand All @@ -16,14 +18,14 @@ Maven:
<dependency>
<groupId>org.web3j</groupId>
<artifactId>web3j-spring-boot-starter</artifactId>
<version>1.4.0</version>
<version>1.5.0</version>
</dependency>
```

Gradle:

```groovy
compile ('org.web3j:web3j-spring-boot-starter:1.4.0')
compile ('org.web3j:web3j-spring-boot-starter:1.5.0')
```

Now Spring can inject web3j instances for you where ever you need them:
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ apply plugin: 'idea'
apply plugin: 'io.codearte.nexus-staging'

group 'org.web3j'
version '1.4.0'
version '1.5.0'

sourceCompatibility = 1.8
targetCompatibility = 1.8
Expand All @@ -32,8 +32,8 @@ ext {
ossrhUsername = project.hasProperty('ossrhUsername') ? project.property('ossrhUsername') : ''
ossrhPassword = project.hasProperty('ossrhPassword') ? project.property('ossrhPassword') : ''

web3jVersion = '3.1.0'
springBootVersion = '1.5.8.RELEASE'
web3jVersion = '3.2.0'
springBootVersion = '1.5.9.RELEASE'

}

Expand Down
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Thu Dec 14 17:23:14 GMT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import org.springframework.boot.actuate.health.AbstractHealthIndicator;
import org.springframework.boot.actuate.health.Health;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.web3j.protocol.Web3j;

import java.util.ArrayList;
Expand All @@ -22,7 +21,6 @@ public Web3jHealthIndicator(Web3j web3j) {
this.web3j = web3j;
}


@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {
try {
Expand Down Expand Up @@ -64,6 +62,5 @@ protected void doHealthCheck(Health.Builder builder) throws Exception {
} catch (Exception ex) {
builder.down(ex);
}

}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.web3j.spring.autoconfigure;


import java.io.IOException;
import java.lang.reflect.Field;
import java.nio.file.Files;
Expand All @@ -22,21 +21,19 @@
import org.web3j.protocol.admin.Admin;
import org.web3j.protocol.core.JsonRpc2_0Web3j;
import org.web3j.protocol.http.HttpService;
import org.web3j.spring.actuate.Web3jHealthIndicator;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.startsWith;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;


public class Web3jAutoConfigurationTest {

private AnnotationConfigApplicationContext context;

@After
public void tearDown() throws IOException {
public void tearDown() {
if (this.context != null) {
this.context.close();
}
Expand Down Expand Up @@ -72,9 +69,8 @@ public void testWindowsIpcClient() throws IOException {
load(EmptyConfiguration.class, "web3j.client-address=" + path.toString());
}


@Test
public void testAdminClient() throws Exception {
public void testAdminClient() {
load(EmptyConfiguration.class, "web3j.client-address=", "web3j.admin-client=true");

this.context.getBean(Admin.class);
Expand All @@ -86,7 +82,7 @@ public void testAdminClient() throws Exception {
}

@Test
public void testNoAdminClient() throws Exception {
public void testNoAdminClient() {
load(EmptyConfiguration.class, "web3j.client-address=");

this.context.getBean(Web3j.class);
Expand All @@ -99,16 +95,14 @@ public void testNoAdminClient() throws Exception {


@Test
public void testHealthCheckIndicatorDown() throws Exception {
public void testHealthCheckIndicatorDown() {
load(EmptyConfiguration.class, "web3j.client-address=");

HealthIndicator web3jHealthIndicator = this.context.getBean(HealthIndicator.class);
Health health = web3jHealthIndicator.health();
assertThat(health.getStatus(), equalTo(Status.DOWN));
assertThat(health.getDetails().get("error"),
is("java.net.ConnectException: Failed to connect to localhost/127.0.0.1:8545"));


assertThat(health.getDetails().get("error").toString(),
startsWith("java.net.ConnectException: Failed to connect to localhost/"));
}

private void verifyHttpConnection(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.web3j.spring.autoconfigure;


import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
Expand Down

0 comments on commit ece20a3

Please sign in to comment.