Author: adietish
Date: 2011-10-05 17:14:43 -0400 (Wed, 05 Oct 2011)
New Revision: 35393
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.client/src/org/jboss/tools/openshift/express/internal/client/Application.java
trunk/as/plugins/org.jboss.tools.openshift.express.client/src/org/jboss/tools/openshift/express/internal/client/InternalUser.java
trunk/as/plugins/org.jboss.tools.openshift.express.client/src/org/jboss/tools/openshift/express/internal/client/UserInfoAware.java
trunk/as/tests/org.jboss.tools.openshift.express.client.test/src/org/jboss/tools/openshift/express/internal/client/test/ApplicationIntegrationTest.java
Log:
[JBIDE-9854] a new application will now force the user to re-request it's user info
object
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.client/src/org/jboss/tools/openshift/express/internal/client/Application.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.client/src/org/jboss/tools/openshift/express/internal/client/Application.java 2011-10-05
20:59:46 UTC (rev 35392)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.client/src/org/jboss/tools/openshift/express/internal/client/Application.java 2011-10-05
21:14:43 UTC (rev 35393)
@@ -67,7 +67,11 @@
@Override
public Date getCreationTime() throws OpenshiftException {
- return getApplicationInfo().getCreationTime();
+ ApplicationInfo applicationInfo = getApplicationInfo();
+ if (applicationInfo == null) {
+ throw new OpenshiftException("Could not find info for application {0}",
getName());
+ }
+ return applicationInfo.getCreationTime();
}
@Override
@@ -120,7 +124,7 @@
protected IOpenshiftService getService() {
return service;
}
-
+
protected ApplicationInfo getApplicationInfo() throws OpenshiftException {
if (applicationInfo == null) {
this.applicationInfo = getUserInfo().getApplicationInfoByName(getName());
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.client/src/org/jboss/tools/openshift/express/internal/client/InternalUser.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.client/src/org/jboss/tools/openshift/express/internal/client/InternalUser.java 2011-10-05
20:59:46 UTC (rev 35392)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.client/src/org/jboss/tools/openshift/express/internal/client/InternalUser.java 2011-10-05
21:14:43 UTC (rev 35393)
@@ -195,6 +195,11 @@
this.sshKey = key;
}
+ protected UserInfo refreshUserInfo() throws OpenshiftException {
+ this.userInfo = null;
+ return getUserInfo();
+ }
+
protected UserInfo getUserInfo() throws OpenshiftException {
if (userInfo == null) {
this.userInfo = service.getUserInfo(this);
Modified:
trunk/as/plugins/org.jboss.tools.openshift.express.client/src/org/jboss/tools/openshift/express/internal/client/UserInfoAware.java
===================================================================
---
trunk/as/plugins/org.jboss.tools.openshift.express.client/src/org/jboss/tools/openshift/express/internal/client/UserInfoAware.java 2011-10-05
20:59:46 UTC (rev 35392)
+++
trunk/as/plugins/org.jboss.tools.openshift.express.client/src/org/jboss/tools/openshift/express/internal/client/UserInfoAware.java 2011-10-05
21:14:43 UTC (rev 35393)
@@ -23,7 +23,7 @@
protected UserInfo getUserInfo() throws OpenshiftException {
if (userInfo == null) {
- this.userInfo = user.getUserInfo();
+ this.userInfo = user.refreshUserInfo();
}
return userInfo;
}
Modified:
trunk/as/tests/org.jboss.tools.openshift.express.client.test/src/org/jboss/tools/openshift/express/internal/client/test/ApplicationIntegrationTest.java
===================================================================
---
trunk/as/tests/org.jboss.tools.openshift.express.client.test/src/org/jboss/tools/openshift/express/internal/client/test/ApplicationIntegrationTest.java 2011-10-05
20:59:46 UTC (rev 35392)
+++
trunk/as/tests/org.jboss.tools.openshift.express.client.test/src/org/jboss/tools/openshift/express/internal/client/test/ApplicationIntegrationTest.java 2011-10-05
21:14:43 UTC (rev 35393)
@@ -14,7 +14,10 @@
import static
org.jboss.tools.openshift.express.internal.client.test.utils.ApplicationAsserts.assertGitUri;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import java.util.Date;
+
import org.jboss.tools.openshift.express.client.IApplication;
import org.jboss.tools.openshift.express.client.ICartridge;
import org.jboss.tools.openshift.express.client.IOpenshiftService;
@@ -22,6 +25,8 @@
import org.jboss.tools.openshift.express.client.OpenshiftException;
import org.jboss.tools.openshift.express.client.OpenshiftService;
import org.jboss.tools.openshift.express.client.User;
+import org.jboss.tools.openshift.express.internal.client.ApplicationInfo;
+import org.jboss.tools.openshift.express.internal.client.UserInfo;
import org.jboss.tools.openshift.express.internal.client.test.fakes.TestUser;
import org.jboss.tools.openshift.express.internal.client.test.utils.ApplicationUtils;
import org.junit.Before;
@@ -196,4 +201,43 @@
ApplicationUtils.silentlyDestroyAS7Application(applicationName, user, service);
}
}
+
+ @Test
+ public void returnsCreationTime() throws Exception {
+ String applicationName = ApplicationUtils.createRandomApplicationName();
+ try {
+ IApplication application = service.createApplication(applicationName,
ICartridge.JBOSSAS_7, user);
+ Date creationTime = application.getCreationTime();
+ assertNotNull(creationTime);
+ assertTrue(creationTime.compareTo(new Date()) == -1);
+ } finally {
+ ApplicationUtils.silentlyDestroyAS7Application(applicationName, user, service);
+ }
+ }
+
+ /**
+ * This tests checks if the creation time is returned in the 2nd
+ * application. The creation time is only available in the
+ * {@link ApplicationInfo} which is held by the {@link UserInfo}. The
+ * UserInfo is fetched when the 1st application is created and then stored.
+ * The 2nd application has therefore to force the user to refresh the user
+ * info.
+ *
+ * @throws Exception
+ *
+ * @see UserInfo
+ * @see ApplicationInfo
+ */
+ @Test
+ public void returnsCreationTimeOn2ndApplication() throws Exception {
+ String applicationName = ApplicationUtils.createRandomApplicationName();
+ try {
+ IApplication application = service.createApplication(applicationName,
ICartridge.JBOSSAS_7, user);
+ Date creationTime = application.getCreationTime();
+ assertNotNull(creationTime);
+ assertTrue(creationTime.compareTo(new Date()) == -1);
+ } finally {
+ ApplicationUtils.silentlyDestroyAS7Application(applicationName, user, service);
+ }
+ }
}
Show replies by date