Move to Commons Base
authorMathieu Baudier <mbaudier@argeo.org>
Tue, 17 Jul 2012 12:27:34 +0000 (12:27 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Tue, 17 Jul 2012 12:27:34 +0000 (12:27 +0000)
git-svn-id: https://svn.argeo.org/commons/trunk@5472 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

12 files changed:
base/runtime/org.argeo.support.junit/.classpath [new file with mode: 0644]
base/runtime/org.argeo.support.junit/.project [new file with mode: 0644]
base/runtime/org.argeo.support.junit/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
base/runtime/org.argeo.support.junit/.settings/org.maven.ide.eclipse.prefs [new file with mode: 0644]
base/runtime/org.argeo.support.junit/pom.xml [new file with mode: 0644]
base/runtime/org.argeo.support.junit/src/main/java/org/argeo/support/junit/AbstractSpringTestCase.java [new file with mode: 0644]
basic/runtime/org.argeo.support.junit/.classpath [deleted file]
basic/runtime/org.argeo.support.junit/.project [deleted file]
basic/runtime/org.argeo.support.junit/.settings/org.eclipse.jdt.core.prefs [deleted file]
basic/runtime/org.argeo.support.junit/.settings/org.maven.ide.eclipse.prefs [deleted file]
basic/runtime/org.argeo.support.junit/pom.xml [deleted file]
basic/runtime/org.argeo.support.junit/src/main/java/org/argeo/support/junit/AbstractSpringTestCase.java [deleted file]

diff --git a/base/runtime/org.argeo.support.junit/.classpath b/base/runtime/org.argeo.support.junit/.classpath
new file mode 100644 (file)
index 0000000..3bf3ade
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="src" output="target/classes" path="src/main/java"/>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>>>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/base/runtime/org.argeo.support.junit/.project b/base/runtime/org.argeo.support.junit/.project
new file mode 100644 (file)
index 0000000..cc37598
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.argeo.support.junit</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/base/runtime/org.argeo.support.junit/.settings/org.eclipse.jdt.core.prefs b/base/runtime/org.argeo.support.junit/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..383a4ec
--- /dev/null
@@ -0,0 +1,5 @@
+#Tue Oct 13 10:02:09 CEST 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/base/runtime/org.argeo.support.junit/.settings/org.maven.ide.eclipse.prefs b/base/runtime/org.argeo.support.junit/.settings/org.maven.ide.eclipse.prefs
new file mode 100644 (file)
index 0000000..721e27e
--- /dev/null
@@ -0,0 +1,9 @@
+#Tue Oct 13 10:01:59 CEST 2009
+activeProfiles=
+eclipse.preferences.version=1
+fullBuildGoals=process-test-resources
+includeModules=false
+resolveWorkspaceProjects=true
+resourceFilterGoals=process-resources resources\:testResources
+skipCompilerPlugin=true
+version=1
diff --git a/base/runtime/org.argeo.support.junit/pom.xml b/base/runtime/org.argeo.support.junit/pom.xml
new file mode 100644 (file)
index 0000000..28e8647
--- /dev/null
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.argeo.commons.basic</groupId>
+               <artifactId>runtime</artifactId>
+               <version>1.1.4-SNAPSHOT</version>
+               <relativePath>..</relativePath>
+       </parent>
+       <artifactId>org.argeo.support.junit</artifactId>
+       <name>Commons Support JUnit</name>
+       <build>
+               <plugins>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-compiler-plugin</artifactId>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-source-plugin</artifactId>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-jar-plugin</artifactId>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.apache.felix</groupId>
+                               <artifactId>maven-bundle-plugin</artifactId>
+
+                               <configuration>
+                                       <instructions>
+                                               <Export-Package>
+                                                       org.argeo.support.junit.*
+                                               </Export-Package>
+                                               <Import-Package>org.springframework.core.io,*</Import-Package>
+                                       </instructions>
+                               </configuration>
+                       </plugin>
+               </plugins>
+       </build>
+       <dependencies>
+               <dependency>
+                       <groupId>org.argeo.tp</groupId>
+                       <artifactId>junit</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp</groupId>
+                       <artifactId>org.springframework.core</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp</groupId>
+                       <artifactId>org.springframework.context</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp</groupId>
+                       <artifactId>org.springframework.beans</artifactId>
+               </dependency>
+
+               <!-- Logging -->
+               <dependency>
+                       <groupId>org.argeo.tp</groupId>
+                       <artifactId>slf4j.org.apache.commons.logging</artifactId>
+               </dependency>
+       </dependencies>
+</project>
\ No newline at end of file
diff --git a/base/runtime/org.argeo.support.junit/src/main/java/org/argeo/support/junit/AbstractSpringTestCase.java b/base/runtime/org.argeo.support.junit/src/main/java/org/argeo/support/junit/AbstractSpringTestCase.java
new file mode 100644 (file)
index 0000000..3ceff66
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2007-2012 Mathieu Baudier
+ *
+ * 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.argeo.support.junit;
+
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.BeanFactoryUtils;
+import org.springframework.beans.factory.ListableBeanFactory;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+
+/** Helper for tests using a Spring application context. */
+public abstract class AbstractSpringTestCase extends TestCase {
+       protected final Log log = LogFactory.getLog(getClass());
+       private ConfigurableApplicationContext context;
+
+       /**
+        * Gets (and creates if necessary) the application context to use. Default
+        * implementation uses a class path xml application context and calls
+        * {@link #getApplicationContextLocation()}.
+        */
+       protected ConfigurableApplicationContext getContext() {
+               if (context == null) {
+                       context = new ClassPathXmlApplicationContext(
+                                       getApplicationContextLocation());
+                       if (getIsStartContext())
+                               context.start();
+               }
+               return context;
+       }
+
+       /** Whether the context should be started after being created. */
+       protected Boolean getIsStartContext() {
+               return false;
+       }
+
+       /** Returns a bean from the underlying context */
+       @SuppressWarnings(value = { "unchecked" })
+       protected <T> T getBean(String beanId) {
+               return (T) getContext().getBean(beanId);
+       }
+
+       protected <T> T getBean(Class<? extends T> clss) {
+               T bean = loadSingleFromContext(getContext(), clss);
+               if (bean == null) {
+                       throw new RuntimeException("Cannot retrieve a unique bean of type "
+                                       + clss);
+               } else {
+                       return bean;
+               }
+       }
+
+       /**
+        * The location of the application to load. The default implementation
+        * returns <i>applicationContext.xml</i> found in the same package as the
+        * test.
+        */
+       protected String getApplicationContextLocation() {
+               return inPackage("applicationContext.xml");
+       }
+
+       /**
+        * Prefixes the package of the class after converting the '.' to '/' in
+        * order to have a resource path.
+        */
+       protected String inPackage(String suffix) {
+               String prefix = getClass().getPackage().getName().replace('.', '/');
+               return prefix + '/' + suffix;
+       }
+
+       @SuppressWarnings(value = { "unchecked" })
+       protected <T> T loadSingleFromContext(ListableBeanFactory context,
+                       Class<T> clss) {
+               Map<String, T> beans = BeanFactoryUtils.beansOfTypeIncludingAncestors(
+                               context, clss, false, false);
+               if (beans.size() == 1) {
+                       return beans.values().iterator().next();
+               } else if (beans.size() > 1) {
+                       if (log.isDebugEnabled()) {
+                               log
+                                               .debug(("Found more that one bean for type " + clss
+                                                               + ": " + beans.keySet()));
+                       }
+                       return null;
+               } else {
+                       return null;
+               }
+       }
+
+}
diff --git a/basic/runtime/org.argeo.support.junit/.classpath b/basic/runtime/org.argeo.support.junit/.classpath
deleted file mode 100644 (file)
index 3bf3ade..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-       <classpathentry kind="src" output="target/classes" path="src/main/java"/>
-       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>>>
-       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-       <classpathentry kind="output" path="target/classes"/>
-</classpath>
diff --git a/basic/runtime/org.argeo.support.junit/.project b/basic/runtime/org.argeo.support.junit/.project
deleted file mode 100644 (file)
index cc37598..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-       <name>org.argeo.support.junit</name>
-       <comment></comment>
-       <projects>
-       </projects>
-       <buildSpec>
-               <buildCommand>
-                       <name>org.eclipse.jdt.core.javabuilder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-               <buildCommand>
-                       <name>org.eclipse.pde.ManifestBuilder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-               <buildCommand>
-                       <name>org.eclipse.pde.SchemaBuilder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-       </buildSpec>
-       <natures>
-               <nature>org.eclipse.pde.PluginNature</nature>
-               <nature>org.eclipse.jdt.core.javanature</nature>
-       </natures>
-</projectDescription>
diff --git a/basic/runtime/org.argeo.support.junit/.settings/org.eclipse.jdt.core.prefs b/basic/runtime/org.argeo.support.junit/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644 (file)
index 383a4ec..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#Tue Oct 13 10:02:09 CEST 2009
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.source=1.5
diff --git a/basic/runtime/org.argeo.support.junit/.settings/org.maven.ide.eclipse.prefs b/basic/runtime/org.argeo.support.junit/.settings/org.maven.ide.eclipse.prefs
deleted file mode 100644 (file)
index 721e27e..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#Tue Oct 13 10:01:59 CEST 2009
-activeProfiles=
-eclipse.preferences.version=1
-fullBuildGoals=process-test-resources
-includeModules=false
-resolveWorkspaceProjects=true
-resourceFilterGoals=process-resources resources\:testResources
-skipCompilerPlugin=true
-version=1
diff --git a/basic/runtime/org.argeo.support.junit/pom.xml b/basic/runtime/org.argeo.support.junit/pom.xml
deleted file mode 100644 (file)
index 28e8647..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.argeo.commons.basic</groupId>
-               <artifactId>runtime</artifactId>
-               <version>1.1.4-SNAPSHOT</version>
-               <relativePath>..</relativePath>
-       </parent>
-       <artifactId>org.argeo.support.junit</artifactId>
-       <name>Commons Support JUnit</name>
-       <build>
-               <plugins>
-                       <plugin>
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-compiler-plugin</artifactId>
-                       </plugin>
-                       <plugin>
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-source-plugin</artifactId>
-                       </plugin>
-                       <plugin>
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-jar-plugin</artifactId>
-                       </plugin>
-                       <plugin>
-                               <groupId>org.apache.felix</groupId>
-                               <artifactId>maven-bundle-plugin</artifactId>
-
-                               <configuration>
-                                       <instructions>
-                                               <Export-Package>
-                                                       org.argeo.support.junit.*
-                                               </Export-Package>
-                                               <Import-Package>org.springframework.core.io,*</Import-Package>
-                                       </instructions>
-                               </configuration>
-                       </plugin>
-               </plugins>
-       </build>
-       <dependencies>
-               <dependency>
-                       <groupId>org.argeo.tp</groupId>
-                       <artifactId>junit</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp</groupId>
-                       <artifactId>org.springframework.core</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp</groupId>
-                       <artifactId>org.springframework.context</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp</groupId>
-                       <artifactId>org.springframework.beans</artifactId>
-               </dependency>
-
-               <!-- Logging -->
-               <dependency>
-                       <groupId>org.argeo.tp</groupId>
-                       <artifactId>slf4j.org.apache.commons.logging</artifactId>
-               </dependency>
-       </dependencies>
-</project>
\ No newline at end of file
diff --git a/basic/runtime/org.argeo.support.junit/src/main/java/org/argeo/support/junit/AbstractSpringTestCase.java b/basic/runtime/org.argeo.support.junit/src/main/java/org/argeo/support/junit/AbstractSpringTestCase.java
deleted file mode 100644 (file)
index 3ceff66..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Mathieu Baudier
- *
- * 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.argeo.support.junit;
-
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.beans.factory.BeanFactoryUtils;
-import org.springframework.beans.factory.ListableBeanFactory;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-
-/** Helper for tests using a Spring application context. */
-public abstract class AbstractSpringTestCase extends TestCase {
-       protected final Log log = LogFactory.getLog(getClass());
-       private ConfigurableApplicationContext context;
-
-       /**
-        * Gets (and creates if necessary) the application context to use. Default
-        * implementation uses a class path xml application context and calls
-        * {@link #getApplicationContextLocation()}.
-        */
-       protected ConfigurableApplicationContext getContext() {
-               if (context == null) {
-                       context = new ClassPathXmlApplicationContext(
-                                       getApplicationContextLocation());
-                       if (getIsStartContext())
-                               context.start();
-               }
-               return context;
-       }
-
-       /** Whether the context should be started after being created. */
-       protected Boolean getIsStartContext() {
-               return false;
-       }
-
-       /** Returns a bean from the underlying context */
-       @SuppressWarnings(value = { "unchecked" })
-       protected <T> T getBean(String beanId) {
-               return (T) getContext().getBean(beanId);
-       }
-
-       protected <T> T getBean(Class<? extends T> clss) {
-               T bean = loadSingleFromContext(getContext(), clss);
-               if (bean == null) {
-                       throw new RuntimeException("Cannot retrieve a unique bean of type "
-                                       + clss);
-               } else {
-                       return bean;
-               }
-       }
-
-       /**
-        * The location of the application to load. The default implementation
-        * returns <i>applicationContext.xml</i> found in the same package as the
-        * test.
-        */
-       protected String getApplicationContextLocation() {
-               return inPackage("applicationContext.xml");
-       }
-
-       /**
-        * Prefixes the package of the class after converting the '.' to '/' in
-        * order to have a resource path.
-        */
-       protected String inPackage(String suffix) {
-               String prefix = getClass().getPackage().getName().replace('.', '/');
-               return prefix + '/' + suffix;
-       }
-
-       @SuppressWarnings(value = { "unchecked" })
-       protected <T> T loadSingleFromContext(ListableBeanFactory context,
-                       Class<T> clss) {
-               Map<String, T> beans = BeanFactoryUtils.beansOfTypeIncludingAncestors(
-                               context, clss, false, false);
-               if (beans.size() == 1) {
-                       return beans.values().iterator().next();
-               } else if (beans.size() > 1) {
-                       if (log.isDebugEnabled()) {
-                               log
-                                               .debug(("Found more that one bean for type " + clss
-                                                               + ": " + beans.keySet()));
-                       }
-                       return null;
-               } else {
-                       return null;
-               }
-       }
-
-}