r401 - trunk/wikitty-api/src/test/java/org/nuiton/wikitty/memory
Author: bpoussin Date: 2010-10-13 16:04:01 +0200 (Wed, 13 Oct 2010) New Revision: 401 Url: http://nuiton.org/repositories/revision/wikitty/401 Log: hack pour permettre aux tests de passer avec le changement de tmp dir Modified: trunk/wikitty-api/src/test/java/org/nuiton/wikitty/memory/InMemoryStorageTest.java Modified: trunk/wikitty-api/src/test/java/org/nuiton/wikitty/memory/InMemoryStorageTest.java =================================================================== --- trunk/wikitty-api/src/test/java/org/nuiton/wikitty/memory/InMemoryStorageTest.java 2010-10-13 14:03:30 UTC (rev 400) +++ trunk/wikitty-api/src/test/java/org/nuiton/wikitty/memory/InMemoryStorageTest.java 2010-10-13 14:04:01 UTC (rev 401) @@ -34,6 +34,12 @@ @Test public void testFilePersistance() throws Exception { + // TODO poussin 20101113 hack to create tmp dir, this is necessary + // actually because new mavenpom move tmp dir to target without create it :( + File tmp = new File(System.getProperty("java.io.tmpdir")); + tmp.mkdirs(); + // end of hack + File tempPersistFile = File.createTempFile(InMemoryStorageTest.class.getName(), ".tmp"); tempPersistFile.delete(); tempPersistFile.deleteOnExit();
Le Wed, 13 Oct 2010 16:04:01 +0200 (CEST), bpoussin@users.nuiton.org a écrit :
@Test public void testFilePersistance() throws Exception { + // TODO poussin 20101113 hack to create tmp dir, this is necessary + // actually because new mavenpom move tmp dir to target without create it :( + File tmp = new File(System.getProperty("java.io.tmpdir")); + tmp.mkdirs(); + // end of hack même si on écrit un hack il peut être un peu mieux que ça :
1) le mettre dans une méthode annotée @BeforeClass 2) Mettre un code un peu moins BOURRIN (on est plus en 1971 :)) @BeforeClass public static void setUpClass() throws Exception { // Create tmpdir if not exist String tmpdir = System.getProperty("java.io.tmpdir"); File file = new File(tmpdir); if (!file.exists()) { boolean b = file.mkdirs(); if (!b) { if (log.isWarnEnabled()) log.warn("Could not create tmp directory : " + file); } if (log.isInfoEnabled()) { log.info("tmp dir : " + file + " was created"); } } } 3) pour moi c'est pas un hack, y'a rien dans l'api de la jdk qui spécifie que cette variable doit pointer sur un répertoire existant ? Donc non c'est pas un hack 4) se connecter quand on code (ou bien pas dire aux autres de le faire, na) -- Tony Chemit -------------------- tél: +33 (0) 2 40 50 29 28 email: chemit@codelutin.com http://www.codelutin.com
participants (2)
-
bpoussin@users.nuiton.org -
chemit