From 312692c163ffcb74a568072775b987e0d0c5a4bf Mon Sep 17 00:00:00 2001 From: Massimiliano Assante Date: Sat, 22 Mar 2014 18:03:30 +0000 Subject: [PATCH] added test case to avoidsthat you release using a fake development user when session expires git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/share-updates@93472 82a268e6-3cf1-43bd-a215-b396298e98cf --- pom.xml | 2 +- .../server/ShareUpdateServiceImpl.java | 18 ++++++------------ .../user/shareupdates/test/TestForDeploy.java | 19 +++++++++++++++++++ 3 files changed, 26 insertions(+), 13 deletions(-) create mode 100644 src/test/java/org/gcube/portlets/user/shareupdates/test/TestForDeploy.java diff --git a/pom.xml b/pom.xml index 8212263..7b78946 100644 --- a/pom.xml +++ b/pom.xml @@ -245,7 +245,7 @@ - Messages.html + ShareUpdates.html ${webappDirectory} diff --git a/src/main/java/org/gcube/portlets/user/shareupdates/server/ShareUpdateServiceImpl.java b/src/main/java/org/gcube/portlets/user/shareupdates/server/ShareUpdateServiceImpl.java index 217fa2b..aa2871d 100644 --- a/src/main/java/org/gcube/portlets/user/shareupdates/server/ShareUpdateServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/shareupdates/server/ShareUpdateServiceImpl.java @@ -1,12 +1,9 @@ package org.gcube.portlets.user.shareupdates.server; import java.io.BufferedReader; -import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; -import java.io.InputStream; import java.io.InputStreamReader; -import java.io.Reader; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; @@ -34,11 +31,6 @@ import org.gcube.application.framework.core.session.SessionManager; import org.gcube.applicationsupportlayer.social.ApplicationNotificationsManager; import org.gcube.applicationsupportlayer.social.NotificationsManager; import org.gcube.applicationsupportlayer.social.storage.UriResolverReaderParameter; -import org.gcube.common.homelibrary.home.HomeLibrary; -import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException; -import org.gcube.common.homelibrary.home.exceptions.InternalErrorException; -import org.gcube.common.homelibrary.home.workspace.Workspace; -import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException; import org.gcube.common.portal.PortalContext; import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.impl.ScopeBean; @@ -62,7 +54,6 @@ import org.gcube.portlets.user.shareupdates.client.ShareUpdateService; import org.gcube.portlets.user.shareupdates.client.view.ShareUpdateForm; import org.gcube.portlets.user.shareupdates.server.metaseeker.MetaSeeker; import org.gcube.portlets.user.shareupdates.server.opengraph.OpenGraph; -import org.gcube.portlets.user.shareupdates.server.opengraph.OpenGraphNamespace; import org.gcube.portlets.user.shareupdates.shared.LinkPreview; import org.gcube.portlets.user.shareupdates.shared.UserSettings; import org.gcube.portlets.widgets.pickuser.shared.PickingUser; @@ -141,8 +132,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar String user = (String) this.getThreadLocalRequest().getSession().getAttribute(ScopeHelper.USERNAME_ATTRIBUTE); if (user == null) { _log.warn("USER IS NULL setting test.user and Running OUTSIDE PORTAL"); - user = "test.user"; - user = "massimiliano.assante"; + user = getDevelopmentUser(); SessionManager.getInstance().getASLSession(sessionID, user).setScope("/gcube/devsec/devVRE"); withinPortal = false; } @@ -151,7 +141,11 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar } return SessionManager.getInstance().getASLSession(sessionID, user); } - + public String getDevelopmentUser() { + String user = "test.user"; + //user = "massimiliano.assante"; + return user; + } /** * diff --git a/src/test/java/org/gcube/portlets/user/shareupdates/test/TestForDeploy.java b/src/test/java/org/gcube/portlets/user/shareupdates/test/TestForDeploy.java new file mode 100644 index 0000000..0aded86 --- /dev/null +++ b/src/test/java/org/gcube/portlets/user/shareupdates/test/TestForDeploy.java @@ -0,0 +1,19 @@ +package org.gcube.portlets.user.shareupdates.test; + +import static org.junit.Assert.*; + +import org.gcube.portlets.user.shareupdates.server.ShareUpdateServiceImpl; +import org.junit.Test; + +public class TestForDeploy { + + @Test + public void testUserIsTestUser() { + ShareUpdateServiceImpl serviceImpl = new ShareUpdateServiceImpl(); + String username = serviceImpl.getDevelopmentUser(); + System.out.println("username for deploy is: " + username); + assertTrue(username.compareTo("test.user") == 0); + System.out.println("Test OK!"); + } + +}