Author: tchemit Date: 2008-01-24 21:31:26 +0000 (Thu, 24 Jan 2008) New Revision: 517 Added: trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceMassInsert.java trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceServerTest.java trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceTest.java Removed: trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/test/StorageServiceMassInsert.java trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/test/StorageServiceServerTest.java trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/test/StorageServiceTest.java Log: paquetage redondant, un test unitaire par convention est dans le m?\195?\170me paquetage que la classe test?\195?\169e Copied: trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceMassInsert.java (from rev 506, trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/test/StorageServiceMassInsert.java) =================================================================== --- trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceMassInsert.java (rev 0) +++ trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceMassInsert.java 2008-01-24 21:31:26 UTC (rev 517) @@ -0,0 +1,104 @@ +/* +* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* ##% */ +package fr.cemagref.simexplorer.is.service; + +import java.io.InputStream; +import java.util.Date; +import java.util.HashMap; + +import junit.framework.TestCase; +import fr.cemagref.simexplorer.is.entities.data.ExplorationApplication; +import fr.cemagref.simexplorer.is.factories.BaseEntityFactory; +import fr.cemagref.simexplorer.is.factories.XmlConstants; +import fr.cemagref.simexplorer.is.service.StorageServiceClient; +import fr.cemagref.simexplorer.is.service.StorageServiceCommon; +import fr.cemagref.simexplorer.is.service.ElementGenerator; + +public class StorageServiceMassInsert extends TestCase { + + private StorageServiceCommon storageService; + private ElementGenerator elementGenerator; + + @Override + protected void setUp() throws Exception { + super.setUp(); + elementGenerator = new ElementGenerator(); + + storageService = new StorageServiceClient(); + storageService.open(); + } + + @Override + protected void tearDown() throws Exception { + super.tearDown(); + storageService.close(); + } + + /* + public void testExportXML() throws Exception { + ExplorationApplication ea = elementGenerator.generateRandomEA(); + InputStream xmlStream = BaseEntityFactory.getFactory( + ExplorationApplication.class).saveElement(ea); + + FileOutputStream os = new FileOutputStream( + "/var/local/simexplorer/test.xml"); + + // Buffer copy stream to stream + BufferedInputStream bin = new BufferedInputStream(xmlStream); + BufferedOutputStream bout = new BufferedOutputStream(os); + + while (true) { + int datum = bin.read(); + if (datum == -1) + break; + bout.write(datum); + } + bout.flush(); + } + */ + + public void testMassInsert() throws Exception { + int c = 350; + + Date begin = new Date(); + + ExplorationApplication ea = null; + for (int i = 0; i < c; i++) { + ea = elementGenerator.generateRandomEA(); + InputStream xmlStream = BaseEntityFactory.getFactory( + ExplorationApplication.class).saveElement( + XmlConstants.VALUE_METADATA_TYPE_EA, ea); + + storageService.saveElement(null, xmlStream, + new HashMap<String, InputStream>()); + + if (i > 0 && i % 100 == 0) { + Date end = new Date(); + long time = end.getTime() - begin.getTime(); + System.out.println("Insert " + i + " : Time taken : " + time + + "ms"); + double timePerElement = time / i; + System.out.println("Insert " + i + + " : Time taken per element : " + timePerElement + + "ms"); + } + + } + } + +} Copied: trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceServerTest.java (from rev 506, trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/test/StorageServiceServerTest.java) =================================================================== --- trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceServerTest.java (rev 0) +++ trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceServerTest.java 2008-01-24 21:31:26 UTC (rev 517) @@ -0,0 +1,52 @@ +/* +* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* ##% */ +package fr.cemagref.simexplorer.is.service; + +import java.util.Properties; + +import javax.naming.Context; +import javax.naming.InitialContext; + +import junit.framework.TestCase; +import fr.cemagref.simexplorer.is.service.StorageService; + +public class StorageServiceServerTest extends TestCase { + + private StorageService storageService; + + @Override + protected void setUp() throws Exception { + super.setUp(); + + Properties properties = (Properties) System.getProperties().clone(); + properties.put("java.naming.provider.url", "jnp://localhost:1099"); + properties.put("java.naming.factory.initial", + "org.jnp.interfaces.NamingContextFactory"); + properties.put("java.naming.factory.url.pkgs", "org.jnp.interfaces"); + + Context context = new InitialContext(properties); + storageService = (StorageService) context.lookup("StorageService"); + + } + + public void testLogin() { + String token = storageService.loginUser("superadmin", "password"); + System.out.println(token); + } + +} Copied: trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceTest.java (from rev 506, trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/test/StorageServiceTest.java) =================================================================== --- trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceTest.java (rev 0) +++ trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/StorageServiceTest.java 2008-01-24 21:31:26 UTC (rev 517) @@ -0,0 +1,145 @@ +/* +* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* ##% */ +package fr.cemagref.simexplorer.is.service; + +import java.io.ByteArrayInputStream; +import java.io.FileInputStream; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; +import java.util.Random; +import java.util.UUID; + +import junit.framework.TestCase; + +import com.healthmarketscience.rmiio.RemoteInputStream; +import com.healthmarketscience.rmiio.RemoteInputStreamServer; +import com.healthmarketscience.rmiio.SimpleRemoteInputStream; + +import fr.cemagref.simexplorer.is.service.StorageService; +import fr.cemagref.simexplorer.is.service.StorageServiceClient; + +public class StorageServiceTest extends TestCase { + + private StorageService storageService; + private Random r = new Random(); + + @Override + protected void setUp() throws Exception { + super.setUp(); + + storageService = new StorageServiceClient(); + } + + @Override + protected void tearDown() throws Exception { + super.tearDown(); + } + + public void testInsertElementZip() throws Exception { + InputStream zipStream = new FileInputStream( + "./src/ressources/testImport/test.zip"); + RemoteInputStreamServer zipRemoteStream = new SimpleRemoteInputStream( + zipStream); + storageService.saveElement(null, zipRemoteStream); + storageService.commit(); + assertNotNull(storageService.getMetadata(null, "abcd")); + } + + public void testInsertElementStreams() throws Exception { + String id = UUID.randomUUID().toString(); + String[] randomcontent = new String[2]; + for (int i = 0; i < randomcontent.length; i++) { + randomcontent[i] = Long.toHexString(r.nextLong()); + } + + StringBuffer xmlString = new StringBuffer( + "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"); + xmlString.append("<data>"); + xmlString.append("<metadata>"); + xmlString.append("<uuid>" + id + "</uuid>"); + xmlString.append("<version>1.0</version>"); + xmlString.append("<name>Test element</name>"); + xmlString.append("<type>TEST</type>"); + xmlString.append("<description>Element test</description>"); + xmlString.append("<creationdate>0</creationdate>"); + xmlString.append("<hash>AAAAA</hash>"); + /* + * xmlString.append("<parentdatauuid></parentdatauuid>"); + * xmlString.append("<parentdataversion></parentdataversion>"); + * xmlString.append("<parentversionuuid></parentversionuuid>"); + * xmlString.append("<parentversionversion></parentversionversion>"); + */ + xmlString.append("<descriptors>"); + xmlString + .append("<descriptor><name>a</name><value>1</value></descriptor>"); + xmlString + .append("<descriptor><name>b</name><value>2</value></descriptor>"); + xmlString + .append("<descriptor><name>c</name><value>3</value></descriptor>"); + xmlString.append("</descriptors>"); + xmlString.append("<attachments>"); + for (int i = 0; i < randomcontent.length; i++) { + xmlString.append("<attachment>"); + xmlString.append("<name>content" + i + + "</name><type>RawType</type>"); + xmlString.append("</attachment>"); + } + xmlString.append("</attachments>"); + xmlString.append("</metadata>"); + xmlString.append("</data>"); + + InputStream xmlStream = new ByteArrayInputStream(xmlString.toString() + .getBytes()); + RemoteInputStreamServer xmlRemoteStream = new SimpleRemoteInputStream( + xmlStream); + + Map<String, RemoteInputStream> attachmentsRemoteStream = new HashMap<String, RemoteInputStream>(); + + for (int j = 0; j < randomcontent.length; j++) { + + StringBuffer contentString = new StringBuffer(""); + for (int i = 0; i < 50; i++) { + contentString.append(Long.toHexString(r.nextLong())) + .append(" "); + } + contentString.append(randomcontent[j]).append(" "); + for (int i = 0; i < 100; i++) { + contentString.append(Long.toHexString(r.nextLong())) + .append(" "); + } + + InputStream contentStream = new ByteArrayInputStream(contentString + .toString().getBytes()); + RemoteInputStreamServer contentRemoteStream = new SimpleRemoteInputStream( + contentStream); + attachmentsRemoteStream.put("content" + j, contentRemoteStream); + + } + + storageService.saveElement(null, xmlRemoteStream, + attachmentsRemoteStream); + storageService.commit(); + assertNotNull(storageService.getMetadata(null, id)); + for (int i = 0; i < randomcontent.length; i++) { + assertTrue(storageService.findFullTextCount(null, randomcontent[i], + false) > 0); + } + } + +} Deleted: trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/test/StorageServiceMassInsert.java =================================================================== --- trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/test/StorageServiceMassInsert.java 2008-01-24 21:30:16 UTC (rev 516) +++ trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/test/StorageServiceMassInsert.java 2008-01-24 21:31:26 UTC (rev 517) @@ -1,104 +0,0 @@ -/* -* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -* ##% */ -package fr.cemagref.simexplorer.is.service.test; - -import java.io.InputStream; -import java.util.Date; -import java.util.HashMap; - -import junit.framework.TestCase; -import fr.cemagref.simexplorer.is.entities.data.ExplorationApplication; -import fr.cemagref.simexplorer.is.factories.BaseEntityFactory; -import fr.cemagref.simexplorer.is.factories.XmlConstants; -import fr.cemagref.simexplorer.is.service.StorageServiceClient; -import fr.cemagref.simexplorer.is.service.StorageServiceCommon; -import fr.cemagref.simexplorer.is.service.ElementGenerator; - -public class StorageServiceMassInsert extends TestCase { - - private StorageServiceCommon storageService; - private ElementGenerator elementGenerator; - - @Override - protected void setUp() throws Exception { - super.setUp(); - elementGenerator = new ElementGenerator(); - - storageService = new StorageServiceClient(); - storageService.open(); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - storageService.close(); - } - - /* - public void testExportXML() throws Exception { - ExplorationApplication ea = elementGenerator.generateRandomEA(); - InputStream xmlStream = BaseEntityFactory.getFactory( - ExplorationApplication.class).saveElement(ea); - - FileOutputStream os = new FileOutputStream( - "/var/local/simexplorer/test.xml"); - - // Buffer copy stream to stream - BufferedInputStream bin = new BufferedInputStream(xmlStream); - BufferedOutputStream bout = new BufferedOutputStream(os); - - while (true) { - int datum = bin.read(); - if (datum == -1) - break; - bout.write(datum); - } - bout.flush(); - } - */ - - public void testMassInsert() throws Exception { - int c = 350; - - Date begin = new Date(); - - ExplorationApplication ea = null; - for (int i = 0; i < c; i++) { - ea = elementGenerator.generateRandomEA(); - InputStream xmlStream = BaseEntityFactory.getFactory( - ExplorationApplication.class).saveElement( - XmlConstants.VALUE_METADATA_TYPE_EA, ea); - - storageService.saveElement(null, xmlStream, - new HashMap<String, InputStream>()); - - if (i > 0 && i % 100 == 0) { - Date end = new Date(); - long time = end.getTime() - begin.getTime(); - System.out.println("Insert " + i + " : Time taken : " + time - + "ms"); - double timePerElement = time / i; - System.out.println("Insert " + i - + " : Time taken per element : " + timePerElement - + "ms"); - } - - } - } - -} Deleted: trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/test/StorageServiceServerTest.java =================================================================== --- trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/test/StorageServiceServerTest.java 2008-01-24 21:30:16 UTC (rev 516) +++ trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/test/StorageServiceServerTest.java 2008-01-24 21:31:26 UTC (rev 517) @@ -1,52 +0,0 @@ -/* -* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -* ##% */ -package fr.cemagref.simexplorer.is.service.test; - -import java.util.Properties; - -import javax.naming.Context; -import javax.naming.InitialContext; - -import junit.framework.TestCase; -import fr.cemagref.simexplorer.is.service.StorageService; - -public class StorageServiceServerTest extends TestCase { - - private StorageService storageService; - - @Override - protected void setUp() throws Exception { - super.setUp(); - - Properties properties = (Properties) System.getProperties().clone(); - properties.put("java.naming.provider.url", "jnp://localhost:1099"); - properties.put("java.naming.factory.initial", - "org.jnp.interfaces.NamingContextFactory"); - properties.put("java.naming.factory.url.pkgs", "org.jnp.interfaces"); - - Context context = new InitialContext(properties); - storageService = (StorageService) context.lookup("StorageService"); - - } - - public void testLogin() { - String token = storageService.loginUser("superadmin", "password"); - System.out.println(token); - } - -} Deleted: trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/test/StorageServiceTest.java =================================================================== --- trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/test/StorageServiceTest.java 2008-01-24 21:30:16 UTC (rev 516) +++ trunk/simexplorer-is-service/src/test/fr/cemagref/simexplorer/is/service/test/StorageServiceTest.java 2008-01-24 21:31:26 UTC (rev 517) @@ -1,146 +0,0 @@ -/* -* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -* ##% */ -package fr.cemagref.simexplorer.is.service.test; - -import java.io.ByteArrayInputStream; -import java.io.FileInputStream; -import java.io.InputStream; -import java.util.HashMap; -import java.util.Map; -import java.util.Random; -import java.util.UUID; - -import junit.framework.TestCase; - -import com.healthmarketscience.rmiio.RemoteInputStream; -import com.healthmarketscience.rmiio.RemoteInputStreamServer; -import com.healthmarketscience.rmiio.SimpleRemoteInputStream; - -import fr.cemagref.simexplorer.is.service.StorageService; -import fr.cemagref.simexplorer.is.service.StorageServiceClient; -import fr.cemagref.simexplorer.is.service.StorageServiceCommon; - -public class StorageServiceTest extends TestCase { - - private StorageService storageService; - private Random r = new Random(); - - @Override - protected void setUp() throws Exception { - super.setUp(); - - storageService = new StorageServiceClient(); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - } - - public void testInsertElementZip() throws Exception { - InputStream zipStream = new FileInputStream( - "./src/ressources/testImport/test.zip"); - RemoteInputStreamServer zipRemoteStream = new SimpleRemoteInputStream( - zipStream); - storageService.saveElement(null, zipRemoteStream); - storageService.commit(); - assertNotNull(storageService.getMetadata(null, "abcd")); - } - - public void testInsertElementStreams() throws Exception { - String id = UUID.randomUUID().toString(); - String[] randomcontent = new String[2]; - for (int i = 0; i < randomcontent.length; i++) { - randomcontent[i] = Long.toHexString(r.nextLong()); - } - - StringBuffer xmlString = new StringBuffer( - "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"); - xmlString.append("<data>"); - xmlString.append("<metadata>"); - xmlString.append("<uuid>" + id + "</uuid>"); - xmlString.append("<version>1.0</version>"); - xmlString.append("<name>Test element</name>"); - xmlString.append("<type>TEST</type>"); - xmlString.append("<description>Element test</description>"); - xmlString.append("<creationdate>0</creationdate>"); - xmlString.append("<hash>AAAAA</hash>"); - /* - * xmlString.append("<parentdatauuid></parentdatauuid>"); - * xmlString.append("<parentdataversion></parentdataversion>"); - * xmlString.append("<parentversionuuid></parentversionuuid>"); - * xmlString.append("<parentversionversion></parentversionversion>"); - */ - xmlString.append("<descriptors>"); - xmlString - .append("<descriptor><name>a</name><value>1</value></descriptor>"); - xmlString - .append("<descriptor><name>b</name><value>2</value></descriptor>"); - xmlString - .append("<descriptor><name>c</name><value>3</value></descriptor>"); - xmlString.append("</descriptors>"); - xmlString.append("<attachments>"); - for (int i = 0; i < randomcontent.length; i++) { - xmlString.append("<attachment>"); - xmlString.append("<name>content" + i - + "</name><type>RawType</type>"); - xmlString.append("</attachment>"); - } - xmlString.append("</attachments>"); - xmlString.append("</metadata>"); - xmlString.append("</data>"); - - InputStream xmlStream = new ByteArrayInputStream(xmlString.toString() - .getBytes()); - RemoteInputStreamServer xmlRemoteStream = new SimpleRemoteInputStream( - xmlStream); - - Map<String, RemoteInputStream> attachmentsRemoteStream = new HashMap<String, RemoteInputStream>(); - - for (int j = 0; j < randomcontent.length; j++) { - - StringBuffer contentString = new StringBuffer(""); - for (int i = 0; i < 50; i++) { - contentString.append(Long.toHexString(r.nextLong())) - .append(" "); - } - contentString.append(randomcontent[j]).append(" "); - for (int i = 0; i < 100; i++) { - contentString.append(Long.toHexString(r.nextLong())) - .append(" "); - } - - InputStream contentStream = new ByteArrayInputStream(contentString - .toString().getBytes()); - RemoteInputStreamServer contentRemoteStream = new SimpleRemoteInputStream( - contentStream); - attachmentsRemoteStream.put("content" + j, contentRemoteStream); - - } - - storageService.saveElement(null, xmlRemoteStream, - attachmentsRemoteStream); - storageService.commit(); - assertNotNull(storageService.getMetadata(null, id)); - for (int i = 0; i < randomcontent.length; i++) { - assertTrue(storageService.findFullTextCount(null, randomcontent[i], - false) > 0); - } - } - -}
participants (1)
-
tchemit@users.labs.libre-entreprise.org