Skip to content

Commit

Permalink
add versioneye & coveralls;
Browse files Browse the repository at this point in the history
fix dependency problems of modules (examples still need work)

Signed-off-by: Sebastian Hoß <mail@shoss.de>
  • Loading branch information
sebhoss committed Dec 9, 2014
1 parent c91e644 commit b142c7f
Show file tree
Hide file tree
Showing 90 changed files with 1,343 additions and 84 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
@@ -1,3 +1,7 @@
language: java
jdk:
- oraclejdk8
- oraclejdk8
env:
global:
- secure: Opjnt4LKgJcC+OqMV6s+aok6ocSS3iREtxTH67HdH+52v1CQxRiBmKx4omxoPwYS5pw2/z87yzYNz4bMMHehnU97aNpWGnXXeMYmbKah5pl5QHJ0nWDyvrluNIAsAkt5IyPUeIVfu+RcvZUNNkMPKFXg8pzD0bvUed05oCzVTCU=
- secure: hWHwRA7x5SiqWNh0BIUVMkMmTbWiEDqssI6075YPiAWEwwa46EZTk3+57JQ94nUKbMvKyXHMAviOTiW+TvOWRnfK3a+92ksufe/l+U0N+OT8/6x6KGL8q/y3ULsu8wrl7VigRT2lW46EiT6h+K7iR9dRNM7At6Dws/wMjzraRYk=
2 changes: 1 addition & 1 deletion README.textile
@@ -1,4 +1,4 @@
h1. annotated-contracts "!https://secure.travis-ci.org/sebhoss/annotated-contracts.png!":http://travis-ci.org/sebhoss/annotated-contracts "!https://www.ohloh.net/p/annotated-contracts/widgets/project_thin_badge.gif!":https://www.ohloh.net/p/annotated-contracts/
h1. annotated-contracts "!https://www.ohloh.net/p/annotated-contracts/widgets/project_thin_badge.gif!":https://www.ohloh.net/p/annotated-contracts/ "!https://secure.travis-ci.org/sebhoss/annotated-contracts.png!":http://travis-ci.org/sebhoss/annotated-contracts !https://coveralls.io/repos/sebhoss/annotated-contracts/badge.png(Coverage Status)!:https://coveralls.io/r/sebhoss/annotated-contracts

p. "Design by Contract":http://en.wikipedia.org/wiki/Design_by_contract based on annotations. It allows easy usage of contracts without any need for extra JVM parameters, JVM agents, special classloaders or compilers. Instead it leverages "dependency injection":http://en.wikipedia.org/wiki/Dependency_injection to capture method calls which are annotation with a contract. The project is highly flexible and can be extended to support new contract annotations and other contract clause definitions (see below).

Expand Down
Expand Up @@ -12,16 +12,18 @@
import javax.enterprise.inject.Produces;

import com.github.sebhoss.nullanalysis.Nullsafe;
import com.github.sebhoss.warnings.CompilerWarnings;
import com.google.common.collect.ImmutableSet;
import com.google.common.util.concurrent.Service;

// TODO: We only need this for pax-exam
class PaxExamConfiguration {

@Produces
@Default
Set<Service> services() {
return Nullsafe.nullsafe(ImmutableSet.<Service> of());
}
@Produces
@Default
@SuppressWarnings(CompilerWarnings.STATIC_METHOD)
Set<Service> services() {
return Nullsafe.nullsafe(ImmutableSet.<Service> of());
}

}
Expand Up @@ -29,6 +29,6 @@ public class CdiJavaScriptInsuranceCompanyTest extends InsuranceCompanyTest {
*/
@Before
public void bind() {
insurance = injectedCompany;
setInsuranceCompany(injectedCompany);
}
}
Expand Up @@ -12,6 +12,7 @@
import javax.enterprise.inject.Produces;

import com.github.sebhoss.nullanalysis.Nullsafe;
import com.github.sebhoss.warnings.CompilerWarnings;
import com.google.common.collect.ImmutableSet;
import com.google.common.util.concurrent.Service;

