Refactor unit tests
authorMathieu Baudier <mbaudier@argeo.org>
Fri, 14 Aug 2015 16:04:34 +0000 (16:04 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Fri, 14 Aug 2015 16:04:34 +0000 (16:04 +0000)
git-svn-id: https://svn.argeo.org/commons/trunk@8321 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

12 files changed:
org.argeo.server.jcr/ext/test/org/argeo/jcr/AbstractInternalJackrabbitTestCase.java [deleted file]
org.argeo.server.jcr/ext/test/org/argeo/jcr/CollectionsObject.java [deleted file]
org.argeo.server.jcr/ext/test/org/argeo/jcr/MapperTest.java [deleted file]
org.argeo.server.jcr/ext/test/org/argeo/jcr/OtherObject.java [deleted file]
org.argeo.server.jcr/ext/test/org/argeo/jcr/SimpleObject.java [deleted file]
org.argeo.server.jcr/ext/test/org/argeo/jcr/spring/CollectionsObject.java [new file with mode: 0644]
org.argeo.server.jcr/ext/test/org/argeo/jcr/spring/MapperTest.java [new file with mode: 0644]
org.argeo.server.jcr/ext/test/org/argeo/jcr/spring/OtherObject.java [new file with mode: 0644]
org.argeo.server.jcr/ext/test/org/argeo/jcr/spring/SimpleObject.java [new file with mode: 0644]
org.argeo.server.jcr/ext/test/org/argeo/jcr/tabular/JcrTabularTest.java
org.argeo.server.jcr/ext/test/org/argeo/server/jcr/JcrResourceAdapterTest.java
org.argeo.server.jcr/src/org/argeo/jackrabbit/unit/AbstractJackrabbitTestCase.java [new file with mode: 0644]

diff --git a/org.argeo.server.jcr/ext/test/org/argeo/jcr/AbstractInternalJackrabbitTestCase.java b/org.argeo.server.jcr/ext/test/org/argeo/jcr/AbstractInternalJackrabbitTestCase.java
deleted file mode 100644 (file)
index 23281d0..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * 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.jcr;
-
-import java.io.File;
-
-import javax.jcr.Repository;
-
-import org.apache.jackrabbit.core.TransientRepository;
-import org.argeo.jcr.unit.AbstractJcrTestCase;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.core.io.Resource;
-
-/** Factorizes configuration of an in memory transient repository */
-public abstract class AbstractInternalJackrabbitTestCase extends
-               AbstractJcrTestCase {
-       protected File getRepositoryFile() throws Exception {
-               Resource res = new ClassPathResource(
-                               "org/argeo/server/jcr/repository-memory.xml");
-               return res.getFile();
-       }
-
-       protected Repository createRepository() throws Exception {
-               Repository repository = new TransientRepository(getRepositoryFile(),
-                               getHomeDir());
-               return repository;
-       }
-
-}
diff --git a/org.argeo.server.jcr/ext/test/org/argeo/jcr/CollectionsObject.java b/org.argeo.server.jcr/ext/test/org/argeo/jcr/CollectionsObject.java
deleted file mode 100644 (file)
index 1cbb931..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * 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.jcr;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class CollectionsObject {
-       private String id;
-       private String label;
-       private SimpleObject simpleObject;
-       private List<String> stringList = new ArrayList<String>();
-       private Map<String, Float> floatMap = new HashMap<String, Float>();
-       private Map<SimpleObject, String> objectMap = new HashMap<SimpleObject, String>();
-       private Map<String, Map<String, String>> mapOfMaps = new HashMap<String, Map<String, String>>();
-
-       public String getId() {
-               return id;
-       }
-
-       public void setId(String id) {
-               this.id = id;
-       }
-
-       public String getLabel() {
-               return label;
-       }
-
-       public void setLabel(String label) {
-               this.label = label;
-       }
-
-       public SimpleObject getSimpleObject() {
-               return simpleObject;
-       }
-
-       public void setSimpleObject(SimpleObject simpleObject) {
-               this.simpleObject = simpleObject;
-       }
-
-       public List<String> getStringList() {
-               return stringList;
-       }
-
-       public void setStringList(List<String> stringList) {
-               this.stringList = stringList;
-       }
-
-       public Map<String, Float> getFloatMap() {
-               return floatMap;
-       }
-
-       public void setFloatMap(Map<String, Float> floatMap) {
-               this.floatMap = floatMap;
-       }
-
-       public Map<SimpleObject, String> getObjectMap() {
-               return objectMap;
-       }
-
-       public void setObjectMap(Map<SimpleObject, String> objectMap) {
-               this.objectMap = objectMap;
-       }
-
-       public Map<String, Map<String, String>> getMapOfMaps() {
-               return mapOfMaps;
-       }
-
-       public void setMapOfMaps(Map<String, Map<String, String>> mapOfMaps) {
-               this.mapOfMaps = mapOfMaps;
-       }
-}
diff --git a/org.argeo.server.jcr/ext/test/org/argeo/jcr/MapperTest.java b/org.argeo.server.jcr/ext/test/org/argeo/jcr/MapperTest.java
deleted file mode 100644 (file)
index 8f4599c..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * 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.jcr;
-
-import javax.jcr.Node;
-
-import org.argeo.jcr.spring.BeanNodeMapper;
-
-@Deprecated
-public class MapperTest extends AbstractInternalJackrabbitTestCase {
-       public void testSimpleObject() throws Exception {
-               SimpleObject mySo = new SimpleObject();
-               mySo.setInteger(100);
-               mySo.setString("hello world");
-
-               OtherObject oo1 = new OtherObject();
-               oo1.setKey("someKey");
-               oo1.setValue("stringValue");
-               mySo.setOtherObject(oo1);
-
-               OtherObject oo2 = new OtherObject();
-               oo2.setKey("anotherSimpleObject");
-               oo2.setValue(new SimpleObject());
-               mySo.setAnotherObject(oo2);
-
-               BeanNodeMapper bnm = new BeanNodeMapper();
-
-               Node node = bnm.save(session(), mySo);
-               session().save();
-               JcrUtils.debug(node);
-       }
-}
diff --git a/org.argeo.server.jcr/ext/test/org/argeo/jcr/OtherObject.java b/org.argeo.server.jcr/ext/test/org/argeo/jcr/OtherObject.java
deleted file mode 100644 (file)
index 5cce8ff..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * 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.jcr;
-
-public class OtherObject {
-       private String key;
-       private Object value;
-
-       public String getKey() {
-               return key;
-       }
-
-       public void setKey(String key) {
-               this.key = key;
-       }
-
-       public Object getValue() {
-               return value;
-       }
-
-       public void setValue(Object value) {
-               this.value = value;
-       }
-}
diff --git a/org.argeo.server.jcr/ext/test/org/argeo/jcr/SimpleObject.java b/org.argeo.server.jcr/ext/test/org/argeo/jcr/SimpleObject.java
deleted file mode 100644 (file)
index cdc32fc..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * 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.jcr;
-
-import java.util.UUID;
-
-public class SimpleObject {
-       private String string;
-       private String uuid = UUID.randomUUID().toString();
-       private Integer integer;
-       private OtherObject otherObject;
-       private OtherObject anotherObject;
-
-       public String getString() {
-               return string;
-       }
-
-       public void setString(String sting) {
-               this.string = sting;
-       }
-
-       public Integer getInteger() {
-               return integer;
-       }
-
-       public void setInteger(Integer integer) {
-               this.integer = integer;
-       }
-
-       public OtherObject getOtherObject() {
-               return otherObject;
-       }
-
-       public void setOtherObject(OtherObject otherObject) {
-               this.otherObject = otherObject;
-       }
-
-       public OtherObject getAnotherObject() {
-               return anotherObject;
-       }
-
-       public void setAnotherObject(OtherObject anotherObject) {
-               this.anotherObject = anotherObject;
-       }
-
-       @Override
-       public boolean equals(Object obj) {
-               return string.equals(((SimpleObject) obj).string);
-       }
-
-       @Override
-       public int hashCode() {
-               return string.hashCode();
-       }
-
-       public void setUuid(String uuid) {
-               this.uuid = uuid;
-       }
-
-       public String getUuid() {
-               return uuid;
-       }
-
-}
diff --git a/org.argeo.server.jcr/ext/test/org/argeo/jcr/spring/CollectionsObject.java b/org.argeo.server.jcr/ext/test/org/argeo/jcr/spring/CollectionsObject.java
new file mode 100644 (file)
index 0000000..eadabfd
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * 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.jcr.spring;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class CollectionsObject {
+       private String id;
+       private String label;
+       private SimpleObject simpleObject;
+       private List<String> stringList = new ArrayList<String>();
+       private Map<String, Float> floatMap = new HashMap<String, Float>();
+       private Map<SimpleObject, String> objectMap = new HashMap<SimpleObject, String>();
+       private Map<String, Map<String, String>> mapOfMaps = new HashMap<String, Map<String, String>>();
+
+       public String getId() {
+               return id;
+       }
+
+       public void setId(String id) {
+               this.id = id;
+       }
+
+       public String getLabel() {
+               return label;
+       }
+
+       public void setLabel(String label) {
+               this.label = label;
+       }
+
+       public SimpleObject getSimpleObject() {
+               return simpleObject;
+       }
+
+       public void setSimpleObject(SimpleObject simpleObject) {
+               this.simpleObject = simpleObject;
+       }
+
+       public List<String> getStringList() {
+               return stringList;
+       }
+
+       public void setStringList(List<String> stringList) {
+               this.stringList = stringList;
+       }
+
+       public Map<String, Float> getFloatMap() {
+               return floatMap;
+       }
+
+       public void setFloatMap(Map<String, Float> floatMap) {
+               this.floatMap = floatMap;
+       }
+
+       public Map<SimpleObject, String> getObjectMap() {
+               return objectMap;
+       }
+
+       public void setObjectMap(Map<SimpleObject, String> objectMap) {
+               this.objectMap = objectMap;
+       }
+
+       public Map<String, Map<String, String>> getMapOfMaps() {
+               return mapOfMaps;
+       }
+
+       public void setMapOfMaps(Map<String, Map<String, String>> mapOfMaps) {
+               this.mapOfMaps = mapOfMaps;
+       }
+}
diff --git a/org.argeo.server.jcr/ext/test/org/argeo/jcr/spring/MapperTest.java b/org.argeo.server.jcr/ext/test/org/argeo/jcr/spring/MapperTest.java
new file mode 100644 (file)
index 0000000..e4bccd9
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * 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.jcr.spring;
+
+import javax.jcr.Node;
+
+import org.argeo.jackrabbit.unit.AbstractJackrabbitTestCase;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.jcr.spring.BeanNodeMapper;
+
+@Deprecated
+public class MapperTest extends AbstractJackrabbitTestCase {
+       public void testSimpleObject() throws Exception {
+               SimpleObject mySo = new SimpleObject();
+               mySo.setInteger(100);
+               mySo.setString("hello world");
+
+               OtherObject oo1 = new OtherObject();
+               oo1.setKey("someKey");
+               oo1.setValue("stringValue");
+               mySo.setOtherObject(oo1);
+
+               OtherObject oo2 = new OtherObject();
+               oo2.setKey("anotherSimpleObject");
+               oo2.setValue(new SimpleObject());
+               mySo.setAnotherObject(oo2);
+
+               BeanNodeMapper bnm = new BeanNodeMapper();
+
+               Node node = bnm.save(session(), mySo);
+               session().save();
+               JcrUtils.debug(node);
+       }
+}
diff --git a/org.argeo.server.jcr/ext/test/org/argeo/jcr/spring/OtherObject.java b/org.argeo.server.jcr/ext/test/org/argeo/jcr/spring/OtherObject.java
new file mode 100644 (file)
index 0000000..d6fb699
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * 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.jcr.spring;
+
+public class OtherObject {
+       private String key;
+       private Object value;
+
+       public String getKey() {
+               return key;
+       }
+
+       public void setKey(String key) {
+               this.key = key;
+       }
+
+       public Object getValue() {
+               return value;
+       }
+
+       public void setValue(Object value) {
+               this.value = value;
+       }
+}
diff --git a/org.argeo.server.jcr/ext/test/org/argeo/jcr/spring/SimpleObject.java b/org.argeo.server.jcr/ext/test/org/argeo/jcr/spring/SimpleObject.java
new file mode 100644 (file)
index 0000000..d18dd04
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * 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.jcr.spring;
+
+import java.util.UUID;
+
+public class SimpleObject {
+       private String string;
+       private String uuid = UUID.randomUUID().toString();
+       private Integer integer;
+       private OtherObject otherObject;
+       private OtherObject anotherObject;
+
+       public String getString() {
+               return string;
+       }
+
+       public void setString(String sting) {
+               this.string = sting;
+       }
+
+       public Integer getInteger() {
+               return integer;
+       }
+
+       public void setInteger(Integer integer) {
+               this.integer = integer;
+       }
+
+       public OtherObject getOtherObject() {
+               return otherObject;
+       }
+
+       public void setOtherObject(OtherObject otherObject) {
+               this.otherObject = otherObject;
+       }
+
+       public OtherObject getAnotherObject() {
+               return anotherObject;
+       }
+
+       public void setAnotherObject(OtherObject anotherObject) {
+               this.anotherObject = anotherObject;
+       }
+
+       @Override
+       public boolean equals(Object obj) {
+               return string.equals(((SimpleObject) obj).string);
+       }
+
+       @Override
+       public int hashCode() {
+               return string.hashCode();
+       }
+
+       public void setUuid(String uuid) {
+               this.uuid = uuid;
+       }
+
+       public String getUuid() {
+               return uuid;
+       }
+
+}
index 2045f9ae5b00688455b8a4b1582035119d37c2f8..8896b2f4b6c81e3f5cede57779c5e3eae47ab901 100644 (file)
@@ -25,7 +25,7 @@ import javax.jcr.PropertyType;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.jackrabbit.commons.cnd.CndImporter;
-import org.argeo.jcr.AbstractInternalJackrabbitTestCase;
+import org.argeo.jackrabbit.unit.AbstractJackrabbitTestCase;
 import org.argeo.jcr.ArgeoNames;
 import org.argeo.jcr.ArgeoTypes;
 import org.argeo.util.tabular.TabularColumn;
@@ -33,7 +33,7 @@ import org.argeo.util.tabular.TabularRow;
 import org.argeo.util.tabular.TabularRowIterator;
 import org.argeo.util.tabular.TabularWriter;
 
-public class JcrTabularTest extends AbstractInternalJackrabbitTestCase {
+public class JcrTabularTest extends AbstractJackrabbitTestCase {
        private final static Log log = LogFactory.getLog(JcrTabularTest.class);
 
        public void testWriteReadCsv() throws Exception {
index b691572e95ab2f0916ff60a196ab7072c040efcc..3ce499af8060a3470ff632b047b1d78cf3746567 100644 (file)
@@ -23,12 +23,12 @@ import java.util.List;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.argeo.jcr.AbstractInternalJackrabbitTestCase;
+import org.argeo.jackrabbit.unit.AbstractJackrabbitTestCase;
 import org.argeo.jcr.JcrResourceAdapter;
 import org.springframework.core.io.ClassPathResource;
 import org.springframework.core.io.Resource;
 
-public class JcrResourceAdapterTest extends AbstractInternalJackrabbitTestCase {
+public class JcrResourceAdapterTest extends AbstractJackrabbitTestCase {
        private static SimpleDateFormat sdf = new SimpleDateFormat(
                        "yyyyMMdd:hhmmss.SSS");
 
diff --git a/org.argeo.server.jcr/src/org/argeo/jackrabbit/unit/AbstractJackrabbitTestCase.java b/org.argeo.server.jcr/src/org/argeo/jackrabbit/unit/AbstractJackrabbitTestCase.java
new file mode 100644 (file)
index 0000000..1f3ff30
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * 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.jackrabbit.unit;
+
+import java.io.File;
+
+import javax.jcr.Repository;
+
+import org.apache.jackrabbit.core.TransientRepository;
+import org.argeo.jcr.unit.AbstractJcrTestCase;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+
+/** Factorizes configuration of an in memory transient repository */
+public abstract class AbstractJackrabbitTestCase extends
+               AbstractJcrTestCase {
+       protected File getRepositoryFile() throws Exception {
+               Resource res = new ClassPathResource(
+                               "org/argeo/server/jcr/repository-memory.xml");
+               return res.getFile();
+       }
+
+       protected Repository createRepository() throws Exception {
+               Repository repository = new TransientRepository(getRepositoryFile(),
+                               getHomeDir());
+               return repository;
+       }
+
+}