[kune-commits] r1500 - in trunk: . src/main/java/cc/kune/core/server src/main/java/cc/kune/core/server/manager/file src/main/java/cc/kune/core/server/properties src/main/java/cc/kune/core/server/rpc src/main/resources src/test/java/cc/kune/core/server/integration/site

Vicente J. Ruiz Jurado vjrj_ at ourproject.org
Tue Aug 30 10:04:23 CEST 2011


Author: vjrj_
Date: 2011-08-30 10:04:22 +0200 (Tue, 30 Aug 2011)
New Revision: 1500

Added:
   trunk/src/test/java/cc/kune/core/server/integration/site/InitDataTest.java
Removed:
   trunk/src/test/java/cc/kune/core/server/integration/site/SiteServiceTest.java
Modified:
   trunk/pom.xml
   trunk/src/main/java/cc/kune/core/server/KuneRackModule.java
   trunk/src/main/java/cc/kune/core/server/manager/file/FileGwtUploadAbstractServlet.java
   trunk/src/main/java/cc/kune/core/server/manager/file/FileUploadManagerAbstract.java
   trunk/src/main/java/cc/kune/core/server/manager/file/UserLogoDownloadManager.java
   trunk/src/main/java/cc/kune/core/server/properties/KuneProperties.java
   trunk/src/main/java/cc/kune/core/server/properties/KunePropertiesDefault.java
   trunk/src/main/java/cc/kune/core/server/properties/ReservedWordsRegistry.java
   trunk/src/main/java/cc/kune/core/server/rpc/SiteRPC.java
   trunk/src/main/resources/kune.properties
Log:
CLOSED - # 55: kune properties as parameter 
http://kune.ourproject.org/issues/ticket/55

Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml	2011-08-20 18:04:22 UTC (rev 1499)
+++ trunk/pom.xml	2011-08-30 08:04:22 UTC (rev 1500)
@@ -793,9 +793,9 @@
           </commandlineArgs>
           <systemProperties>
             <systemProperty>
-              <key>kune.config</key>
-              <!-- <value>/src/main/resources/kune.properties</value> -->
-              <value>kune.properties</value>
+              <key>kune.server.config</key>
+              <value>src/main/resources/kune.properties</value>
+  <!--               <value>kune.properties</value> -->
             </systemProperty>
             <systemProperty>
               <key>wave.server.config</key>

