/*
 * Copyright (C) 2000 - 2009 Silverpeas
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * As a special exception to the terms and conditions of version 3.0 of
 * the GPL, you may redistribute this Program in connection with Free/Libre
 * Open Source Software ("FLOSS") applications as described in Silverpeas's
 * FLOSS exception.  You should have recieved a copy of the text describing
 * the FLOSS exception, and it is also available here:
 * "http://www.silverpeas.org/legal/licensing"
 *
 * 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 Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.stratelia.webactiv.beans.admin.spaceTemplates;

import com.silverpeas.util.PathTestUtil;
import java.io.File;
import com.stratelia.webactiv.beans.admin.SpaceInst;
import com.stratelia.webactiv.beans.admin.instance.control.WAComponent;
import java.util.Hashtable;
import java.util.Map;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 * Unit tests on the SpaceInstanciator objects behaviour.
 */
public class SpaceInstanciatorTest {

  private static final String XMLSPACETEMPLATES_DIR = PathTestUtil.TARGET_DIR
          + "test-classes" + File.separatorChar + "xmlspacetemplates";

  public SpaceInstanciatorTest() {
  }

  @BeforeClass
  public static void setUpClass() throws Exception {
  }

  @AfterClass
  public static void tearDownClass() throws Exception {
  }

  @Before
  public void setUp() {
  }

  @After
  public void tearDown() {
  }

  /**
   * Test of getAllSpaceTemplates method, of class SpaceInstanciator.
   */
  @Test
  public void atInitAllTemplatesAreAvailables() {
    SpaceInstanciator.xmlPackage = XMLSPACETEMPLATES_DIR;
    Hashtable<String, WAComponent> componentModels = new Hashtable<String, WAComponent>();
    SpaceInstanciator instanciator = new SpaceInstanciator(componentModels);
    Map<String, SpaceTemplate> spaceTemplates = instanciator.getAllSpaceTemplates();
    assertNotNull(spaceTemplates);
    assertEquals(1, spaceTemplates.size());
    assertTrue(spaceTemplates.containsKey("EspaceProjet"));
  }

  /**
   * Test of getAllSpaceTemplates method, of class SpaceInstanciator.
   */
  @Test
  public void atInitNoTemplatesDirectoryImpliesNoTemplatesLoaded() {
    Hashtable<String, WAComponent> componentModels = new Hashtable<String, WAComponent>();
    SpaceInstanciator instanciator = new SpaceInstanciator(componentModels);
    Map<String, SpaceTemplate> spaceTemplates = instanciator.getAllSpaceTemplates();
    assertNotNull(spaceTemplates);
    assertTrue(spaceTemplates.isEmpty());
  }
}
@@ -1362,16 +1362,94 @@
 ponent;%0A
+import com.stratelia.webactiv.util.ResourceLocator;%0Aimport java.util.HashMap;%0A
 import j
@@ -2376,33 +2376,27 @@
 ES_DIR;%0A    
-Hashtable
+Map
 %3CString, WAC
@@ -2423,37 +2423,35 @@
 odels = new Hash
-table
+Map
 %3CString, WACompo
@@ -2928,25 +2928,62 @@
 ) %7B%0A    
-Hashtable
+SpaceInstanciator.xmlPackage = %22toto%22;%0A    Map
 %3CString,
@@ -3022,21 +3022,19 @@
 new Hash
-table
+Map
 %3CString,

Fix a bug in a test coming from a bad value of a static field in a class.