From fbdb667858a4ebeea4dd9425144098b29856231f Mon Sep 17 00:00:00 2001 From: Michael Hunger Date: Thu, 6 Oct 2011 14:12:44 +0200 Subject: [PATCH] Added Documentation generating test to be used in the manual --- .../data/neo4j/annotation/Fetch.java | 15 +++++++++ .../test/DocumentingTestBase.java | 31 ++++++++++++++++++- .../test/DocumentingTestBaseTest.java | 15 +++++++++ .../snippets/SnippetNeo4jTemplateMethods.java | 15 +++++++++ 4 files changed, 75 insertions(+), 1 deletion(-) diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/annotation/Fetch.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/annotation/Fetch.java index c03f048dd..a128cc455 100644 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/annotation/Fetch.java +++ b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/annotation/Fetch.java @@ -1,3 +1,18 @@ +/** + * Copyright 2011 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.data.neo4j.annotation; import java.lang.annotation.ElementType; diff --git a/spring-data-neo4j/src/test/java/org/springframework/test/DocumentingTestBase.java b/spring-data-neo4j/src/test/java/org/springframework/test/DocumentingTestBase.java index c0a9a1dbe..4c77e1ba0 100644 --- a/spring-data-neo4j/src/test/java/org/springframework/test/DocumentingTestBase.java +++ b/spring-data-neo4j/src/test/java/org/springframework/test/DocumentingTestBase.java @@ -1,3 +1,18 @@ +/** + * Copyright 2011 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.test; @@ -85,11 +100,25 @@ public abstract class DocumentingTestBase { protected File getJavaFile() { final String javaFileName = getClass().getName().replaceAll("\\.", File.separator) + ".java"; - final File javaFile = new File(module() + "/src/test/java", javaFileName); + final File javaFile = new File(directoryPrefix() + "src/test/java", javaFileName); if (!javaFile.exists()) fail("Snippet File " + javaFile + " does not exist "); return javaFile; } + private String directoryPrefix() { + final boolean isAlreadyInDirectory = moduleWithParent().equals(currentDirectoryWithParent()); + return isAlreadyInDirectory ? "" : module()+"/"; + } + + private String moduleWithParent() { + return ("spring-data-neo4j/"+module()); + } + + private String currentDirectoryWithParent() { + final File currentDir = new File(".").getAbsoluteFile(); + return currentDir.getParentFile().getParentFile().getName() + "/" + currentDir.getParentFile().getName(); + } + protected String module() { return "spring-data-neo4j"; } diff --git a/spring-data-neo4j/src/test/java/org/springframework/test/DocumentingTestBaseTest.java b/spring-data-neo4j/src/test/java/org/springframework/test/DocumentingTestBaseTest.java index 3d7e4d3ba..1ccf55c29 100644 --- a/spring-data-neo4j/src/test/java/org/springframework/test/DocumentingTestBaseTest.java +++ b/spring-data-neo4j/src/test/java/org/springframework/test/DocumentingTestBaseTest.java @@ -1,3 +1,18 @@ +/** + * Copyright 2011 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.test; import org.junit.Test; diff --git a/spring-data-neo4j/src/test/java/org/springframework/test/snippets/SnippetNeo4jTemplateMethods.java b/spring-data-neo4j/src/test/java/org/springframework/test/snippets/SnippetNeo4jTemplateMethods.java index 46d6980a1..9a567b772 100644 --- a/spring-data-neo4j/src/test/java/org/springframework/test/snippets/SnippetNeo4jTemplateMethods.java +++ b/spring-data-neo4j/src/test/java/org/springframework/test/snippets/SnippetNeo4jTemplateMethods.java @@ -1,3 +1,18 @@ +/** + * Copyright 2011 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.test.snippets; import org.junit.Test;