rave-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfrank...@apache.org
Subject svn commit: r1127283 - in /incubator/rave/trunk/rave-portal/src: main/java/org/apache/rave/jdbc/util/ main/java/org/apache/rave/portal/model/ main/java/org/apache/rave/portal/repository/ main/java/org/apache/rave/portal/repository/impl/ main/java/org/a...
Date Tue, 24 May 2011 20:58:25 GMT
Author: mfranklin
Date: Tue May 24 20:58:24 2011
New Revision: 1127283

URL: http://svn.apache.org/viewvc?rev=1127283&view=rev
Log:
Initial server side code for widget repository (Supports RAVE-32)

Added:
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/JpaWidgetRepository.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/WidgetProviderService.java
      - copied, changed from r1127227, incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/WidgetService.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/WidgetService.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/impl/DefaultWidgetService.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/controller/WidgetStoreController.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/util/ViewNames.java
    incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/store.jsp
    incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/widget.jsp
    incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/repository/JpaWidgetRepositoryTest.java
    incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/service/WidgetServiceTest.java
    incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/controller/WidgetStoreControllerTest.java
Modified:
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/jdbc/util/DataSourcePopulator.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/Widget.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/WidgetRepository.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/JpaPageRepository.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/JpaRegionRepository.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/JpaUserRepository.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/util/LocalizationUtils.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/api/rpc/model/RpcOperation.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/renderer/RenderService.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/renderer/impl/DefaultRenderService.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/util/ModelKeys.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/provider/w3c/service/impl/WookieWidgetService.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/provider/w3c/web/renderer/W3cWidgetRenderer.java
    incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/tags/rave_generic_page.tag
    incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/model/PageTest.java
    incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/model/UserTest.java
    incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/repository/JpaRegionRepositoryTest.java
    incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/repository/JpaUserRepositoryTest.java
    incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/repository/impl/util/JpaUtilTest.java
    incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/util/LocalizationUtilsTest.java
    incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/api/rpc/model/RpcOperationTest.java
    incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/controller/HomeControllerTest.java
    incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/renderer/RenderServiceIntegrationTest.java
    incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/tag/RegionWidgetTagTest.java
    incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/provider/opensocial/web/renderer/OpenSocialWidgetRendererTest.java
    incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/provider/w3c/web/renderer/W3cWidgetRendererTest.java

