You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by as...@apache.org on 2015/11/09 22:37:13 UTC
[22/50] [abbrv] incubator-geode git commit: GEODE-328: Create
gemfire-common project with Experimental annotation
GEODE-328: Create gemfire-common project with Experimental annotation
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/60d3f001
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/60d3f001
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/60d3f001
Branch: refs/heads/feature/GEODE-11
Commit: 60d3f0019228a98e2e182c7cabd309c52719d4f7
Parents: 919d636
Author: Kirk Lund <kl...@pivotal.io>
Authored: Tue Sep 15 13:54:50 2015 -0700
Committer: Kirk Lund <kl...@pivotal.io>
Committed: Tue Nov 3 11:32:54 2015 -0800
----------------------------------------------------------------------
gemfire-assembly/build.gradle | 6 +
gemfire-common/build.gradle | 3 +
.../gemfire/annotations/Experimental.java | 40 ++++
.../annotations/ExperimentalJUnitTest.java | 183 +++++++++++++++++++
.../ClassInExperimentalPackage.java | 11 ++
.../experimentalpackage/package-info.java | 11 ++
.../ClassInNonExperimentalPackage.java | 11 ++
.../nonexperimentalpackage/package-info.java | 8 +
gemfire-core/build.gradle | 1 +
gemfire-rebalancer/build.gradle | 1 +
gemfire-web/build.gradle | 1 +
settings.gradle | 1 +
12 files changed, 277 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/60d3f001/gemfire-assembly/build.gradle
----------------------------------------------------------------------
diff --git a/gemfire-assembly/build.gradle b/gemfire-assembly/build.gradle
index b351729..f94c92b 100755
--- a/gemfire-assembly/build.gradle
+++ b/gemfire-assembly/build.gradle
@@ -21,6 +21,7 @@ configurations {
dependencies {
provided project(':gemfire-core')
+ archives project(':gemfire-common')
archives project(':gemfire-json')
archives project(':gemfire-joptsimple')
archives project(':gemfire-jgroups')
@@ -161,6 +162,10 @@ distributions {
into ('lib') {
exclude 'annotation*.jar'
+
+ from project(":gemfire-common").configurations.runtime
+ from project(":gemfire-common").configurations.archives.allArtifacts.files
+
from project(":gemfire-jgroups").configurations.runtime
from project(":gemfire-jgroups").configurations.archives.allArtifacts.files
@@ -210,6 +215,7 @@ def springExtReleaseLocalRepo = [ id:'ext-release-local', name:'Spring Maven ext
def MavenRepos = [ springReleaseRepo, springSnapshotRepo, springLibsReleaseRepo, springExtReleaseLocalRepo ]
// Jars to be published via Maven
+def commonJar = [publicationName:'commonJar', project:project(":gemfire-common").name]
def coreJar = [publicationName:'coreJar', project:project(":gemfire-core").name]
def jgroupsJar = [publicationName:'jgroupsJar', project:project(":gemfire-jgroups").name]
def jsonJar = [publicationName:'jsonJar', project:project(":gemfire-json").name]
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/60d3f001/gemfire-common/build.gradle
----------------------------------------------------------------------
diff --git a/gemfire-common/build.gradle b/gemfire-common/build.gradle
new file mode 100755
index 0000000..aa8adcb
--- /dev/null
+++ b/gemfire-common/build.gradle
@@ -0,0 +1,3 @@
+dependencies {
+ provided project(path: ':gemfire-junit', configuration: 'testOutput')
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/60d3f001/gemfire-common/src/main/java/com/gemstone/gemfire/annotations/Experimental.java
----------------------------------------------------------------------
diff --git a/gemfire-common/src/main/java/com/gemstone/gemfire/annotations/Experimental.java b/gemfire-common/src/main/java/com/gemstone/gemfire/annotations/Experimental.java
new file mode 100755
index 0000000..0cded83
--- /dev/null
+++ b/gemfire-common/src/main/java/com/gemstone/gemfire/annotations/Experimental.java
@@ -0,0 +1,40 @@
+package com.gemstone.gemfire.annotations;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Signifies that a public API (public class, method or field) is subject to
+ * incompatible changes, or even removal, in a future release. An API bearing
+ * this annotation is exempt from any compatibility guarantees made by its
+ * containing library.
+ *
+ * <p>Note that the presence of this annotation implies nothing
+ * about the quality or performance of the API in question, only the fact that
+ * it is not "API-frozen."
+ *
+ * <p>It is generally safe for <i>applications</i> to depend on beta APIs, at
+ * the cost of some extra work during upgrades. However, it is generally
+ * inadvisable for <i>libraries</i> (which get included on users' class paths,
+ * outside the library developers' control) to do so.
+ *
+ * <p>Inspired by similar annotations in JGroups, Spark, DataflowJavaSDK.
+ */
+@Documented
+@Retention(RetentionPolicy.RUNTIME)
+@Target({
+ ElementType.ANNOTATION_TYPE,
+ ElementType.CONSTRUCTOR,
+ ElementType.FIELD,
+ ElementType.METHOD,
+ ElementType.PACKAGE,
+ ElementType.TYPE})
+public @interface Experimental {
+
+ /** Optional description */
+ String value() default "";
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/60d3f001/gemfire-common/src/test/java/com/gemstone/gemfire/annotations/ExperimentalJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-common/src/test/java/com/gemstone/gemfire/annotations/ExperimentalJUnitTest.java b/gemfire-common/src/test/java/com/gemstone/gemfire/annotations/ExperimentalJUnitTest.java
new file mode 100755
index 0000000..38fa57f
--- /dev/null
+++ b/gemfire-common/src/test/java/com/gemstone/gemfire/annotations/ExperimentalJUnitTest.java
@@ -0,0 +1,183 @@
+package com.gemstone.gemfire.annotations;
+
+import static org.assertj.core.api.Assertions.*;
+
+import java.lang.reflect.AnnotatedElement;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.annotations.experimentalpackage.ClassInExperimentalPackage;
+import com.gemstone.gemfire.experimental.nonexperimentalpackage.ClassInNonExperimentalPackage;
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
+/**
+ * Unit tests for the <tt>Experimental</tt> annotation. Verifies that the
+ * annotation can be applied to Interfaces, Classes, Public and Protected
+ * Fields, Enums, Enum Constants, Public and Protected Methods, Packages,
+ * and Constructors.
+ *
+ * @author Kirk Lund
+ */
+@Category(UnitTest.class)
+public class ExperimentalJUnitTest {
+
+ private static final String FIELD_NAME = "field";
+ private static final String METHOD_NAME = "method";
+
+ @Test
+ public void shouldIdentifyExperimentalInterface() throws Exception {
+ assertThat(isExperimental(RegularInterface.class)).isFalse();
+ assertThat(isExperimental(ExperimentalInterface.class)).isTrue();
+ }
+
+ @Test
+ public void shouldIdentifyExperimentalClass() throws Exception {
+ assertThat(isExperimental(RegularClass.class)).isFalse();
+ assertThat(isExperimental(ExperimentalClass.class)).isTrue();
+ }
+
+ @Test
+ public void shouldIdentifyExperimentalPublicField() throws Exception {
+ assertThat(isExperimental(RegularPublicField.class.getField(FIELD_NAME))).isFalse();
+ assertThat(isExperimental(ExperimentalPublicField.class.getField(FIELD_NAME))).isTrue();
+ }
+
+ @Test
+ public void shouldIdentifyExperimentalProtectedField() throws Exception {
+ assertThat(isExperimental(RegularProtectedField.class.getDeclaredField(FIELD_NAME))).isFalse();
+ assertThat(isExperimental(ExperimentalProtectedField.class.getDeclaredField(FIELD_NAME))).isTrue();
+ }
+
+ @Test
+ public void shouldIdentifyExperimentalEnum() throws Exception {
+ assertThat(isExperimental(RegularEnum.class)).isFalse();
+ assertThat(isExperimental(ExperimentalEnum.class)).isTrue();
+ }
+
+ @Test
+ public void shouldIdentifyExperimentalEnumConstant() throws Exception {
+ assertThat(isExperimental(RegularEnumInstance.class.getField(RegularEnumInstance.THREE.name()))).isFalse();
+ assertThat(isExperimental(ExperimentalEnumInstance.class.getField(ExperimentalEnumInstance.THREE.name()))).isTrue();
+ }
+
+ @Test
+ public void shouldIdentifyExperimentalPublicMethod() throws Exception {
+ assertThat(isExperimental(RegularPublicMethod.class.getMethod(METHOD_NAME))).isFalse();
+ assertThat(isExperimental(ExperimentalPublicMethod.class.getMethod(METHOD_NAME))).isTrue();
+ }
+
+ @Test
+ public void shouldIdentifyExperimentalProtectedMethod() throws Exception {
+ assertThat(isExperimental(RegularProtectedMethod.class.getDeclaredMethod(METHOD_NAME))).isFalse();
+ assertThat(isExperimental(ExperimentalProtectedMethod.class.getDeclaredMethod(METHOD_NAME))).isTrue();
+ }
+
+ @Test
+ public void shouldIdentifyExperimentalPackage() throws Exception {
+ assertThat(isExperimental(ClassInNonExperimentalPackage.class.getPackage())).isFalse();
+ assertThat(isExperimental(ClassInExperimentalPackage.class.getPackage())).isTrue();
+ }
+
+ @Test
+ public void shouldIdentifyExperimentalPublicConstructor() throws Exception {
+ assertThat(isExperimental(RegularPublicConstructor.class.getConstructor())).isFalse();
+ assertThat(isExperimental(ExperimentalPublicConstructor.class.getConstructor())).isTrue();
+ }
+
+ @Test
+ public void shouldIdentifyExperimentalProtectedConstructor() throws Exception {
+ assertThat(isExperimental(RegularProtectedConstructor.class.getConstructor())).isFalse();
+ assertThat(isExperimental(ExperimentalProtectedConstructor.class.getConstructor())).isTrue();
+ }
+
+ private static boolean isExperimental(final AnnotatedElement element) {
+ return element.getAnnotation(Experimental.class) != null;
+ }
+
+ public static interface RegularInterface {
+ }
+ @Experimental("This is an experimental interface")
+ public static interface ExperimentalInterface {
+ }
+
+ public static class RegularClass {
+ }
+ @Experimental("This is an experimental class")
+ public static class ExperimentalClass {
+ }
+
+ public static class RegularPublicField {
+ public final boolean field = false;
+ }
+ public static class ExperimentalPublicField {
+ @Experimental("This is an experimental public field")
+ public final boolean field = false;
+ }
+
+ public static class RegularProtectedField {
+ protected final boolean field = false;
+ }
+ public static class ExperimentalProtectedField {
+ @Experimental("This is an experimental protected field")
+ protected final boolean field = false;
+ }
+
+ public static enum RegularEnum {
+ ONE, TWO, THREE
+ }
+ @Experimental("This is an experimental enum")
+ public static enum ExperimentalEnum {
+ ONE, TWO, THREE
+ }
+
+ public static enum RegularEnumInstance {
+ ONE, TWO, THREE
+ }
+ public static enum ExperimentalEnumInstance {
+ ONE,
+ TWO,
+ @Experimental("This is an experimental enum constant")
+ THREE
+ }
+
+ public static class RegularPublicMethod {
+ public void method() {
+ }
+ }
+ public static class ExperimentalPublicMethod {
+ @Experimental("This is an experimental public method")
+ public void method() {
+ }
+ }
+
+ public static class RegularProtectedMethod {
+ public void method() {
+ }
+ }
+ public static class ExperimentalProtectedMethod {
+ @Experimental("This is an experimental protected method")
+ protected void method() {
+ }
+ }
+
+ public static class RegularPublicConstructor {
+ public RegularPublicConstructor() {
+ }
+ }
+ public static class ExperimentalPublicConstructor {
+ @Experimental("This is an experimental public constructor")
+ public ExperimentalPublicConstructor() {
+ }
+ }
+
+ public static class RegularProtectedConstructor {
+ public RegularProtectedConstructor() {
+ }
+ }
+ public static class ExperimentalProtectedConstructor {
+ @Experimental("This is an experimental protected constructor")
+ public ExperimentalProtectedConstructor() {
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/60d3f001/gemfire-common/src/test/java/com/gemstone/gemfire/annotations/experimentalpackage/ClassInExperimentalPackage.java
----------------------------------------------------------------------
diff --git a/gemfire-common/src/test/java/com/gemstone/gemfire/annotations/experimentalpackage/ClassInExperimentalPackage.java b/gemfire-common/src/test/java/com/gemstone/gemfire/annotations/experimentalpackage/ClassInExperimentalPackage.java
new file mode 100755
index 0000000..eaa1a97
--- /dev/null
+++ b/gemfire-common/src/test/java/com/gemstone/gemfire/annotations/experimentalpackage/ClassInExperimentalPackage.java
@@ -0,0 +1,11 @@
+package com.gemstone.gemfire.annotations.experimentalpackage;
+
+/**
+ * Used by <tt>ExperimentalJUnitTest</tt>. This is a class in an
+ * <tt>Experimental</tt> package.
+ *
+ * @author Kirk Lund
+ * @see com.gemstone.gemfire.annotations.ExperimentalJUnitTest
+ */
+public class ClassInExperimentalPackage {
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/60d3f001/gemfire-common/src/test/java/com/gemstone/gemfire/annotations/experimentalpackage/package-info.java
----------------------------------------------------------------------
diff --git a/gemfire-common/src/test/java/com/gemstone/gemfire/annotations/experimentalpackage/package-info.java b/gemfire-common/src/test/java/com/gemstone/gemfire/annotations/experimentalpackage/package-info.java
new file mode 100755
index 0000000..7edce2c
--- /dev/null
+++ b/gemfire-common/src/test/java/com/gemstone/gemfire/annotations/experimentalpackage/package-info.java
@@ -0,0 +1,11 @@
+/**
+ * Used by <tt>ExperimentalJUnitTest</tt>. This is an <tt>Experimental</tt>
+ * package.
+ *
+ * @author Kirk Lund
+ * @see com.gemstone.gemfire.annotations.ExperimentalJUnitTest
+ */
+@Experimental("This is an experimental package")
+package com.gemstone.gemfire.annotations.experimentalpackage;
+
+import com.gemstone.gemfire.annotations.Experimental;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/60d3f001/gemfire-common/src/test/java/com/gemstone/gemfire/experimental/nonexperimentalpackage/ClassInNonExperimentalPackage.java
----------------------------------------------------------------------
diff --git a/gemfire-common/src/test/java/com/gemstone/gemfire/experimental/nonexperimentalpackage/ClassInNonExperimentalPackage.java b/gemfire-common/src/test/java/com/gemstone/gemfire/experimental/nonexperimentalpackage/ClassInNonExperimentalPackage.java
new file mode 100755
index 0000000..711b533
--- /dev/null
+++ b/gemfire-common/src/test/java/com/gemstone/gemfire/experimental/nonexperimentalpackage/ClassInNonExperimentalPackage.java
@@ -0,0 +1,11 @@
+package com.gemstone.gemfire.experimental.nonexperimentalpackage;
+
+/**
+ * Used by <tt>ExperimentalJUnitTest</tt>. This is a class in an
+ * <tt>Experimental</tt> package.
+ *
+ * @author Kirk Lund
+ * @see com.gemstone.gemfire.annotations.ExperimentalJUnitTest
+ */
+public class ClassInNonExperimentalPackage {
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/60d3f001/gemfire-common/src/test/java/com/gemstone/gemfire/experimental/nonexperimentalpackage/package-info.java
----------------------------------------------------------------------
diff --git a/gemfire-common/src/test/java/com/gemstone/gemfire/experimental/nonexperimentalpackage/package-info.java b/gemfire-common/src/test/java/com/gemstone/gemfire/experimental/nonexperimentalpackage/package-info.java
new file mode 100755
index 0000000..958a9c5
--- /dev/null
+++ b/gemfire-common/src/test/java/com/gemstone/gemfire/experimental/nonexperimentalpackage/package-info.java
@@ -0,0 +1,8 @@
+/**
+ * Used by <tt>ExperimentalJUnitTest</tt>. This is a non-<tt>Experimental</tt>
+ * package.
+ *
+ * @author Kirk Lund
+ * @see com.gemstone.gemfire.annotations.ExperimentalJUnitTest
+ */
+package com.gemstone.gemfire.experimental.nonexperimentalpackage;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/60d3f001/gemfire-core/build.gradle
----------------------------------------------------------------------
diff --git a/gemfire-core/build.gradle b/gemfire-core/build.gradle
index 1c17474..47a84f3 100755
--- a/gemfire-core/build.gradle
+++ b/gemfire-core/build.gradle
@@ -70,6 +70,7 @@ dependencies {
testRuntime 'commons-io:commons-io:2.1'
testRuntime 'log4j:log4j:1.2.17'
+ compile project(':gemfire-common')
compile project(':gemfire-jgroups')
compile project(':gemfire-joptsimple')
compile project(':gemfire-json')
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/60d3f001/gemfire-rebalancer/build.gradle
----------------------------------------------------------------------
diff --git a/gemfire-rebalancer/build.gradle b/gemfire-rebalancer/build.gradle
index d87dd58..1226a7e 100644
--- a/gemfire-rebalancer/build.gradle
+++ b/gemfire-rebalancer/build.gradle
@@ -1,4 +1,5 @@
dependencies {
+ provided project(':gemfire-common')
provided project(':gemfire-core')
provided project(path: ':gemfire-junit', configuration: 'testOutput')
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/60d3f001/gemfire-web/build.gradle
----------------------------------------------------------------------
diff --git a/gemfire-web/build.gradle b/gemfire-web/build.gradle
index f0de25a..0c02b86 100755
--- a/gemfire-web/build.gradle
+++ b/gemfire-web/build.gradle
@@ -12,6 +12,7 @@ dependencies {
// have to use output since we exclude the dependent classes from jar :(
provided project(path: ':gemfire-core', configuration: 'classesOutput')
+ testRuntime project(':gemfire-common')
testRuntime project(':gemfire-core')
provided project(path: ':gemfire-junit', configuration: 'testOutput')
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/60d3f001/settings.gradle
----------------------------------------------------------------------
diff --git a/settings.gradle b/settings.gradle
index 4b2da7b..5cc0e30 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1,5 +1,6 @@
rootProject.name = 'gemfire'
+include 'gemfire-common'
include 'gemfire-jgroups'
include 'gemfire-joptsimple'
include 'gemfire-json'