[Joafip-svn] SF.net SVN: joafip:[2968] trunk/joafip/src
Brought to you by:
luc_peuvrier
|
From: <luc...@us...> - 2011-11-12 16:58:29
|
Revision: 2968
http://joafip.svn.sourceforge.net/joafip/?rev=2968&view=rev
Author: luc_peuvrier
Date: 2011-11-12 16:58:23 +0000 (Sat, 12 Nov 2011)
Log Message:
-----------
added tests. added fix. correction
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/service/FilePersistence.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/out/ExportStoreQue.java
trunk/joafip/src/test/resources/log4j.properties
Added Paths:
-----------
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/out/que/
trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/EnumItemState.java
trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/Item.java
trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestEnumMap.java
Modified: trunk/joafip/src/main/java/net/sf/joafip/service/FilePersistence.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/service/FilePersistence.java 2011-11-12 16:56:52 UTC (rev 2967)
+++ trunk/joafip/src/main/java/net/sf/joafip/service/FilePersistence.java 2011-11-12 16:58:23 UTC (rev 2968)
@@ -59,7 +59,6 @@
import net.sf.joafip.store.service.objectio.manager.ISubsituteSynchronizer;
import net.sf.joafip.store.service.objectio.serialize.input.IObjectInput;
import net.sf.joafip.store.service.objectio.serialize.output.IObjectOutput;
-import net.sf.joafip.store.service.proxy.ProxyManager2;
/**
*
@@ -1291,7 +1290,6 @@
}
private void storedEnumMapPutAll(final Map<EnumKey, Enum<?>> map) {
- assert !ProxyManager2.isProxyOrEnhanced(map);
for (final Map.Entry<EnumKey, Enum<?>> entry : map.entrySet()) {
storedEnumMap.put(entry.getKey(), entry.getValue());
}
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/out/ExportStoreQue.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/out/ExportStoreQue.java 2011-11-12 16:56:52 UTC (rev 2967)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/out/ExportStoreQue.java 2011-11-12 16:58:23 UTC (rev 2968)
@@ -39,7 +39,14 @@
@NotStorableClass
public class ExportStoreQue {
- private static final byte[] DATA = new byte[] {};
+ // FIXMELUC ____________________________why not empty ?
+ // HeapFileDataManager not accept empty data
+ // net.sf.joafip.heapfile.service.HeapException: associated data size must
+ // be defined
+ // at
+ // net.sf.joafip.heapfile.record.entity.HeapRecord.assertDataRecordStateForMarshalling(HeapRecord.java:385)
+ // private static final byte[] DATA = new byte[] {};
+ private static final byte[] DATA = new byte[] { 0 };
private static final int MAX_RECORDS = 1000;
Added: trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/EnumItemState.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/EnumItemState.java (rev 0)
+++ trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/EnumItemState.java 2011-11-12 16:58:23 UTC (rev 2968)
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2008 Luc Peuvrier
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (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.gnu.org/licenses/lgpl.html
+ *
+ * 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 net.sf.joafip.entity.rel400;
+
+/**
+ * for test
+ *
+ * @author luc peuvrier
+ */
+public enum EnumItemState {
+ /**/STATE1,
+ /**/STATE2;
+}
Added: trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/Item.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/Item.java (rev 0)
+++ trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/Item.java 2011-11-12 16:58:23 UTC (rev 2968)
@@ -0,0 +1,132 @@
+/*
+ * Copyright 2007 Luc Peuvrier
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (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.gnu.org/licenses/lgpl.html
+ *
+ * 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 net.sf.joafip.entity.rel400;
+
+import net.sf.joafip.StorableClass;
+
+@SuppressWarnings("PMD")
+@StorableClass
+public class Item implements Cloneable {
+
+ private final int identifier;
+
+ private String value;
+
+ private EnumItemState itemState;
+
+ /**
+ * default constructor to make this persistable
+ *
+ */
+ public Item() {
+ super();
+ identifier = -1;
+ }
+
+ public Item(final int identifier) {
+ super();
+ this.identifier = identifier;
+ }
+
+ public Item(final int identifier,
+ final String value) {
+ super();
+ this.identifier = identifier;
+ this.value = value;
+ }
+
+ /**
+ * copy constructor
+ *
+ * @param item
+ */
+ public Item(final Item item) {
+ super();
+ identifier = item.getIdentifier();
+ final String valueFromItem = item.getValue();
+ if (valueFromItem == null) {
+ value = null;
+ } else {
+ value = "" + valueFromItem;
+ }
+ itemState = item.getItemState();
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(final String value) {
+ this.value = value;
+ }
+
+ public int getIdentifier() {
+ return identifier;
+ }
+
+ public EnumItemState getItemState() {
+ return itemState;
+ }
+
+ public void setItemState(final EnumItemState itemState) {
+ this.itemState = itemState;
+ }
+
+ @Override
+ public String toString() {
+ return "id=" + identifier + " value=" + value;
+ }
+
+ @Override
+ public int hashCode() {
+ final int PRIME = 31;
+ int result = 1;
+ result = PRIME * result + identifier;
+ result = PRIME * result + ((value == null) ? 0 : value.hashCode());
+ return result;
+ }
+
+ @Override
+ @SuppressWarnings("PMD")
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (!(obj instanceof Item)) {
+ return false;
+ }
+ final Item other = (Item) obj;
+ if (identifier != other.getIdentifier())
+ return false;
+ if (value == null) {
+ if (other.getValue() != null)
+ return false;
+ } else if (!value.equals(other.getValue()))
+ return false;
+ return true;
+ }
+
+ @Override
+ public Item clone() {// NOPMD
+ try {
+ return (Item) super.clone();
+ } catch (CloneNotSupportedException exception) {
+ throw new InternalError();// NOPMD
+ }
+ }
+}
Added: trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestEnumMap.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestEnumMap.java (rev 0)
+++ trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestEnumMap.java 2011-11-12 16:58:23 UTC (rev 2968)
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (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.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * 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 net.sf.joafip.service.rel400;
+
+import net.sf.joafip.AbstractDeleteFileTestCase;
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.StorableAccess;
+import net.sf.joafip.TestException;
+import net.sf.joafip.entity.EnumFilePersistenceCloseAction;
+import net.sf.joafip.entity.rel400.Item;
+import net.sf.joafip.service.FilePersistenceBuilder;
+import net.sf.joafip.service.FilePersistenceClassNotFoundException;
+import net.sf.joafip.service.FilePersistenceDataCorruptedException;
+import net.sf.joafip.service.FilePersistenceException;
+import net.sf.joafip.service.FilePersistenceInvalidClassException;
+import net.sf.joafip.service.FilePersistenceNotSerializableException;
+import net.sf.joafip.service.FilePersistenceTooBigForSerializationException;
+import net.sf.joafip.service.IDataAccessSession;
+import net.sf.joafip.service.IFilePersistence;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+@StorableAccess
+public class TestEnumMap extends AbstractDeleteFileTestCase {
+
+ public TestEnumMap() throws TestException {
+ super();
+ }
+
+ public TestEnumMap(final String name) throws TestException {
+ super(name);
+ }
+
+ public void testEnumMap() throws FilePersistenceException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException,
+ FilePersistenceTooBigForSerializationException {
+
+ IFilePersistence filePersistence = createFilePersistence(true);
+ IDataAccessSession session = filePersistence.createDataAccessSession();
+ session.open();
+ Item item=new Item(0, "value");
+ session.setObject("key",item);
+ session.closeAndWait(EnumFilePersistenceCloseAction.SAVE);
+ filePersistence.close();
+
+ filePersistence = createFilePersistence(false);
+ session = filePersistence.createDataAccessSession();
+ session.open();
+ item=(Item) session.getObject("key");
+ assertEquals("bad state",0,item.getIdentifier());
+ assertEquals("bad state","value",item.getValue());
+ session.closeAndWait(EnumFilePersistenceCloseAction.SAVE);
+ filePersistence.close();
+ }
+
+ private IFilePersistence createFilePersistence(final boolean removeFile)
+ throws FilePersistenceException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException {
+ final FilePersistenceBuilder builder = new FilePersistenceBuilder();
+ builder.setPathName(path.getAbsolutePath());
+ builder.setRemoveFiles(removeFile);
+ builder.setProxyMode(true);
+ builder.setCrashSafeMode(false);
+ builder.setGarbageManagement(false);
+ return builder.build();
+ }
+}
Modified: trunk/joafip/src/test/resources/log4j.properties
===================================================================
--- trunk/joafip/src/test/resources/log4j.properties 2011-11-12 16:56:52 UTC (rev 2967)
+++ trunk/joafip/src/test/resources/log4j.properties 2011-11-12 16:58:23 UTC (rev 2968)
@@ -127,7 +127,9 @@
#log4j.logger.net.sf.joafip.performance.service=debug
#log4j.logger.net.sf.joafip.service.bug.emis.TestEmis=debug
log4j.logger.net.sf.joafip.performance.items.service.Inserter=info
+log4j.logger.net.sf.joafip.performance.items.service.InserterBKM=info
log4j.logger.net.sf.joafip.performance.items.service.Searcher=info
+log4j.logger.net.sf.joafip.performance.items.service.SearcherBKM=info
log4j.logger.net.sf.joafip.performance.items.service.ImportSearcher=info
log4j.logger.net.sf.joafip.service.MainCrash=info
log4j.logger.net.sf.joafip.service.MainAfterCrash=info
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|