From bba98464cc7eeaea08cebe1b136de3a2e35430d1 Mon Sep 17 00:00:00 2001 From: Yann Robert Date: Mon, 12 May 2014 12:43:04 +0200 Subject: [PATCH 1/3] Revert "anticipating FindBugs warnings : fixed field visibility + using immutable state contructor parameter" This reverts commit 0b11accbf5878a4c43119e650b1375e3bb3837b5. --- .../src/test/java/org/ektorp/http/BulkTest.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/org.ektorp/src/test/java/org/ektorp/http/BulkTest.java b/org.ektorp/src/test/java/org/ektorp/http/BulkTest.java index 10eb2881..94822f96 100644 --- a/org.ektorp/src/test/java/org/ektorp/http/BulkTest.java +++ b/org.ektorp/src/test/java/org/ektorp/http/BulkTest.java @@ -219,7 +219,7 @@ public void doUpdateInBulkWithManyElements(CouchDbConnector db) { for (int i = 0; i < elementsCount; i++) { String currentId = "TestDocumentBean-" + i; - TestDocumentBean bean = new TestDocumentBean(RandomStringUtils.randomAlphanumeric(32), RandomStringUtils.randomAlphanumeric(16), System.currentTimeMillis(), 0); + TestDocumentBean bean = new TestDocumentBean(RandomStringUtils.randomAlphanumeric(32), RandomStringUtils.randomAlphanumeric(16), new Date(), 0); String currentRevision = currentRevisionById.get(currentId); if (currentRevision != null) { bean.setId(currentId); @@ -314,16 +314,16 @@ public void doUpdateInBulkWithOneSmallInputStream(CouchDbConnector db) throws Ex public static class TestDocumentBean extends CouchDbDocument { - private String lastName; - private String firstName; - private Long dateOfBirth; - private int version; + public String lastName; + public String firstName; + public Date dateOfBirth; + public int version; public TestDocumentBean() { } - public TestDocumentBean(String lastName, String firstName, Long dateOfBirth, int version) { + public TestDocumentBean(String lastName, String firstName, Date dateOfBirth, int version) { this.lastName = lastName; this.firstName = firstName; this.dateOfBirth = dateOfBirth; From b308326d2f7c12927ee53ecf1e4297cf7332cc12 Mon Sep 17 00:00:00 2001 From: Yann Robert Date: Mon, 12 May 2014 14:51:36 +0200 Subject: [PATCH 2/3] TestDocumentBean should have accessor methods in order to be handled properly by Jackson and make findbugs happy at the same time + unmarking @Ignore but renamed the class to BulkIT so it is not run by surefire --- .../http/{BulkTest.java => BulkIT.java} | 75 +++++++++++++------ 1 file changed, 52 insertions(+), 23 deletions(-) rename org.ektorp/src/test/java/org/ektorp/http/{BulkTest.java => BulkIT.java} (88%) diff --git a/org.ektorp/src/test/java/org/ektorp/http/BulkTest.java b/org.ektorp/src/test/java/org/ektorp/http/BulkIT.java similarity index 88% rename from org.ektorp/src/test/java/org/ektorp/http/BulkTest.java rename to org.ektorp/src/test/java/org/ektorp/http/BulkIT.java index 94822f96..f0c9844d 100644 --- a/org.ektorp/src/test/java/org/ektorp/http/BulkTest.java +++ b/org.ektorp/src/test/java/org/ektorp/http/BulkIT.java @@ -11,10 +11,7 @@ import org.ektorp.impl.StdObjectMapperFactory; import org.ektorp.impl.StreamedCouchDbConnector; import org.ektorp.support.CouchDbDocument; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -50,10 +47,9 @@ at org.ektorp.http.StdHttpClient.executeRequest(StdHttpClient.java:96) ... 5 more */ -@Ignore -public class BulkTest { +public class BulkIT { - private final static Logger LOG = LoggerFactory.getLogger(StdCouchDbInstance.class); + private final static Logger LOG = LoggerFactory.getLogger(BulkIT.class); private HttpClient httpClient; @@ -67,7 +63,7 @@ public class BulkTest { private boolean createDatabaseIfNeeded = true; - private boolean deleteDatabaseIfNeeded = false; + private boolean deleteDatabaseIfNeeded = true; @Before public void setUp() { @@ -165,7 +161,7 @@ public void shouldUpdateInBulkWithManyElementsWithStreamedCouchDbConnector() thr } public void doUpdateInBulkWithOneElement(CouchDbConnector db) throws Exception { - final int iterationsCount = 100; + final int iterationsCount = 10; // create document "myid" try { @@ -192,8 +188,8 @@ public void doUpdateInBulkWithOneElement(CouchDbConnector db) throws Exception { public void doUpdateInBulkWithManyElements(CouchDbConnector db) { - final int iterationsCount = 20; - final int elementsCount = 200; + final int iterationsCount = 10; + final int elementsCount = 20; final List allDocIds = new ArrayList(); @@ -219,7 +215,7 @@ public void doUpdateInBulkWithManyElements(CouchDbConnector db) { for (int i = 0; i < elementsCount; i++) { String currentId = "TestDocumentBean-" + i; - TestDocumentBean bean = new TestDocumentBean(RandomStringUtils.randomAlphanumeric(32), RandomStringUtils.randomAlphanumeric(16), new Date(), 0); + TestDocumentBean bean = new TestDocumentBean(RandomStringUtils.randomAlphanumeric(32), RandomStringUtils.randomAlphanumeric(16), System.currentTimeMillis(), 0); String currentRevision = currentRevisionById.get(currentId); if (currentRevision != null) { bean.setId(currentId); @@ -240,11 +236,12 @@ public void doUpdateInBulkWithManyElements(CouchDbConnector db) { List docList = db.queryView(q, TestDocumentBean.class); for (TestDocumentBean b : docList) { + Assert.assertNotNull(b.firstName); + Assert.assertNotNull(b.getLastName()); + Assert.assertNotNull(b.dateOfBirth); // check version is as expected - if (b.version != i - 1) { - throw new IllegalStateException("Bean state is not as expected : " + b); - } - b.version = i; + Assert.assertEquals("Bean state is not as expected", i - 1, b.getVersion()); + b.setVersion(i); } long bulkOpStart = System.currentTimeMillis(); @@ -258,7 +255,7 @@ public void doUpdateInBulkWithManyElements(CouchDbConnector db) { List docList = db.queryView(q, TestDocumentBean.class); for (TestDocumentBean b : docList) { // check version is as expected - if (b.version != iterationsCount) { + if (b.getVersion() != iterationsCount) { throw new IllegalStateException("Bean state is not as expected : " + b); } } @@ -268,7 +265,7 @@ public void doUpdateInBulkWithManyElements(CouchDbConnector db) { } public void doUpdateInBulkWithOneSmallInputStream(CouchDbConnector db) throws Exception { - final int iterationsCount = 100; + final int iterationsCount = 10; // create or update the document, with initial "i" value of 0 final String id = "myid"; @@ -314,21 +311,53 @@ public void doUpdateInBulkWithOneSmallInputStream(CouchDbConnector db) throws Ex public static class TestDocumentBean extends CouchDbDocument { - public String lastName; - public String firstName; - public Date dateOfBirth; - public int version; + private String lastName; + private String firstName; + private Long dateOfBirth; + private int version = -1; public TestDocumentBean() { } - public TestDocumentBean(String lastName, String firstName, Date dateOfBirth, int version) { + public TestDocumentBean(String lastName, String firstName, Long dateOfBirth, int version) { this.lastName = lastName; this.firstName = firstName; this.dateOfBirth = dateOfBirth; this.version = version; } + + public int getVersion() { + return version; + } + + public void setVersion(int version) { + this.version = version; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public Long getDateOfBirth() { + return dateOfBirth; + } + + public void setDateOfBirth(Long dateOfBirth) { + this.dateOfBirth = dateOfBirth; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } } } From 013f44ba394cabd0bda494bce38438cf8d77be93 Mon Sep 17 00:00:00 2001 From: Yann Robert Date: Mon, 12 May 2014 15:15:52 +0200 Subject: [PATCH 3/3] introduced failsafe maven plugin in order to execute integration tests with mvn verify -DskipITs=true --- pom.xml | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/pom.xml b/pom.xml index 51655f8f..f174656c 100644 --- a/pom.xml +++ b/pom.xml @@ -53,6 +53,10 @@ false false + + true + jacoco + ${project.basedir}/../target/jacoco-it.exec @@ -149,6 +153,25 @@ findbugs-maven-plugin 2.5.3 + + org.apache.maven.plugins + maven-failsafe-plugin + 2.16 + + ${jacoco.agent.argLine} + + **/*IT.java + + + + + + integration-test + verify + + + + @@ -210,6 +233,23 @@ + + maven-failsafe-plugin + + ${skipITs} + + ${project.build.directory}/surefire-reports + ${jacoco.agent.argLine} + + + + + integration-test + verify + + + + @@ -293,5 +333,60 @@ 2.1 + + + + sonar + + + + false + + + + + + + org.jacoco + jacoco-maven-plugin + + jacoco.agent.argLine + + + org/ektorp/** + + ${project.build.directory}/jacoco-integration.exec + + ${project.build.directory}/jacoco-integration.exec + + + + + agent + + prepare-agent + + + + + report + site + + report + + + + + + + +