Modified: trunk/src/main/java/cc/kune/core/server/KuneRackModule.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/KuneRackModule.java	2011-08-20 18:04:22 UTC (rev 1499)
+++ trunk/src/main/java/cc/kune/core/server/KuneRackModule.java	2011-08-30 08:04:22 UTC (rev 1500)
@@ -81,7 +81,7 @@
   public KuneRackModule(final String jpaUnit, final Scope sessionScope) {
 
     final SystemConfiguration sysConf = new SystemConfiguration();
-    final String kuneConfig = sysConf.getString("kune.config");
+    final String kuneConfig = sysConf.getString("kune.server.config");
 
     configModule = new AbstractModule() {
       @Override

Modified: trunk/src/main/java/cc/kune/core/server/manager/file/FileGwtUploadAbstractServlet.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/manager/file/FileGwtUploadAbstractServlet.java	2011-08-20 18:04:22 UTC (rev 1499)
+++ trunk/src/main/java/cc/kune/core/server/manager/file/FileGwtUploadAbstractServlet.java	2011-08-30 08:04:22 UTC (rev 1500)
@@ -46,8 +46,8 @@
 
   public FileGwtUploadAbstractServlet(final KuneProperties kuneProperties) {
     this.kuneProperties = kuneProperties;
-    this.maxSize = Integer.valueOf(kuneProperties.get(KuneProperties.UPLOAD_MAX_FILE_SIZE_IN_KS));
-    this.uploadDelay = Integer.valueOf(kuneProperties.get(KuneProperties.UPLOAD_DELAY_FOR_TEST));
+    this.maxSize = kuneProperties.getInteger(KuneProperties.UPLOAD_MAX_FILE_SIZE_IN_KS);
+    this.uploadDelay = kuneProperties.getInteger(KuneProperties.UPLOAD_DELAY_FOR_TEST);
   }
 
   protected abstract String createUploadedFile(final String userHash, final StateToken stateToken,

Modified: trunk/src/main/java/cc/kune/core/server/manager/file/FileUploadManagerAbstract.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/manager/file/FileUploadManagerAbstract.java	2011-08-20 18:04:22 UTC (rev 1499)
+++ trunk/src/main/java/cc/kune/core/server/manager/file/FileUploadManagerAbstract.java	2011-08-30 08:04:22 UTC (rev 1500)
@@ -46,113 +46,116 @@
 
 public abstract class FileUploadManagerAbstract extends HttpServlet {
 
-    private static final long serialVersionUID = -4227762495128652369L;
+  public static final Log LOG = LogFactory.getLog(FileUploadManager.class);
 
-    public static final Log LOG = LogFactory.getLog(FileUploadManager.class);
+  private static final long serialVersionUID = -4227762495128652369L;
 
-    protected static final String UTF8 = "UTF-8";
+  protected static final String UTF8 = "UTF-8";
 
-    @Inject
-    KuneProperties kuneProperties;
+  @Inject
+  KuneProperties kuneProperties;
 
-    protected abstract void beforePostStart();
+  protected abstract void beforePostStart();
 
-    protected abstract void beforeRespond(final HttpServletResponse response, final Writer w) throws IOException;
+  protected abstract void beforeRespond(final HttpServletResponse response, final Writer w)
+      throws IOException;
 
-    @Override
-    @SuppressWarnings({ "rawtypes", "deprecation" })
-    protected void doPost(final HttpServletRequest req, final HttpServletResponse response) throws ServletException,
-            IOException {
+  abstract void createUploadedFile(final String userHash, final StateToken stateToken,
+      final String fileName, final FileItem file, final String typeId) throws Exception;
 
-        beforePostStart();
+  @Override
+  @SuppressWarnings({ "rawtypes" })
+  protected void doPost(final HttpServletRequest req, final HttpServletResponse response)
+      throws ServletException, IOException {
 
-        final DiskFileItemFactory factory = new DiskFileItemFactory();
-        // maximum size that will be stored in memory
-        factory.setSizeThreshold(4096);
-        // the location for saving data that is larger than getSizeThreshold()
-        factory.setRepository(new File("/tmp"));
+    beforePostStart();
 
-        if (!ServletFileUpload.isMultipartContent(req)) {
-            LOG.warn("Not a multipart upload");
-        }
+    final DiskFileItemFactory factory = new DiskFileItemFactory();
+    // maximum size that will be stored in memory
+    factory.setSizeThreshold(4096);
+    // the location for saving data that is larger than getSizeThreshold()
+    factory.setRepository(new File("/tmp"));
 
-        final ServletFileUpload upload = new ServletFileUpload(factory);
-        // maximum size before a FileUploadException will be thrown
-        upload.setSizeMax(Long.valueOf(kuneProperties.get(KuneProperties.UPLOAD_MAX_FILE_SIZE)) * 1024 * 1024);
-
-        try {
-            final List fileItems = upload.parseRequest(req);
-            String userHash = null;
-            StateToken stateToken = null;
-            String typeId = null;
-            String fileName = null;
-            FileItem file = null;
-            for (final Iterator iterator = fileItems.iterator(); iterator.hasNext();) {
-                final FileItem item = (FileItem) iterator.next();
-                if (item.isFormField()) {
-                    final String name = item.getFieldName();
-                    final String value = item.getString();
-                    LOG.info("name: " + name + " value: " + value);
-                    if (name.equals(FileConstants.HASH)) {
-                        userHash = value;
-                    }
-                    if (name.equals(FileConstants.TOKEN)) {
-                        stateToken = new StateToken(value);
-                    }
-                    if (name.equals(FileConstants.TYPE_ID)) {
-                        typeId = value;
-                    }
-                } else {
-                    fileName = item.getName();
-                    LOG.info("file: " + fileName + " fieldName: " + item.getFieldName() + " size: " + item.getSize()
-                            + " typeId: " + typeId);
-                    file = item;
-                }
-            }
-            createUploadedFile(userHash, stateToken, fileName, file, typeId);
-            onSuccess(response);
-        } catch (final FileUploadException e) {
-            onFileUploadException(response);
-        } catch (final Exception e) {
-            onOtherException(response, e);
-        }
+    if (!ServletFileUpload.isMultipartContent(req)) {
+      LOG.warn("Not a multipart upload");
     }
 
-    protected void doResponse(final HttpServletResponse response, final String additionalResponse) throws IOException {
-        doResponse(response, additionalResponse, HttpServletResponse.SC_OK);
-    }
+    final ServletFileUpload upload = new ServletFileUpload(factory);
+    // maximum size before a FileUploadException will be thrown
+    upload.setSizeMax(kuneProperties.getLong(KuneProperties.UPLOAD_MAX_FILE_SIZE) * 1024 * 1024);
 
-    protected void doResponse(final HttpServletResponse response, final String additionalResponse,
-            final int responseCode) throws IOException {
-        final Writer w = new OutputStreamWriter(response.getOutputStream());
-        if (additionalResponse != null) {
-            w.write(additionalResponse);
+    try {
+      final List fileItems = upload.parseRequest(req);
+      String userHash = null;
+      StateToken stateToken = null;
+      String typeId = null;
+      String fileName = null;
+      FileItem file = null;
+      for (final Iterator iterator = fileItems.iterator(); iterator.hasNext();) {
+        final FileItem item = (FileItem) iterator.next();
+        if (item.isFormField()) {
+          final String name = item.getFieldName();
+          final String value = item.getString();
+          LOG.info("name: " + name + " value: " + value);
+          if (name.equals(FileConstants.HASH)) {
+            userHash = value;
+          }
+          if (name.equals(FileConstants.TOKEN)) {
+            stateToken = new StateToken(value);
+          }
+          if (name.equals(FileConstants.TYPE_ID)) {
+            typeId = value;
+          }
+        } else {
+          fileName = item.getName();
+          LOG.info("file: " + fileName + " fieldName: " + item.getFieldName() + " size: "
+              + item.getSize() + " typeId: " + typeId);
+          file = item;
         }
-        w.close();
-        response.setStatus(responseCode);
+      }
+      createUploadedFile(userHash, stateToken, fileName, file, typeId);
+      onSuccess(response);
+    } catch (final FileUploadException e) {
+      onFileUploadException(response);
+    } catch (final Exception e) {
+      onOtherException(response, e);
     }
+  }
 
-    protected void logFileDel(final boolean delResult) {
-        if (!delResult) {
-            LOG.error("Cannot delete file");
-        }
-    }
+  protected void doResponse(final HttpServletResponse response, final String additionalResponse)
+      throws IOException {
+    doResponse(response, additionalResponse, HttpServletResponse.SC_OK);
+  }
 
-    protected void onFileUploadException(final HttpServletResponse response) throws IOException {
-        doResponse(response, null);
+  protected void doResponse(final HttpServletResponse response, final String additionalResponse,
+      final int responseCode) throws IOException {
+    final Writer w = new OutputStreamWriter(response.getOutputStream());
+    if (additionalResponse != null) {
+      w.write(additionalResponse);
     }
+    w.close();
+    response.setStatus(responseCode);
+  }
 
-    protected void onOtherException(final HttpServletResponse response, final Exception e) throws IOException {
-        LOG.info("Exception: " + e.getCause());
-        e.printStackTrace();
-        doResponse(response, null);
+  protected void logFileDel(final boolean delResult) {
+    if (!delResult) {
+      LOG.error("Cannot delete file");
     }
+  }
 
-    protected void onSuccess(final HttpServletResponse response) throws IOException {
-        doResponse(response, null);
-    }
+  protected void onFileUploadException(final HttpServletResponse response) throws IOException {
+    doResponse(response, null);
+  }
 
-    abstract void createUploadedFile(final String userHash, final StateToken stateToken, final String fileName,
-            final FileItem file, final String typeId) throws Exception;
+  protected void onOtherException(final HttpServletResponse response, final Exception e)
+      throws IOException {
+    LOG.info("Exception: " + e.getCause());
+    e.printStackTrace();
+    doResponse(response, null);
+  }
 
+  protected void onSuccess(final HttpServletResponse response) throws IOException {
+    doResponse(response, null);
+  }
+
 }

Modified: trunk/src/main/java/cc/kune/core/server/manager/file/UserLogoDownloadManager.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/manager/file/UserLogoDownloadManager.java	2011-08-20 18:04:22 UTC (rev 1499)
+++ trunk/src/main/java/cc/kune/core/server/manager/file/UserLogoDownloadManager.java	2011-08-30 08:04:22 UTC (rev 1500)
@@ -77,7 +77,8 @@
   }
 
   private void noResult(final HttpServletResponse resp) throws IOException {
-    FileDownloadManagerUtils.returnNotFound(resp);
+    // FileDownloadManagerUtils.returnNotFound(resp);
+    FileDownloadManagerUtils.returnFile("src/main/webapp/others/unknown.jpg", resp.getOutputStream());
   }
 
   private void replyDefAvatar(final HttpServletResponse resp) throws FileNotFoundException, IOException {

Modified: trunk/src/main/java/cc/kune/core/server/properties/KuneProperties.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/properties/KuneProperties.java	2011-08-20 18:04:22 UTC (rev 1499)
+++ trunk/src/main/java/cc/kune/core/server/properties/KuneProperties.java	2011-08-30 08:04:22 UTC (rev 1500)
@@ -19,13 +19,14 @@
  */
 package cc.kune.core.server.properties;
 
+import java.util.List;
+
 public interface KuneProperties {
   String AVI_EMBEDED_OBJECT = "kune.media.aviembededobject";
   String CHAT_DOMAIN = "kune.chat.domain";
   String CHAT_HTTP_BASE = "kune.chat.httpbase";
   String CHAT_ROOM_HOST = "kune.chat.roomHost";
   String CURRENT_CC_VERSION = "kune.currentccversion";
-
   String DEFAULT_SITE_SHORT_NAME = "kune.default.site.shortName";
   String FLV_EMBEDED_OBJECT = "kune.media.flvembededobject";
   String IMAGES_CROPSIZE = "kune.images.cropsize";
@@ -57,4 +58,10 @@
   String get(String key);
 
   String get(String key, String defaultValue);
+
+  Integer getInteger(String key);
+
+  List<String> getList(String key);
+
+  Long getLong(String key);
 }

Modified: trunk/src/main/java/cc/kune/core/server/properties/KunePropertiesDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/properties/KunePropertiesDefault.java	2011-08-20 18:04:22 UTC (rev 1499)
+++ trunk/src/main/java/cc/kune/core/server/properties/KunePropertiesDefault.java	2011-08-30 08:04:22 UTC (rev 1500)
@@ -19,11 +19,14 @@
  */
 package cc.kune.core.server.properties;
 
-import java.io.IOException;
-import java.io.InputStream;
 import java.text.MessageFormat;
-import java.util.Properties;
+import java.util.List;
 
+import org.apache.commons.configuration.CompositeConfiguration;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.commons.configuration.SystemConfiguration;
+
 import cc.kune.core.server.ServerException;
 
 import com.google.inject.Inject;
@@ -31,46 +34,61 @@
 
 @Singleton
 public class KunePropertiesDefault implements KuneProperties {
+  private CompositeConfiguration config;
   private final String fileName;
-  private Properties properties;
 
   @Inject
   public KunePropertiesDefault(@PropertiesFileName final String fileName) {
     this.fileName = fileName;
     try {
-      properties = new Properties();
-      final InputStream input = getInputStream(fileName);
-      properties.load(input);
-    } catch (final IOException e) {
+      config = new CompositeConfiguration();
+      config.addConfiguration(new SystemConfiguration());
+      config.addConfiguration(new PropertiesConfiguration(fileName));
+    } catch (final ConfigurationException e) {
       final String msg = MessageFormat.format("Couldn't open property file {0}", fileName);
       throw new ServerException(msg, e);
     }
+  }
 
+  private void checkNull(final String key, final Object value) {
+    if (value == null) {
+      throw new ServerException("PROPERTY: " + key + " not defined in " + fileName);
+    }
   }
 
   @Override
   public String get(final String key) {
-    final String value = properties.getProperty(key);
-    if (value == null) {
-      throw new ServerException("PROPERTY: " + key + " not defined in " + fileName);
-    }
+    final String value = config.getString(key);
+    checkNull(key, value);
     return value;
   }
 
   @Override
   public String get(final String key, final String defaultValue) {
-    final String value = properties.getProperty(key);
+    final String value = config.getString(key);
     return value != null ? value : defaultValue;
   }
 
-  private InputStream getInputStream(final String fileName) {
-    final InputStream input = Thread.currentThread().getContextClassLoader().getResourceAsStream(
-        fileName);
-    if (input == null) {
-      final String msg = MessageFormat.format("Properties file: ''{0}'' not found", fileName);
-      throw new ServerException(msg);
-    }
-    return input;
+  @Override
+  public Integer getInteger(final String key) {
+    final Integer value = config.getInt(key);
+    checkNull(key, value);
+    return value;
   }
 
+  @Override
+  public List<String> getList(final String key) {
+    @SuppressWarnings("unchecked")
+    final List<String> value = config.getList(key);
+    checkNull(key, value);
+    return value;
+  }
+
+  @Override
+  public Long getLong(final String key) {
+    final Long value = config.getLong(key);
+    checkNull(key, value);
+    return value;
+  }
+
 }

Modified: trunk/src/main/java/cc/kune/core/server/properties/ReservedWordsRegistry.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/properties/ReservedWordsRegistry.java	2011-08-20 18:04:22 UTC (rev 1499)
+++ trunk/src/main/java/cc/kune/core/server/properties/ReservedWordsRegistry.java	2011-08-30 08:04:22 UTC (rev 1500)
@@ -1,7 +1,6 @@
 package cc.kune.core.server.properties;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
 
 import cc.kune.core.client.errors.DefaultException;
@@ -15,8 +14,7 @@
   private static final long serialVersionUID = 7455756500618858360L;
 
   public static List<String> fromList(final KuneProperties kuneProperties) {
-    return Arrays.asList(kuneProperties.get(KuneProperties.RESERVED_WORDS, "root").replaceAll(" ", "").split(
-        ","));
+    return kuneProperties.getList(KuneProperties.RESERVED_WORDS);
   }
 
   @Inject

Modified: trunk/src/main/java/cc/kune/core/server/rpc/SiteRPC.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/rpc/SiteRPC.java	2011-08-20 18:04:22 UTC (rev 1499)
+++ trunk/src/main/java/cc/kune/core/server/rpc/SiteRPC.java	2011-08-30 08:04:22 UTC (rev 1500)
@@ -20,6 +20,7 @@
 package cc.kune.core.server.rpc;
 
 import java.util.HashMap;
+import java.util.List;
 import java.util.TimeZone;
 
 import cc.kune.core.client.errors.DefaultException;
@@ -80,12 +81,12 @@
     this.serverToolRegistry = serverToolRegistry;
     this.extMediaDescManager = extMediaDescManager;
     data = loadInitData();
-    siteThemes = getSiteThemes(this.kuneProperties.get(KuneProperties.WS_THEMES).split(","));
+    siteThemes = getSiteThemes(this.kuneProperties.getList(KuneProperties.WS_THEMES));
     reservedWords = new ReservedWordsRegistryDTO(ReservedWordsRegistry.fromList(kuneProperties));
   }
 
   private String[] getColors(final String key) {
-    return this.kuneProperties.get(key).split(",");
+    return this.kuneProperties.getList(key).toArray(new String[0]);
   }
 
   @Override
@@ -104,7 +105,7 @@
     return dataMapped;
   }
 
-  private HashMap<String, GSpaceTheme> getSiteThemes(final String[] themes) {
+  private HashMap<String, GSpaceTheme> getSiteThemes(final List<String> themes) {
     final HashMap<String, GSpaceTheme> map = new HashMap<String, GSpaceTheme>();
     for (final String theme : themes) {
       map.put(theme, getThemeFromProperties(theme));
@@ -142,10 +143,10 @@
     data.setMaxFileSizeInMb(kuneProperties.get(KuneProperties.UPLOAD_MAX_FILE_SIZE));
     data.setUserTools(serverToolRegistry.getToolsForUsers());
     data.setGroupTools(serverToolRegistry.getToolsForGroups());
-    data.setImgResizewidth(Integer.valueOf(kuneProperties.get(KuneProperties.IMAGES_RESIZEWIDTH)));
-    data.setImgThumbsize(Integer.valueOf(kuneProperties.get(KuneProperties.IMAGES_THUMBSIZE)));
-    data.setImgCropsize(Integer.valueOf(kuneProperties.get(KuneProperties.IMAGES_CROPSIZE)));
-    data.setImgIconsize(Integer.valueOf(kuneProperties.get(KuneProperties.IMAGES_ICONSIZE)));
+    data.setImgResizewidth(kuneProperties.getInteger(KuneProperties.IMAGES_RESIZEWIDTH));
+    data.setImgThumbsize(kuneProperties.getInteger(KuneProperties.IMAGES_THUMBSIZE));
+    data.setImgCropsize(kuneProperties.getInteger(KuneProperties.IMAGES_CROPSIZE));
+    data.setImgIconsize(kuneProperties.getInteger(KuneProperties.IMAGES_ICONSIZE));
     data.setFlvEmbedObject(kuneProperties.get(KuneProperties.FLV_EMBEDED_OBJECT));
     data.setMp3EmbedObject(kuneProperties.get(KuneProperties.MP3_EMBEDED_OBJECT));
     data.setOggEmbedObject(kuneProperties.get(KuneProperties.OGG_EMBEDED_OBJECT));

Modified: trunk/src/main/resources/kune.properties
===================================================================
--- trunk/src/main/resources/kune.properties	2011-08-20 18:04:22 UTC (rev 1499)
+++ trunk/src/main/resources/kune.properties	2011-08-30 08:04:22 UTC (rev 1500)
@@ -95,10 +95,6 @@
 kune.media.oggembededobject = <applet code="com.fluendo.player.Cortado.class" archive="/kune/others/cortado.jar" width="352" height="288"> <param name="url" value="###DOC_URL###"/> <param name="local" value="false"/> <param name="showStatus" value="show"/> <param name="keepAspect" value="true"/> <param name="autoPlay" value="false"/> <param name="video" value="true"/> <param name="audio" value="true"/> <param name="bufferSize" value="200"/> </applet>
 kune.media.aviembededobject = <object data="###DOC_URL###" type="video/msvideo" />
 
-### See: http://code.google.com/p/wave-protocol/wiki/Installation
-### wave server configuration
-wave.server.config = wave-server.properties
-
 ### More info about properties
 # http://en.wikipedia.org/wiki/.properties
 # http://java.sun.com/javase/6/docs/api/java/util/Properties.html#load(java.io.Reader)

Copied: trunk/src/test/java/cc/kune/core/server/integration/site/InitDataTest.java (from rev 1496, trunk/src/test/java/cc/kune/core/server/integration/site/SiteServiceTest.java)
===================================================================
--- trunk/src/test/java/cc/kune/core/server/integration/site/InitDataTest.java	                        (rev 0)
+++ trunk/src/test/java/cc/kune/core/server/integration/site/InitDataTest.java	2011-08-30 08:04:22 UTC (rev 1500)
@@ -0,0 +1,83 @@
+/*
+ *
+ * Copyright (C) 2007-2011 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * 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.
+ *
+ * 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 cc.kune.core.server.integration.site;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import cc.kune.core.client.rpcservices.SiteService;
+import cc.kune.core.server.UserSession;
+import cc.kune.core.server.integration.IntegrationTest;
+import cc.kune.core.server.integration.IntegrationTestHelper;
+import cc.kune.core.server.manager.I18nLanguageManager;
+import cc.kune.core.shared.dto.InitDataDTO;
+import cc.kune.core.shared.dto.LicenseDTO;
+import cc.kune.domain.Group;
+
+import com.google.inject.Inject;
+
+public class InitDataTest extends IntegrationTest {
+
+  @Inject
+  Group groupFinder;
+  @Inject
+  I18nLanguageManager i18nLangManager;
+  @Inject
+  SiteService service;
+  @Inject
+  UserSession session;
+
+  private void assertValidLicenseDTOList(final ArrayList<LicenseDTO> licenseList) {
+    assertTrue(licenseList.size() > 0);
+    for (final Object o : licenseList) {
+      assertNotNull(o);
+      assertEquals(LicenseDTO.class, o.getClass());
+    }
+  }
+
+  @Before
+  public void init() {
+    new IntegrationTestHelper(this);
+  }
+
+  @Test
+  public void testGetInitData() throws Exception {
+    final InitDataDTO initData = service.getInitData(null);
+    assertNotNull(initData);
+    assertValidLicenseDTOList(initData.getLicenses());
+    assertTrue(initData.getLanguages().size() > 0);
+    assertTrue(initData.getCountries().size() > 0);
+    assertNotNull(initData.getLanguages().get(0).getCode());
+    assertNotNull(initData.getCountries().get(0).getCode());
+    assertNotNull(initData.getGroupTools());
+    assertNotNull(initData.getUserTools());
+    assertTrue(initData.getGroupTools().size() > 0);
+    assertTrue(initData.getUserTools().size() > 0);
+    assertTrue(initData.getgSpaceThemes().size() > 1);
+    assertTrue(initData.getReservedWords().size() > 1);
+  }
+
+}

Deleted: trunk/src/test/java/cc/kune/core/server/integration/site/SiteServiceTest.java
===================================================================
--- trunk/src/test/java/cc/kune/core/server/integration/site/SiteServiceTest.java	2011-08-20 18:04:22 UTC (rev 1499)
+++ trunk/src/test/java/cc/kune/core/server/integration/site/SiteServiceTest.java	2011-08-30 08:04:22 UTC (rev 1500)
@@ -1,81 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2011 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * 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.
- *
- * 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 cc.kune.core.server.integration.site;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import cc.kune.core.client.rpcservices.SiteService;
-import cc.kune.core.server.UserSession;
-import cc.kune.core.server.integration.IntegrationTest;
-import cc.kune.core.server.integration.IntegrationTestHelper;
-import cc.kune.core.server.manager.I18nLanguageManager;
-import cc.kune.core.shared.dto.InitDataDTO;
-import cc.kune.core.shared.dto.LicenseDTO;
-import cc.kune.domain.Group;
-
-import com.google.inject.Inject;
-
-public class SiteServiceTest extends IntegrationTest {
-
-    @Inject
-    SiteService service;
-    @Inject
-    UserSession session;
-    @Inject
-    Group groupFinder;
-    @Inject
-    I18nLanguageManager i18nLangManager;
-
-    @Before
-    public void init() {
-        new IntegrationTestHelper(this);
-    }
-
-    @Test
-    public void testGetInitData() throws Exception {
-        final InitDataDTO initData = service.getInitData(null);
-        assertNotNull(initData);
-        assertValidLicenseDTOList(initData.getLicenses());
-        assertTrue(initData.getLanguages().size() > 0);
-        assertTrue(initData.getCountries().size() > 0);
-        assertNotNull(initData.getLanguages().get(0).getCode());
-        assertNotNull(initData.getCountries().get(0).getCode());
-        assertNotNull(initData.getGroupTools());
-        assertNotNull(initData.getUserTools());
-        assertTrue(initData.getGroupTools().size() > 0);
-        assertTrue(initData.getUserTools().size() > 0);
-    }
-
-    private void assertValidLicenseDTOList(final ArrayList<LicenseDTO> licenseList) {
-        assertTrue(licenseList.size() > 0);
-        for (final Object o : licenseList) {
-            assertNotNull(o);
-            assertEquals(LicenseDTO.class, o.getClass());
-        }
-    }
-
-}




More information about the kune-commits mailing list