Modified: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/jdbc/util/DataSourcePopulator.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/jdbc/util/DataSourcePopulator.java?rev=1127283&r1=1127282&r2=1127283&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/jdbc/util/DataSourcePopulator.java (original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/jdbc/util/DataSourcePopulator.java Tue May 24 20:58:24 2011
@@ -23,7 +23,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.core.io.Resource;
 
-import javax.persistence.EntityManager;
 import javax.sql.DataSource;
 import java.io.IOException;
 import java.sql.Connection;

Modified: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/Widget.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/Widget.java?rev=1127283&r1=1127282&r2=1127283&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/Widget.java (original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/Widget.java Tue May 24 20:58:24 2011
@@ -26,6 +26,9 @@ import javax.persistence.*;
 @Entity
 @Table(name="widget")
 @SequenceGenerator(name="widgetIdSeq", sequenceName = "widget_id_seq")
+@NamedQueries({
+        @NamedQuery(name = "Widget.getAll", query = "SELECT w from Widget w")
+})
 public class Widget {
     @Id @Column(name="id")
     @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "widgetIdSeq")

Modified: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/WidgetRepository.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/WidgetRepository.java?rev=1127283&r1=1127282&r2=1127283&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/WidgetRepository.java (original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/WidgetRepository.java Tue May 24 20:58:24 2011
@@ -18,5 +18,21 @@
  */
 package org.apache.rave.portal.repository;
 
+import org.apache.rave.portal.model.Widget;
+
+import java.util.List;
+
 public interface WidgetRepository {
+    /**
+     * Gets a list of all widgets in the repository
+     * @return a valid List
+     */
+    List<Widget> getAll();
+
+    /**
+     * Gets the widget by its id
+     * @param id the id of the target widget
+     * @return valid widget if exists; null otherwise
+     */
+    Widget getById(long id);
 }
\ No newline at end of file

Modified: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/JpaPageRepository.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/JpaPageRepository.java?rev=1127283&r1=1127282&r2=1127283&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/JpaPageRepository.java (original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/JpaPageRepository.java Tue May 24 20:58:24 2011
@@ -25,7 +25,6 @@ import org.springframework.stereotype.Re
 
 import javax.persistence.EntityManager;
 import javax.persistence.PersistenceContext;
-import javax.persistence.Query;
 import javax.persistence.TypedQuery;
 import java.util.List;
 

Modified: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/JpaRegionRepository.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/JpaRegionRepository.java?rev=1127283&r1=1127282&r2=1127283&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/JpaRegionRepository.java (original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/JpaRegionRepository.java Tue May 24 20:58:24 2011
@@ -26,7 +26,6 @@ import org.springframework.stereotype.Re
 import javax.persistence.EntityManager;
 import javax.persistence.PersistenceContext;
 
-import static org.apache.rave.portal.repository.impl.util.JpaUtil.getSingleResult;
 import static org.apache.rave.portal.repository.impl.util.JpaUtil.saveOrUpdate;
 
 /**

Modified: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/JpaUserRepository.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/JpaUserRepository.java?rev=1127283&r1=1127282&r2=1127283&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/JpaUserRepository.java (original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/JpaUserRepository.java Tue May 24 20:58:24 2011
@@ -25,7 +25,6 @@ import org.springframework.stereotype.Re
 
 import javax.persistence.EntityManager;
 import javax.persistence.PersistenceContext;
-import javax.persistence.Query;
 import javax.persistence.TypedQuery;
 
 import static org.apache.rave.portal.repository.impl.util.JpaUtil.getSingleResult;

Added: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/JpaWidgetRepository.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/JpaWidgetRepository.java?rev=1127283&view=auto
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/JpaWidgetRepository.java (added)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/repository/impl/JpaWidgetRepository.java Tue May 24 20:58:24 2011
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 org.apache.rave.portal.repository.impl;
+
+
+import org.apache.rave.portal.model.Widget;
+import org.apache.rave.portal.repository.WidgetRepository;
+import org.springframework.stereotype.Repository;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.TypedQuery;
+import java.util.List;
+
+@Repository
+public class JpaWidgetRepository implements WidgetRepository{
+
+    @PersistenceContext
+    private EntityManager manager;
+
+    @Override
+    public List<Widget> getAll() {
+        TypedQuery<Widget> query = manager.createNamedQuery("Widget.getAll", Widget.class);
+        return query.getResultList();
+    }
+
+    @Override
+    public Widget getById(long id) {
+        return manager.find(Widget.class, id);
+    }
+}

Copied: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/WidgetProviderService.java (from r1127227, incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/WidgetService.java)
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/WidgetProviderService.java?p2=incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/WidgetProviderService.java&p1=incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/WidgetService.java&r1=1127227&r2=1127283&rev=1127283&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/WidgetService.java (original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/WidgetProviderService.java Tue May 24 20:58:24 2011
@@ -21,7 +21,7 @@ package org.apache.rave.portal.service;
 import org.apache.rave.portal.model.User;
 import org.apache.rave.portal.model.Widget;
 
-public interface WidgetService {
+public interface WidgetProviderService {
     
     /**
      * Gets the object that represents the metadata about the widget for 

Added: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/WidgetService.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/WidgetService.java?rev=1127283&view=auto
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/WidgetService.java (added)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/WidgetService.java Tue May 24 20:58:24 2011
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 org.apache.rave.portal.service;
+
+import org.apache.rave.portal.model.Widget;
+
+import java.util.List;
+
+/**
+ * Provides widget operations
+ */
+public interface WidgetService {
+
+    /**
+     * Gets a list of widgets that a user can add to their context
+     * @return valid list of widgets
+     */
+    List<Widget> getAllWidgets();
+
+    /**
+     * Gets the detailed metadata for a widget
+     * @param id the Id of the widget to add
+     * @return a valid widget if one exists for the given id; null otherwise
+     */
+    Widget getWidget(long id);
+}

Added: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/impl/DefaultWidgetService.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/impl/DefaultWidgetService.java?rev=1127283&view=auto
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/impl/DefaultWidgetService.java (added)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/service/impl/DefaultWidgetService.java Tue May 24 20:58:24 2011
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 org.apache.rave.portal.service.impl;
+
+import org.apache.rave.portal.model.Widget;
+import org.apache.rave.portal.repository.WidgetRepository;
+import org.apache.rave.portal.service.WidgetService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class DefaultWidgetService implements WidgetService {
+
+    private final WidgetRepository widgetRepository;
+
+    @Autowired
+    public DefaultWidgetService(WidgetRepository widgetRepository) {
+        this.widgetRepository = widgetRepository;
+    }
+
+    @Override
+    public List<Widget> getAllWidgets() {
+        return widgetRepository.getAll();
+    }
+
+    @Override
+    public Widget getWidget(long id) {
+        return widgetRepository.getById(id);
+    }
+}

Modified: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/util/LocalizationUtils.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/util/LocalizationUtils.java?rev=1127283&r1=1127282&r2=1127283&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/util/LocalizationUtils.java (original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/util/LocalizationUtils.java Tue May 24 20:58:24 2011
@@ -19,9 +19,9 @@
 package org.apache.rave.portal.util;
 //REVIEW NOTE: these may be replaceable with Java 7
 //classes.
+
 import com.ibm.icu.util.GlobalizationPreferences;
 import com.ibm.icu.util.ULocale;
-
 import org.apache.commons.lang.ArrayUtils;
 import org.apache.rave.portal.model.util.LocalizedString;
 import org.slf4j.Logger;

Modified: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/api/rpc/model/RpcOperation.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/api/rpc/model/RpcOperation.java?rev=1127283&r1=1127282&r2=1127283&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/api/rpc/model/RpcOperation.java (original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/api/rpc/model/RpcOperation.java Tue May 24 20:58:24 2011
@@ -19,8 +19,6 @@
 
 package org.apache.rave.portal.web.api.rpc.model;
 
-import org.apache.rave.portal.model.RegionWidget;
-
 /**
  * Defines an RPC operation that can be executed to return a given result
  */

Added: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/controller/WidgetStoreController.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/controller/WidgetStoreController.java?rev=1127283&view=auto
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/controller/WidgetStoreController.java (added)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/controller/WidgetStoreController.java Tue May 24 20:58:24 2011
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 org.apache.rave.portal.web.controller;
+
+import org.apache.rave.portal.service.WidgetService;
+import org.apache.rave.portal.web.util.ModelKeys;
+import org.apache.rave.portal.web.util.ViewNames;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+@Controller
+@RequestMapping(value = "/store/*")
+public class WidgetStoreController {
+
+    private final WidgetService widgetService;
+
+    @Autowired
+    public WidgetStoreController(WidgetService widgetService) {
+        this.widgetService = widgetService;
+    }
+
+    @RequestMapping(method = RequestMethod.GET)
+    public String view(Model model) {
+        model.addAttribute(ModelKeys.WIDGETS, widgetService.getAllWidgets());
+        return ViewNames.STORE;
+    }
+
+    @RequestMapping(method = RequestMethod.GET, value = "widget/{widgetId}")
+    public String viewWidget(Model model, @PathVariable long widgetId) {
+        model.addAttribute(ModelKeys.WIDGET, widgetService.getWidget(widgetId));
+        return ViewNames.WIDGET;
+    }
+}

Modified: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/renderer/RenderService.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/renderer/RenderService.java?rev=1127283&r1=1127282&r2=1127283&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/renderer/RenderService.java (original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/renderer/RenderService.java Tue May 24 20:58:24 2011
@@ -20,6 +20,7 @@
 package org.apache.rave.portal.web.renderer;
 
 import org.apache.rave.portal.model.RegionWidget;
+
 import java.util.Collection;
 
 /**

Modified: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/renderer/impl/DefaultRenderService.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/renderer/impl/DefaultRenderService.java?rev=1127283&r1=1127282&r2=1127283&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/renderer/impl/DefaultRenderService.java (original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/renderer/impl/DefaultRenderService.java Tue May 24 20:58:24 2011
@@ -21,10 +21,8 @@ package org.apache.rave.portal.web.rende
 
 import org.apache.rave.exception.NotSupportedException;
 import org.apache.rave.portal.model.RegionWidget;
-import org.apache.rave.portal.model.Widget;
 import org.apache.rave.portal.web.renderer.RegionWidgetRenderer;
 import org.apache.rave.portal.web.renderer.RenderService;
-import org.apache.rave.portal.web.renderer.Renderer;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 

Modified: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/util/ModelKeys.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/util/ModelKeys.java?rev=1127283&r1=1127282&r2=1127283&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/util/ModelKeys.java (original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/util/ModelKeys.java Tue May 24 20:58:24 2011
@@ -20,9 +20,8 @@
 package org.apache.rave.portal.web.util;
 
 public class ModelKeys {
-	 //Private, empty constructor for utility class
-	 private ModelKeys () {;}
-
     public final static String PAGES = "pages"; // a list of pages available for the current user
     public final static String ERROR_MESSAGE = "errorMessage"; // an error message to be reported to the user
+    public static final String WIDGETS = "widgets"; // a list of widget objects
+    public static final String WIDGET = "widget";
 }
\ No newline at end of file

Added: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/util/ViewNames.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/util/ViewNames.java?rev=1127283&view=auto
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/util/ViewNames.java (added)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/util/ViewNames.java Tue May 24 20:58:24 2011
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 org.apache.rave.portal.web.util;
+
+public class ViewNames {
+    public static final String HOME = "home";
+    public static final String STORE = "store";
+    public static final String WIDGET = "widget";
+}

Modified: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/provider/w3c/service/impl/WookieWidgetService.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/provider/w3c/service/impl/WookieWidgetService.java?rev=1127283&r1=1127282&r2=1127283&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/provider/w3c/service/impl/WookieWidgetService.java (original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/provider/w3c/service/impl/WookieWidgetService.java Tue May 24 20:58:24 2011
@@ -16,18 +16,20 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.rave.provider.w3c.service.impl;
 
 import org.apache.rave.portal.model.User;
 import org.apache.rave.portal.model.Widget;
-import org.apache.rave.portal.service.WidgetService;
+import org.apache.rave.portal.service.WidgetProviderService;
+import org.springframework.stereotype.Service;
+
 //import org.apache.wookie.connector.framework.WidgetInstance;
 //import org.apache.wookie.connector.framework.WookieConnectorException;
 //import org.apache.wookie.connector.framework.WookieConnectorService;
-import org.springframework.stereotype.Service;
 
 @Service
-public class WookieWidgetService implements WidgetService {
+public class WookieWidgetService implements WidgetProviderService {
 	
 	// TODO uncomment when Wookie Connector is available in Maven
     
@@ -39,7 +41,7 @@ public class WookieWidgetService impleme
     }
 
     /* (non-Javadoc)
-     * @see org.apache.rave.portal.service.WidgetService#getWidget(org.apache.rave.portal.model.User)
+     * @see org.apache.rave.portal.service.WidgetProviderService#getWidget(org.apache.rave.portal.model.User)
      */
     @Override
     public Widget getWidget(User viewer, String context, Widget widget) {

Modified: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/provider/w3c/web/renderer/W3cWidgetRenderer.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/provider/w3c/web/renderer/W3cWidgetRenderer.java?rev=1127283&r1=1127282&r2=1127283&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/provider/w3c/web/renderer/W3cWidgetRenderer.java (original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/provider/w3c/web/renderer/W3cWidgetRenderer.java Tue May 24 20:58:24 2011
@@ -19,17 +19,17 @@
 
 package org.apache.rave.provider.w3c.web.renderer;
 
-import static org.apache.rave.provider.w3c.Constants.WIDGET_TYPE;
-
 import org.apache.rave.exception.NotSupportedException;
 import org.apache.rave.portal.model.RegionWidget;
 import org.apache.rave.portal.model.Widget;
-import org.apache.rave.portal.service.WidgetService;
+import org.apache.rave.portal.service.WidgetProviderService;
 import org.apache.rave.portal.web.renderer.RegionWidgetRenderer;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Component;
 
+import static org.apache.rave.provider.w3c.Constants.WIDGET_TYPE;
+
 /**
  * Renders W3C widgets via the injected Wookie service
  */
@@ -45,10 +45,10 @@ public class W3cWidgetRenderer implement
 
     private static final String INLINE_MARKUP = "";
 
-    private final WidgetService widgetService;
+    private final WidgetProviderService widgetService;
 
     @Autowired
-    public W3cWidgetRenderer(@Qualifier("wookieWidgetService") WidgetService widgetService) {
+    public W3cWidgetRenderer(@Qualifier("wookieWidgetService") WidgetProviderService widgetService) {
         this.widgetService = widgetService;
     }
 

Modified: incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/tags/rave_generic_page.tag
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/tags/rave_generic_page.tag?rev=1127283&r1=1127282&r2=1127283&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/tags/rave_generic_page.tag (original)
+++ incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/tags/rave_generic_page.tag Tue May 24 20:58:24 2011
@@ -1,12 +1,28 @@
-<%@ tag language="java" pageEncoding="UTF-8"%>
-<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
-<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
-<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
+<%--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<!--
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  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.
+
+--%><%@ tag language="java" pageEncoding="UTF-8"%><%--
+--%><%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%><%--
+--%><%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%><%--
+--%><%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%><%--
+--%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><%--
 This tag will provide simple template layouts for pages that use it. See for example home.jsp.
--->
+--%>
 <html>
   <head>
      <title>Rave Home</title>

Added: incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/store.jsp
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/store.jsp?rev=1127283&view=auto
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/store.jsp (added)
+++ incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/store.jsp Tue May 24 20:58:24 2011
@@ -0,0 +1,26 @@
+<%--
+   Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+  
+   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.
+  
+--%><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><%--
+--%><%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %><%--
+--%><%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %><%--
+--%><%@ taglib tagdir="/WEB-INF/tags" prefix="rave"%><%--
+
+--%><rave:rave_generic_page>
+
+</rave:rave_generic_page>
\ No newline at end of file

Added: incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/widget.jsp
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/widget.jsp?rev=1127283&view=auto
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/widget.jsp (added)
+++ incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/widget.jsp Tue May 24 20:58:24 2011
@@ -0,0 +1,26 @@
+<%--
+   Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+  
+   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.
+  
+--%><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><%--
+--%><%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %><%--
+--%><%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %><%--
+--%><%@ taglib tagdir="/WEB-INF/tags" prefix="rave"%><%--
+
+--%><rave:rave_generic_page>
+
+</rave:rave_generic_page>
\ No newline at end of file

Modified: incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/model/PageTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/model/PageTest.java?rev=1127283&r1=1127282&r2=1127283&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/model/PageTest.java (original)
+++ incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/model/PageTest.java Tue May 24 20:58:24 2011
@@ -18,12 +18,12 @@
  */
 package org.apache.rave.portal.model;
 
-import org.junit.Test;
-import org.junit.Before;
 import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 
-import java.util.List;
 import java.util.ArrayList;
+import java.util.List;
 
 import static org.junit.Assert.assertTrue;
 

Modified: incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/model/UserTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/model/UserTest.java?rev=1127283&r1=1127282&r2=1127283&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/model/UserTest.java (original)
+++ incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/model/UserTest.java Tue May 24 20:58:24 2011
@@ -17,11 +17,12 @@
  * under the License.
  */
 package org.apache.rave.portal.model;
-import org.junit.Test;
+
 import org.junit.Before;
+import org.junit.Test;
 
-import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 /**
  * Tests the User class.

Modified: incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/repository/JpaRegionRepositoryTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/repository/JpaRegionRepositoryTest.java?rev=1127283&r1=1127282&r2=1127283&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/repository/JpaRegionRepositoryTest.java (original)
+++ incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/repository/JpaRegionRepositoryTest.java Tue May 24 20:58:24 2011
@@ -21,7 +21,6 @@ package org.apache.rave.portal.repositor
 
 import org.apache.rave.portal.model.Region;
 import org.apache.rave.portal.model.RegionWidget;
-import org.hamcrest.CoreMatchers;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;

Modified: incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/repository/JpaUserRepositoryTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/repository/JpaUserRepositoryTest.java?rev=1127283&r1=1127282&r2=1127283&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/repository/JpaUserRepositoryTest.java (original)
+++ incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/repository/JpaUserRepositoryTest.java Tue May 24 20:58:24 2011
@@ -19,7 +19,6 @@
 
 package org.apache.rave.portal.repository;
 
-import org.apache.rave.portal.model.Page;
 import org.apache.rave.portal.model.User;
 import org.hamcrest.CoreMatchers;
 import org.junit.Test;
@@ -28,11 +27,7 @@ import org.springframework.beans.factory
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
-import java.util.List;
-
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.CoreMatchers.*;
 import static org.junit.Assert.assertThat;
 
 @RunWith(SpringJUnit4ClassRunner.class)

Added: incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/repository/JpaWidgetRepositoryTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/repository/JpaWidgetRepositoryTest.java?rev=1127283&view=auto
==============================================================================
--- incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/repository/JpaWidgetRepositoryTest.java (added)
+++ incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/repository/JpaWidgetRepositoryTest.java Tue May 24 20:58:24 2011
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 org.apache.rave.portal.repository;
+
+import org.apache.rave.portal.model.Widget;
+import org.hamcrest.CoreMatchers;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import java.util.List;
+
+import static org.easymock.EasyMock.notNull;
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.assertThat;
+
+@Transactional
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = {"file:src/main/webapp/WEB-INF/dataContext.xml", "file:src/main/webapp/WEB-INF/applicationContext.xml"})
+public class JpaWidgetRepositoryTest {
+
+    @PersistenceContext
+    private EntityManager sharedManager;
+
+    @Autowired
+    private WidgetRepository repository;
+
+    @Test
+    public void getById_valid() {
+        Widget widget = repository.getById(1L);
+        assertThat(widget, is(notNullValue()));
+        assertThat(widget.getId(), is(equalTo(1L)));
+    }
+
+    @Test
+    public void getById_invValid() {
+        Widget widget = repository.getById(-1L);
+        assertThat(widget, is(nullValue()));
+    }
+
+    @Test
+    public void getAll() {
+        List<Widget> widgets = repository.getAll();
+        assertThat(widgets, is(notNullValue()));
+        assertThat(widgets.size() > 4, is(true));
+    }
+}

Modified: incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/repository/impl/util/JpaUtilTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/repository/impl/util/JpaUtilTest.java?rev=1127283&r1=1127282&r2=1127283&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/repository/impl/util/JpaUtilTest.java (original)
+++ incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/repository/impl/util/JpaUtilTest.java Tue May 24 20:58:24 2011
@@ -19,11 +19,14 @@
 
 package org.apache.rave.portal.repository.impl.util;
 
+import org.junit.Test;
 import org.springframework.dao.IncorrectResultSizeDataAccessException;
+
 import java.util.ArrayList;
 import java.util.List;
-import org.junit.Test;
-import static org.junit.Assert.*;
+
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
 
 /**
  *

Added: incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/service/WidgetServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/service/WidgetServiceTest.java?rev=1127283&view=auto
==============================================================================
--- incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/service/WidgetServiceTest.java (added)
+++ incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/service/WidgetServiceTest.java Tue May 24 20:58:24 2011
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 org.apache.rave.portal.service;
+
+import org.apache.rave.portal.model.Widget;
+import org.apache.rave.portal.repository.WidgetRepository;
+import org.apache.rave.portal.service.impl.DefaultWidgetService;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.easymock.EasyMock.*;
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.assertThat;
+
+public class WidgetServiceTest {
+
+    private WidgetService service;
+    private WidgetRepository repository;
+
+    @Before
+    public void setup() {
+        repository = createNiceMock(WidgetRepository.class);
+        service = new DefaultWidgetService(repository);
+    }
+
+    @Test
+    public void getAvailableWidgets() {
+        List<Widget> widgets = new ArrayList<Widget>();
+        expect(repository.getAll()).andReturn(widgets);
+        replay(repository);
+
+        List<Widget> result = service.getAllWidgets();
+        assertThat(result, is(sameInstance(widgets)));
+    }
+
+    @Test
+    public void getWidget() {
+        Widget w = new Widget();
+        expect(repository.getById(1L)).andReturn(w);
+        replay(repository);
+
+        Widget result = service.getWidget(1L);
+        assertThat(result, is(sameInstance(w)));
+
+    }
+
+    @Test
+    public void getWidget_null() {
+        expect(repository.getById(1L)).andReturn(null);
+        replay(repository);
+
+        Widget result = service.getWidget(1L);
+        assertThat(result, is(nullValue()));
+
+    }
+
+}

Modified: incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/util/LocalizationUtilsTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/util/LocalizationUtilsTest.java?rev=1127283&r1=1127282&r2=1127283&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/util/LocalizationUtilsTest.java (original)
+++ incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/util/LocalizationUtilsTest.java Tue May 24 20:58:24 2011
@@ -18,19 +18,15 @@
  */
 package org.apache.rave.portal.util;
 
-import org.junit.Test;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertNotNull;
-
-import org.apache.rave.portal.model.util.LocalizedString;
-import org.apache.rave.portal.util.LocalizationUtils;
-
 import com.ibm.icu.util.GlobalizationPreferences;
 import com.ibm.icu.util.ULocale;
+import org.apache.rave.portal.model.util.LocalizedString;
+import org.junit.Test;
 
 import java.util.ArrayList;
 
+import static org.junit.Assert.*;
+
 public class LocalizationUtilsTest {
 	@Test
 	public void testIsValidLanguageTag() {

Modified: incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/api/rpc/model/RpcOperationTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/api/rpc/model/RpcOperationTest.java?rev=1127283&r1=1127282&r2=1127283&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/api/rpc/model/RpcOperationTest.java (original)
+++ incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/api/rpc/model/RpcOperationTest.java Tue May 24 20:58:24 2011
@@ -21,9 +21,7 @@ package org.apache.rave.portal.web.api.r
 
 import org.junit.Test;
 
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.CoreMatchers.*;
 import static org.junit.Assert.assertThat;
 
 public class RpcOperationTest {

Modified: incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/controller/HomeControllerTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/controller/HomeControllerTest.java?rev=1127283&r1=1127282&r2=1127283&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/controller/HomeControllerTest.java (original)
+++ incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/controller/HomeControllerTest.java Tue May 24 20:58:24 2011
@@ -23,7 +23,6 @@ import org.apache.rave.portal.model.Page
 import org.apache.rave.portal.model.User;
 import org.apache.rave.portal.service.PageService;
 import org.apache.rave.portal.service.UserService;
-import org.apache.rave.portal.service.WidgetService;
 import org.apache.rave.portal.web.util.ModelKeys;
 import org.hamcrest.CoreMatchers;
 import org.junit.Before;

Added: incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/controller/WidgetStoreControllerTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/controller/WidgetStoreControllerTest.java?rev=1127283&view=auto
==============================================================================
--- incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/controller/WidgetStoreControllerTest.java (added)
+++ incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/controller/WidgetStoreControllerTest.java Tue May 24 20:58:24 2011
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 org.apache.rave.portal.web.controller;
+
+import org.apache.rave.portal.model.Widget;
+import org.apache.rave.portal.service.WidgetService;
+import org.apache.rave.portal.web.util.ModelKeys;
+import org.apache.rave.portal.web.util.ViewNames;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.ui.ExtendedModelMap;
+import org.springframework.ui.Model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.easymock.EasyMock.*;
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.assertThat;
+
+public class WidgetStoreControllerTest {
+
+    private WidgetStoreController controller;
+    private WidgetService widgetService;
+
+    @Before
+    public void setup() {
+        widgetService = createNiceMock(WidgetService.class);
+        controller = new WidgetStoreController(widgetService);
+    }
+
+    @Test
+    @SuppressWarnings("unchecked")
+    public void view() {
+        Model model = new ExtendedModelMap();
+        List<Widget> widgets = new ArrayList<Widget>();
+
+        expect(widgetService.getAllWidgets()).andReturn(widgets);
+        replay(widgetService);
+
+        String view = controller.view(model);
+
+        verify(widgetService);
+        assertThat(view, is(equalTo(ViewNames.STORE)));
+        assertThat(model.containsAttribute(ModelKeys.WIDGETS), is(true));
+        assertThat(widgets, is(sameInstance(widgets)));
+    }
+
+    @Test
+    public void viewWidget() {
+        Model model = new ExtendedModelMap();
+        Widget w = new Widget();
+
+        expect(widgetService.getWidget(1L)).andReturn(w);
+        replay(widgetService);
+
+        String view = controller.viewWidget(model, 1L);
+
+        verify(widgetService);
+        assertThat(view, is(equalTo(ViewNames.WIDGET)));
+        assertThat(model.containsAttribute(ModelKeys.WIDGET), is(true));
+        assertThat(((Widget)model.asMap().get(ModelKeys.WIDGET)), is(sameInstance(w)));
+    }
+
+}

Modified: incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/renderer/RenderServiceIntegrationTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/renderer/RenderServiceIntegrationTest.java?rev=1127283&r1=1127282&r2=1127283&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/renderer/RenderServiceIntegrationTest.java (original)
+++ incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/renderer/RenderServiceIntegrationTest.java Tue May 24 20:58:24 2011
@@ -28,9 +28,7 @@ import org.springframework.beans.factory
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.CoreMatchers.*;
 import static org.junit.Assert.assertThat;
 
 @RunWith(SpringJUnit4ClassRunner.class)

Modified: incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/tag/RegionWidgetTagTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/tag/RegionWidgetTagTest.java?rev=1127283&r1=1127282&r2=1127283&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/tag/RegionWidgetTagTest.java (original)
+++ incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/portal/web/tag/RegionWidgetTagTest.java Tue May 24 20:58:24 2011
@@ -30,7 +30,6 @@ import javax.servlet.ServletContext;
 import javax.servlet.jsp.JspException;
 import javax.servlet.jsp.JspWriter;
 import javax.servlet.jsp.PageContext;
-
 import java.io.IOException;
 import java.util.HashSet;
 import java.util.Set;

Modified: incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/provider/opensocial/web/renderer/OpenSocialWidgetRendererTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/provider/opensocial/web/renderer/OpenSocialWidgetRendererTest.java?rev=1127283&r1=1127282&r2=1127283&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/provider/opensocial/web/renderer/OpenSocialWidgetRendererTest.java (original)
+++ incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/provider/opensocial/web/renderer/OpenSocialWidgetRendererTest.java Tue May 24 20:58:24 2011
@@ -20,10 +20,10 @@
 package org.apache.rave.provider.opensocial.web.renderer;
 
 import org.apache.rave.exception.NotSupportedException;
-import org.apache.rave.provider.opensocial.Constants;
 import org.apache.rave.portal.model.RegionWidget;
 import org.apache.rave.portal.model.Widget;
 import org.apache.rave.portal.web.renderer.Renderer;
+import org.apache.rave.provider.opensocial.Constants;
 import org.junit.Before;
 import org.junit.Test;
 

Modified: incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/provider/w3c/web/renderer/W3cWidgetRendererTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/provider/w3c/web/renderer/W3cWidgetRendererTest.java?rev=1127283&r1=1127282&r2=1127283&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/provider/w3c/web/renderer/W3cWidgetRendererTest.java (original)
+++ incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/provider/w3c/web/renderer/W3cWidgetRendererTest.java Tue May 24 20:58:24 2011
@@ -22,10 +22,9 @@ package org.apache.rave.provider.w3c.web
 import org.apache.rave.exception.NotSupportedException;
 import org.apache.rave.portal.model.RegionWidget;
 import org.apache.rave.portal.model.Widget;
-import org.apache.rave.portal.service.WidgetService;
+import org.apache.rave.portal.service.WidgetProviderService;
 import org.apache.rave.portal.web.renderer.Renderer;
 import org.apache.rave.provider.w3c.Constants;
-import org.apache.rave.provider.w3c.web.renderer.W3cWidgetRenderer;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -39,11 +38,11 @@ import static org.junit.Assert.assertTha
 public class W3cWidgetRendererTest {
 
     private Renderer<RegionWidget> renderer;
-    private WidgetService wookieService;
+    private WidgetProviderService wookieService;
 
     @Before
     public void setup() {
-        wookieService = createNiceMock(WidgetService.class);
+        wookieService = createNiceMock(WidgetProviderService.class);
         renderer = new W3cWidgetRenderer(wookieService);
     }
 



Mime
View raw message