Expand All @@ -20,6 +21,7 @@ class PaxExamConfiguration {

@Produces
@Default
@SuppressWarnings(CompilerWarnings.STATIC_METHOD)
Set<Service> services() {
return Nullsafe.nullsafe(ImmutableSet.<Service> of());
}
Expand Down
Expand Up @@ -29,7 +29,7 @@ public class CdiJexlInsuranceCompanyTest extends InsuranceCompanyTest {
*/
@Before
public void bind() {
insurance = injectedCompany;
setInsuranceCompany(injectedCompany);
}

}
Expand Up @@ -12,6 +12,7 @@
import javax.enterprise.inject.Produces;

import com.github.sebhoss.nullanalysis.Nullsafe;
import com.github.sebhoss.warnings.CompilerWarnings;
import com.google.common.collect.ImmutableSet;
import com.google.common.util.concurrent.Service;

Expand All @@ -20,6 +21,7 @@ class PaxExamConfiguration {

@Produces
@Default
@SuppressWarnings(CompilerWarnings.STATIC_METHOD)
Set<Service> services() {
return Nullsafe.nullsafe(ImmutableSet.<Service> of());
}
Expand Down
Expand Up @@ -29,7 +29,7 @@ public class CdiJuelInsuranceCompanyTest extends InsuranceCompanyTest {
*/
@Before
public void bind() {
insurance = injectedCompany;
setInsuranceCompany(injectedCompany);
}

}
Expand Up @@ -17,11 +17,11 @@
import com.google.common.util.concurrent.Service;

// TODO: We only need this for pax-exam
@SuppressWarnings(CompilerWarnings.STATIC_METHOD)
class PaxExamConfiguration {

@Produces
@Default
@SuppressWarnings(CompilerWarnings.STATIC_METHOD)
Set<Service> services() {
return Nullsafe.nullsafe(ImmutableSet.<Service> of());
}
Expand Down
Expand Up @@ -29,7 +29,7 @@ public class CdiMvelInsuranceCompanyTest extends InsuranceCompanyTest {
*/
@Before
public void bind() {
insurance = injectedCompany;
setInsuranceCompany(injectedCompany);
}

}
Expand Up @@ -29,7 +29,7 @@ public class CdiOgnlInsuranceCompanyTest extends InsuranceCompanyTest {
*/
@Before
public void bind() {
insurance = injectedCompany;
setInsuranceCompany(injectedCompany);
}

}
Expand Up @@ -29,7 +29,7 @@ public class CdiSpElInsuranceCompanyTest extends InsuranceCompanyTest {
*/
@Before
public void bind() {
insurance = injectedCompany;
setInsuranceCompany(injectedCompany);
}

}
Expand Up @@ -29,7 +29,7 @@ public class CdiUelInsuranceCompanyTest extends InsuranceCompanyTest {
*/
@Before
public void bind() {
insurance = injectedCompany;
setInsuranceCompany(injectedCompany);
}

}
22 changes: 22 additions & 0 deletions contract-examples/contract-example-model/pom.xml
Expand Up @@ -45,4 +45,26 @@
<artifactId>junit</artifactId>
</dependency>
</dependencies>

<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- BUILD -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<configuration>
<!--
Ignore common annotations because @SuppressWarnings is not retained
in byte code. There the plugin detects a false positive.
-->
<usedDependencies>
<usedDependency>com.github.sebhoss:suppress-warnings</usedDependency>
</usedDependencies>
</configuration>
</plugin>
</plugins>
</build>
</project>
Expand Up @@ -6,14 +6,14 @@
*/
package com.github.sebhoss.contract.example;

import org.eclipse.jdt.annotation.Nullable;
import com.github.sebhoss.nullanalysis.Nullsafe;
import com.github.sebhoss.warnings.CompilerWarnings;

import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import com.github.sebhoss.warnings.CompilerWarnings;

/**
* Test cases for the {@link InsuranceCompany}.
*/
Expand All @@ -22,17 +22,24 @@ public abstract class InsuranceCompanyTest {

/** Catches expected exceptions */
@Rule
public ExpectedException thrown = ExpectedException.none();
public ExpectedException thrown = ExpectedException.none();

@Nullable
protected InsuranceCompany insurance;
private InsuranceCompany insurance;

protected InsuranceCompany getInsuranceCompany() {
return insurance;
}

protected void setInsuranceCompany(final InsuranceCompany insurance) {
this.insurance = insurance;
}

/**
* Ensures that the insurance company can calculate payouts based on a positive damage input.
*/
@Test
public void shouldAcceptPositiveDamages() {
final double result = insurance.calculateCover(10);
final double result = Nullsafe.nullsafe(getInsuranceCompany()).calculateCover(10);

Assert.assertEquals(5.0, result, 0d);
}
Expand All @@ -45,7 +52,7 @@ public void shouldNotAcceptNegativeDamages() {
thrown.expect(IllegalStateException.class);
thrown.expectMessage("Reported damage must be positive!");

insurance.calculateCover(-10);
Nullsafe.nullsafe(getInsuranceCompany()).calculateCover(-10);
}

/**
Expand All @@ -56,7 +63,7 @@ public void shouldNotAcceptHighDamages() {
thrown.expect(IllegalStateException.class);
thrown.expectMessage("We won't pay that!");

insurance.calculateCover(5001);
Nullsafe.nullsafe(getInsuranceCompany()).calculateCover(5001);
}

/**
Expand All @@ -67,7 +74,7 @@ public void shouldNotPerformHighPayout() {
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("We can't pay that much!");

insurance.calculateCover(5000);
Nullsafe.nullsafe(getInsuranceCompany()).calculateCover(5000);
}

}
Expand Up @@ -14,15 +14,15 @@
/**
* Test cases for a JavaScript {@link InsuranceCompany}.
*/
public class JavaScriptInsuranceCompanyTest extends InsuranceCompanyTest {
public class GuiceJavaScriptInsuranceCompanyTest extends InsuranceCompanyTest {

/**
* Creates a new insurance company for each test.
*/
@Before
public void createCompany() {
final Injector injector = Guice.createInjector(new GuiceJavaScriptModule());
insurance = injector.getInstance(InsuranceCompany.class);
setInsuranceCompany(injector.getInstance(InsuranceCompany.class));
}

}
Expand Up @@ -14,15 +14,15 @@
/**
* Test cases for a JEXL {@link InsuranceCompany}.
*/
public class JexlInsuranceCompanyTest extends InsuranceCompanyTest {
public class GuiceJexlInsuranceCompanyTest extends InsuranceCompanyTest {

/**
* Creates a new insurance company for each test.
*/
@Before
public void createCompany() {
final Injector injector = Guice.createInjector(new GuiceJexlModule());
insurance = injector.getInstance(InsuranceCompany.class);
setInsuranceCompany(injector.getInstance(InsuranceCompany.class));
}

}
Expand Up @@ -14,15 +14,15 @@
/**
* Test cases for a JUEL {@link InsuranceCompany}.
*/
public class JuelInsuranceCompanyTest extends InsuranceCompanyTest {
public class GuiceJuelInsuranceCompanyTest extends InsuranceCompanyTest {

/**
* Creates a new insurance company for each test.
*/
@Before
public void createCompany() {
final Injector injector = Guice.createInjector(new GuiceJuelModule());
insurance = injector.getInstance(InsuranceCompany.class);
setInsuranceCompany(injector.getInstance(InsuranceCompany.class));
}

}
Expand Up @@ -14,15 +14,15 @@
/**
* Test cases for a MVEL {@link InsuranceCompany}.
*/
public class MvelInsuranceCompanyTest extends InsuranceCompanyTest {
public class GuiceMvelInsuranceCompanyTest extends InsuranceCompanyTest {

/**
* Creates a new insurance company for each test.
*/
@Before
public void createCompany() {
final Injector injector = Guice.createInjector(new GuiceMvelModule());
insurance = injector.getInstance(InsuranceCompany.class);
setInsuranceCompany(injector.getInstance(InsuranceCompany.class));
}

}
Expand Up @@ -14,15 +14,15 @@
/**
* Test cases for a OGNL {@link InsuranceCompany}.
*/
public class OgnlInsuranceCompanyTest extends InsuranceCompanyTest {
public class GuiceOgnlInsuranceCompanyTest extends InsuranceCompanyTest {

/**
* Creates a new insurance company for each test.
*/
@Before
public void createCompany() {
final Injector injector = Guice.createInjector(new GuiceOgnlModule());
insurance = injector.getInstance(InsuranceCompany.class);
setInsuranceCompany(injector.getInstance(InsuranceCompany.class));
}

}
Expand Up @@ -22,7 +22,7 @@ public class GuiceSpELInsuranceCompanyTest extends InsuranceCompanyTest {
@Before
public void createCompany() {
final Injector injector = Guice.createInjector(new GuiceSpELModule());
insurance = injector.getInstance(InsuranceCompany.class);
setInsuranceCompany(injector.getInstance(InsuranceCompany.class));
}

}
Expand Up @@ -22,7 +22,7 @@ public class GuiceUelInsuranceCompanyTest extends InsuranceCompanyTest {
@Before
public void createCompany() {
final Injector injector = Guice.createInjector(new GuiceUelModule());
insurance = injector.getInstance(InsuranceCompany.class);
setInsuranceCompany(injector.getInstance(InsuranceCompany.class));
}

}
Expand Up @@ -6,6 +6,10 @@
*/
package com.github.sebhoss.contract.example;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

import com.github.sebhoss.contract.configuration.DefaultJavaScriptConfiguration;
import com.github.sebhoss.warnings.CompilerWarnings;

Expand Down
Expand Up @@ -7,6 +7,8 @@
package com.github.sebhoss.contract.example;

import org.junit.Before;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import com.github.sebhoss.warnings.CompilerWarnings;

Expand All @@ -22,7 +24,7 @@ public class SpringJavaScriptInsuranceCompanyTest extends InsuranceCompanyTest {
@SuppressWarnings(CompilerWarnings.RESOURCE)
public void createCompany() {
final ApplicationContext context = new AnnotationConfigApplicationContext(SpringJavaScriptConfiguration.class);
insurance = context.getBean(InsuranceCompany.class);
setInsuranceCompany(context.getBean(InsuranceCompany.class));
}

}
Expand Up @@ -6,6 +6,10 @@
*/
package com.github.sebhoss.contract.example;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

import com.github.sebhoss.contract.configuration.DefaultJEXLConfiguration;
import com.github.sebhoss.warnings.CompilerWarnings;

Expand Down

0 comments on commit b142c7f

Please sign in to comment.