JBoss Tools SVN: r34998 - in trunk/as: plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal and 4 other directories.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-09-23 09:38:47 -0400 (Fri, 23 Sep 2011)
New Revision: 34998
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/ApplicationInfo.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/IUser.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/CartridgeTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/UserTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/fakes/CartridgeResponseFake.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/utils/ApplicationInfoAsserts.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/Application.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/ApplicationLogReader.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/Cartridge.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/Domain.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/IOpenshiftService.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/ISSHPublicKey.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/SSHKeyPair.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/SSHPublicKey.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/User.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/UserInfo.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/OpenshiftService.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/response/ApplicationResponseUnmarshaller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/response/DomainResponseUnmarshaller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/response/UserInfoResponseUnmarshaller.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ApplicationIntegrationTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ApplicationTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/CartridgesIntegrationTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/DomainIntegrationTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/DomainTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ListCartridgesIntegrationTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/OpenshiftTestSuite.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/UserInfoIntegrationTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/UserInfoTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/fakes/ApplicationResponseFake.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/fakes/NoopOpenshiftServiceFake.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/fakes/UserInfoResponseFake.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/utils/ApplicationAsserts.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/utils/CartridgeAsserts.java
Log:
[JBIDE-9591] implementing Application#getGitUri:
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/Application.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/Application.java 2011-09-23 13:26:18 UTC (rev 34997)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/Application.java 2011-09-23 13:38:47 UTC (rev 34998)
@@ -32,12 +32,8 @@
private User user;
- private boolean userInfoQueried;
-
- public Application(String name, Cartridge cartridge, IOpenshiftService service) {
- this(name, null, cartridge, null, null, null, service);
-
- this.userInfoQueried = false;
+ public Application(String name, Cartridge cartridge, User user, IOpenshiftService service) {
+ this(name, null, cartridge, null, null, user, service);
}
public Application(String name, String uuid, Cartridge cartridge, String embedded, Date creationTime, User user,
@@ -49,8 +45,6 @@
this.creationTime = creationTime;
this.user = user;
this.service = service;
-
- this.userInfoQueried = true;
}
public String getName() {
@@ -58,7 +52,7 @@
}
public String getUUID() throws OpenshiftException {
- updateFromUserInfoIfNeeded();
+ user.loadLazyValues();
return uuid;
}
@@ -67,39 +61,38 @@
}
public String getEmbedded() throws OpenshiftException {
- updateFromUserInfoIfNeeded();
+ user.loadLazyValues();
return embedded;
}
public Date getCreationTime() throws OpenshiftException {
- updateFromUserInfoIfNeeded();
+ user.loadLazyValues();
return creationTime;
}
- protected User getUser() throws OpenshiftException {
- updateFromUserInfoIfNeeded();
+ protected IUser getUser() throws OpenshiftException {
return user;
}
public void destroy() throws OpenshiftException {
- service.destroyApplication(name, cartridge);
+ service.destroyApplication(name, cartridge, user);
}
public void start() throws OpenshiftException {
- service.startApplication(name, cartridge);
+ service.startApplication(name, cartridge, user);
}
public void restart() throws OpenshiftException {
- service.restartApplication(name, cartridge);
+ service.restartApplication(name, cartridge, user);
}
public void stop() throws OpenshiftException {
- service.stopApplication(name, cartridge);
+ service.stopApplication(name, cartridge, user);
}
public ApplicationLogReader getLog() throws OpenshiftException {
if (logReader == null) {
- this.logReader = new ApplicationLogReader(this, service);
+ this.logReader = new ApplicationLogReader(this, user, service);
}
return logReader;
}
@@ -120,24 +113,39 @@
return Assert.assertNotNull(getUser()).getDomain();
}
- private void updateFromUserInfoIfNeeded() throws OpenshiftException {
- if (!userInfoQueried) {
- updateFrom(service.getUserInfo());
- this.userInfoQueried = true;
+ void update(ApplicationInfo applicationInfo) {
+ if (applicationInfo == null) {
+ return;
}
+ this.cartridge = applicationInfo.getCartridge();
+ this.creationTime = applicationInfo.getCreationTime();
+ this.name = applicationInfo.getName();
+ this.uuid = applicationInfo.getUuid();
}
-
- private void updateFrom(UserInfo userInfo) {
- updateFrom(userInfo.getApplicationByName(getName()));
- this.user = userInfo.getUser();
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
}
- private void updateFrom(Application application) {
- this.cartridge = application.cartridge;
- this.creationTime = application.creationTime;
- this.name = application.name;
- this.uuid = application.uuid;
-
- this.userInfoQueried = false;
+ @Override
+ public boolean equals(Object object) {
+ if (this == object)
+ return true;
+ if (object == null)
+ return false;
+ if (getClass() != object.getClass())
+ return false;
+ Application other = (Application) object;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ return true;
}
+
}
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/ApplicationInfo.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/ApplicationInfo.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/ApplicationInfo.java 2011-09-23 13:38:47 UTC (rev 34998)
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.openshift.core;
+
+import java.util.Date;
+
+/**
+ * @author André Dietisheim
+ */
+public class ApplicationInfo {
+
+ private String name;
+ private String uuid;
+ private String embedded;
+ private Cartridge cartridge;
+ private Date creationTime;
+
+ public ApplicationInfo(String name, String uuid, String embedded, Cartridge cartridge, Date creationTime) {
+ this.name = name;
+ this.uuid = uuid;
+ this.embedded = embedded;
+ this.cartridge = cartridge;
+ this.creationTime = creationTime;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getEmbedded() {
+ return embedded;
+ }
+
+ public String getUuid() {
+ return uuid;
+ }
+
+ public Cartridge getCartridge() {
+ return cartridge;
+ }
+
+ public Date getCreationTime() {
+ return creationTime;
+ }
+
+}
Property changes on: trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/ApplicationInfo.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/ApplicationLogReader.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/ApplicationLogReader.java 2011-09-23 13:26:18 UTC (rev 34997)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/ApplicationLogReader.java 2011-09-23 13:38:47 UTC (rev 34998)
@@ -33,8 +33,11 @@
private Application application;
private int logIndex = 0;
- public ApplicationLogReader(Application application, IOpenshiftService service) {
+ private User user;
+
+ public ApplicationLogReader(Application application, User user, IOpenshiftService service) {
this.application = application;
+ this.user = user;
this.service = service;
}
@@ -68,7 +71,7 @@
protected String requestStatus() throws IOException {
try {
- return service.getStatus(application.getName(), application.getCartridge());
+ return service.getStatus(application.getName(), application.getCartridge(), user);
} catch (OpenshiftException e) {
throw new IOException(e);
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/Cartridge.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/Cartridge.java 2011-09-23 13:26:18 UTC (rev 34997)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/Cartridge.java 2011-09-23 13:38:47 UTC (rev 34998)
@@ -7,17 +7,19 @@
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.ide.eclipse.as.openshift.core;
-
/**
+ * CA cartridge that is available on the openshift server. This class is no enum
+ * since we dont know all available types and they may change at any time.
+ *
* @author André Dietisheim
*/
public class Cartridge {
public static final Cartridge JBOSSAS_7 = new Cartridge("jbossas-7.0");
-
+
private String name;
public Cartridge(String name) {
@@ -27,4 +29,11 @@
public String getName() {
return name;
}
+
+ public static Cartridge valueOf(String name) {
+ if (JBOSSAS_7.getName().equals(name)) {
+ return JBOSSAS_7;
+ }
+ return null;
+ }
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/Domain.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/Domain.java 2011-09-23 13:26:18 UTC (rev 34997)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/Domain.java 2011-09-23 13:38:47 UTC (rev 34998)
@@ -18,21 +18,29 @@
private String namespace;
private String rhcDomain;
+ private User user;
- public Domain(String namespace) {
- this(namespace, null);
+ public Domain(String namespace, User user) {
+ this(namespace, null, user);
}
- public Domain(String namespace, String rhcDomain) {
+ public Domain(String namespace, String rhcDomain, User user) {
this.namespace = namespace;
this.rhcDomain = rhcDomain;
+ this.user = user;
}
- public String getRhcDomain() {
+ public String getNamespace() throws OpenshiftException {
+ return namespace;
+ }
+
+ public String getRhcDomain() throws OpenshiftException {
+ user.loadLazyValues();
return rhcDomain;
}
- public String getNamespace() {
- return namespace;
+ void update(UserInfo userInfo) {
+ this.rhcDomain = userInfo.getRhcDomain();
+ this.namespace = userInfo.getNamespace();
}
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/IOpenshiftService.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/IOpenshiftService.java 2011-09-23 13:26:18 UTC (rev 34997)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/IOpenshiftService.java 2011-09-23 13:38:47 UTC (rev 34998)
@@ -17,27 +17,23 @@
*/
public interface IOpenshiftService {
- public UserInfo getUserInfo() throws OpenshiftException;
+ public UserInfo getUserInfo(User user) throws OpenshiftException;
- public List<Cartridge> getCartridges() throws OpenshiftException;
+ public List<Cartridge> getCartridges(User user) throws OpenshiftException;
- public Application createApplication(String name, Cartridge cartridge) throws OpenshiftException;
+ public Application createApplication(String name, Cartridge cartridge, User user) throws OpenshiftException;
- public Application destroyApplication(String name, Cartridge cartridge) throws OpenshiftException;
+ public Application destroyApplication(String name, Cartridge cartridge, User user) throws OpenshiftException;
- public Application startApplication(String name, Cartridge cartridge) throws OpenshiftException;
+ public Application startApplication(String name, Cartridge cartridge, User user) throws OpenshiftException;
- public Application restartApplication(String name, Cartridge cartridge) throws OpenshiftException;
+ public Application restartApplication(String name, Cartridge cartridge, User user) throws OpenshiftException;
- public Application stopApplication(String name, Cartridge cartridge) throws OpenshiftException;
+ public Application stopApplication(String name, Cartridge cartridge, User user) throws OpenshiftException;
- public String getStatus(String name, Cartridge cartridge) throws OpenshiftException;
+ public String getStatus(String name, Cartridge cartridge, User user) throws OpenshiftException;
- public Domain changeDomain(String domainName, ISSHPublicKey sshKey) throws OpenshiftException;
+ public Domain changeDomain(String name, ISSHPublicKey sshKey, User user) throws OpenshiftException;
- public Domain createDomain(String name, ISSHPublicKey sshKey) throws OpenshiftException;
-
- public SSHKeyPair createKey(String passPhrase, String privateKeyPath, String publicKeyPath) throws OpenshiftException;
-
- public SSHKeyPair loadKey(String privateKeyPath, String publicKeyPath) throws OpenshiftException;
+ public Domain createDomain(String name, ISSHPublicKey sshKey, User user) throws OpenshiftException;
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/ISSHPublicKey.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/ISSHPublicKey.java 2011-09-23 13:26:18 UTC (rev 34997)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/ISSHPublicKey.java 2011-09-23 13:38:47 UTC (rev 34998)
@@ -23,6 +23,7 @@
* comment)
* @throws OpenshiftException
*/
- public String getPublicKey() throws OpenshiftException;
-
+ public String getPublicKey() throws OpenshiftException ;
+
+ public void update(ISSHPublicKey sshPublicKey) throws OpenshiftException;
}
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/IUser.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/IUser.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/IUser.java 2011-09-23 13:38:47 UTC (rev 34998)
@@ -0,0 +1,19 @@
+package org.jboss.ide.eclipse.as.openshift.core;
+
+import java.util.Collection;
+
+public interface IUser {
+
+ public abstract String getRhlogin();
+
+ public abstract String getPassword();
+
+ public abstract Domain getDomain() throws OpenshiftException;
+
+ public abstract ISSHPublicKey getSshKey() throws OpenshiftException;
+
+ public abstract Collection<Cartridge> getCartridges() throws OpenshiftException;
+
+ public abstract Collection<Application> getApplications() throws OpenshiftException;
+
+}
\ No newline at end of file
Property changes on: trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/IUser.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/SSHKeyPair.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/SSHKeyPair.java 2011-09-23 13:26:18 UTC (rev 34997)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/SSHKeyPair.java 2011-09-23 13:38:47 UTC (rev 34998)
@@ -101,4 +101,10 @@
return publicKeyPath;
}
+ @Override
+ public void update(ISSHPublicKey sshPublicKey) {
+ // do nothing, there's no sense to update this key since the public key
+ // misses the private key
+ }
+
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/SSHPublicKey.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/SSHPublicKey.java 2011-09-23 13:26:18 UTC (rev 34997)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/SSHPublicKey.java 2011-09-23 13:38:47 UTC (rev 34998)
@@ -21,7 +21,14 @@
this.publicKey = publicKey;
}
- public String getPublicKey() throws OpenshiftException {
+ public String getPublicKey() {
return publicKey;
}
+
+ void update(String publicKey) {
+ }
+
+ public void update(ISSHPublicKey sshPublicKey) throws OpenshiftException {
+ this.publicKey = sshPublicKey.getPublicKey();
+ }
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/User.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/User.java 2011-09-23 13:26:18 UTC (rev 34997)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/User.java 2011-09-23 13:38:47 UTC (rev 34998)
@@ -7,39 +7,169 @@
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.ide.eclipse.as.openshift.core;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.ide.eclipse.as.openshift.core.internal.OpenshiftService;
+
/**
* @author André Dietisheim
*/
-public class User {
+public class User implements IUser {
private String rhlogin;
+ private String password;
private String uuid;
private ISSHPublicKey sshKey;
private Domain domain;
+ private UserInfo userInfo;
+ private List<Cartridge> cartridges;
+ private List<Application> applications = new ArrayList<Application>();
- public User(String rhlogin, String uuid, ISSHPublicKey sshKey, Domain domain) {
+ private OpenshiftService service;
+
+ public User(String rhlogin, String password) {
+ this(rhlogin, password, (ISSHPublicKey) null, new OpenshiftService());
+ }
+
+ public User(String rhlogin, String password, OpenshiftService service) {
+ this(rhlogin, password, (ISSHPublicKey) null, service);
+ }
+
+ public User(String rhlogin, String password, ISSHPublicKey sshKey, OpenshiftService service) {
this.rhlogin = rhlogin;
- this.uuid = uuid;
+ this.password = password;
this.sshKey = sshKey;
- this.domain = domain;
+ this.service = service;
}
-
- public Domain getDomain() {
+
+ @Override
+ public Domain getDomain() throws OpenshiftException {
+ loadLazyValues();
return domain;
}
- public ISSHPublicKey getSshKey() {
+ @Override
+ public ISSHPublicKey getSshKey() throws OpenshiftException {
+ loadLazyValues();
return sshKey;
}
+ @Override
public String getRhlogin() {
return rhlogin;
}
- public String getUuid() {
+ @Override
+ public String getPassword() {
+ return password;
+ }
+
+ public String getUUID() throws OpenshiftException {
+ loadLazyValues();
return uuid;
}
+
+ @Override
+ public List<Cartridge> getCartridges() throws OpenshiftException {
+ if (cartridges == null) {
+ this.cartridges = service.getCartridges(this);
+ }
+ return Collections.unmodifiableList(cartridges);
+ }
+
+ @Override
+ public Collection<Application> getApplications() throws OpenshiftException {
+ loadLazyValues();
+ return Collections.unmodifiableList(applications);
+ }
+
+ public Application getApplicationByName(String name) throws OpenshiftException {
+ loadLazyValues();
+ return getApplicationByName(name, applications);
+ }
+
+ private Application getApplicationByName(String name, Collection<Application> applications) {
+ Application matchingApplication = null;
+ for (Application application : applications) {
+ if (name.equals(application.getName())) {
+ matchingApplication = application;
+ }
+ }
+ return matchingApplication;
+ }
+
+ public void add(Application application) {
+ applications.add(application);
+ }
+
+ /**
+ * Loads the lazy values from the server if needed. Updates itself all
+ * referenced objects (applications, domain).
+ *
+ * @throws OpenshiftException
+ * if an error occurred while loading the values
+ */
+ void loadLazyValues() throws OpenshiftException {
+ if (userInfo == null) {
+ refresh();
+ }
+ }
+
+ public void refresh() throws OpenshiftException {
+ this.userInfo = service.getUserInfo(this);
+ update(userInfo);
+ }
+
+ private void update(UserInfo userInfo) throws OpenshiftException {
+ this.uuid = userInfo.getUuid();
+ updateDomain(userInfo);
+ updateSshPublicKey(userInfo);
+ update(userInfo.getApplicationInfos());
+ }
+
+ private void updateDomain(UserInfo userInfo) {
+ if (domain == null) {
+ this.domain = new Domain(userInfo.getNamespace(), userInfo.getRhcDomain(), this);
+ } else {
+ domain.update(userInfo);
+ }
+ }
+
+ private void updateSshPublicKey(UserInfo userInfo) throws OpenshiftException {
+ if (sshKey == null) {
+ sshKey = userInfo.getSshPublicKey();
+ } else {
+ sshKey.update(userInfo.getSshPublicKey());
+ }
+ }
+
+ private void update(List<ApplicationInfo> applicationInfos) {
+ for (ApplicationInfo applicationInfo : applicationInfos) {
+ Application application = getApplicationByName(applicationInfo.getName(), applications);
+ if (application != null) {
+ application.update(applicationInfo);
+ } else {
+ applications.add(createApplication(applicationInfo));
+ }
+ }
+ }
+
+ private Application createApplication(ApplicationInfo applicationInfo) {
+ return new Application(applicationInfo.getName()
+ , applicationInfo.getUuid()
+ , applicationInfo.getCartridge()
+ , applicationInfo.getEmbedded()
+ , applicationInfo.getCreationTime()
+ , this, service);
+ }
+
+ public void setSshPublicKey(ISSHPublicKey key) {
+ this.sshKey = key;
+ }
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/UserInfo.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/UserInfo.java 2011-09-23 13:26:18 UTC (rev 34997)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/UserInfo.java 2011-09-23 13:38:47 UTC (rev 34998)
@@ -17,31 +17,55 @@
*/
public class UserInfo {
- private User user;
- private List<Application> applications;
+ private String rhLogin;
+ private String uuid;
+ private SSHPublicKey sshPublicKey;
+ private String rhcDomain;
+ private String namespace;
+ private List<ApplicationInfo> applicationInfos;
- public UserInfo(User user, List<Application> applications) {
- this.user = user;
- this.applications = applications;
+ public UserInfo(String rhLogin, String uuid, String sshPublicKey, String rhcDomain, String namespace, List<ApplicationInfo> applicationInfos) {
+ this.rhLogin = rhLogin;
+ this.uuid = uuid;
+ this.sshPublicKey = new SSHPublicKey(sshPublicKey);
+ this.rhcDomain = rhcDomain;
+ this.namespace = namespace;
+ this.applicationInfos = applicationInfos;
}
- public User getUser() {
- return user;
+ public String getUuid() {
+ return uuid;
}
- public List<Application> getApplications() {
- return applications;
+ public SSHPublicKey getSshPublicKey() {
+ return sshPublicKey;
}
- public Application getApplicationByName(String applicationName) {
- Application matchingApplication = null;
- for (Application application : applications) {
- if (applicationName.equals(application.getName())) {
- matchingApplication = application;
+ public String getRhLogin() {
+ return rhLogin;
+ }
+
+ public String getNamespace() {
+ return namespace;
+ }
+
+ public List<ApplicationInfo> getApplicationInfos() {
+ return applicationInfos;
+ }
+
+ public ApplicationInfo getApplicationInfoByName(String name) {
+ ApplicationInfo matchingApplicationInfo = null;
+ for (ApplicationInfo applicationInfo : applicationInfos) {
+ if (name.equals(applicationInfo.getName())) {
+ matchingApplicationInfo = applicationInfo;
break;
}
}
- return matchingApplication;
+ return matchingApplicationInfo;
}
+
+ public String getRhcDomain() {
+ return rhcDomain;
+ }
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/OpenshiftService.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/OpenshiftService.java 2011-09-23 13:26:18 UTC (rev 34997)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/OpenshiftService.java 2011-09-23 13:38:47 UTC (rev 34998)
@@ -12,6 +12,7 @@
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.Collection;
import java.util.List;
import org.jboss.ide.eclipse.as.openshift.core.Application;
@@ -23,7 +24,7 @@
import org.jboss.ide.eclipse.as.openshift.core.InvalidCredentialsOpenshiftException;
import org.jboss.ide.eclipse.as.openshift.core.OpenshiftEndpointException;
import org.jboss.ide.eclipse.as.openshift.core.OpenshiftException;
-import org.jboss.ide.eclipse.as.openshift.core.SSHKeyPair;
+import org.jboss.ide.eclipse.as.openshift.core.User;
import org.jboss.ide.eclipse.as.openshift.core.UserInfo;
import org.jboss.ide.eclipse.as.openshift.core.internal.httpclient.HttpClientException;
import org.jboss.ide.eclipse.as.openshift.core.internal.httpclient.UnauthorizedException;
@@ -55,48 +56,36 @@
private static final String BASE_URL = "https://openshift.redhat.com/broker";
- private String username;
- private String password;
-
- public OpenshiftService(String username, String password) {
- this.username = username;
- this.password = password;
- }
-
- public UserInfo getUserInfo() throws OpenshiftException {
- UserInfoRequest request = new UserInfoRequest(username, true);
+ public UserInfo getUserInfo(User user) throws OpenshiftException {
+ UserInfoRequest request = new UserInfoRequest(user.getRhlogin(), true);
String url = request.getUrlString(BASE_URL);
try {
String requestString = new UserInfoRequestJsonMarshaller().marshall(request);
- String openShiftRequestString = new OpenshiftEnvelopeFactory(password, requestString).createString();
+ String openShiftRequestString = new OpenshiftEnvelopeFactory(user.getPassword(), requestString)
+ .createString();
String responseString = createHttpClient(url).post(openShiftRequestString);
responseString = JsonSanitizer.sanitize(responseString);
OpenshiftResponse<UserInfo> response =
- new UserInfoResponseUnmarshaller(this).unmarshall(responseString);
+ new UserInfoResponseUnmarshaller().unmarshall(responseString);
return response.getOpenshiftObject();
} catch (MalformedURLException e) {
throw new OpenshiftEndpointException(
- url, e, "Could not get user info for user \"{0}\" at \"{1}\"", username, url, e);
+ url, e, "Could not get user info for user \"{0}\" at \"{1}\"", user.getRhlogin(), url, e);
} catch (HttpClientException e) {
throw new OpenshiftEndpointException(
- url, e, "Could not get user info for user \"{0}\" at \"{1}\"", username, url, e);
+ url, e, "Could not get user info for user \"{0}\" at \"{1}\"", user.getRhlogin(), url, e);
}
}
- /**
- * WARNING: the current server implementation returns invalid json.
- *
- * @see ListCartridgesResponseUnmarshaller
- * @see JsonSanitizer#sanitize(String)
- */
@Override
- public List<Cartridge> getCartridges() throws OpenshiftException {
- ListCartridgesRequest listCartridgesRequest = new ListCartridgesRequest(username, true);
+ public List<Cartridge> getCartridges(User user) throws OpenshiftException {
+ ListCartridgesRequest listCartridgesRequest = new ListCartridgesRequest(user.getRhlogin(), true);
String url = listCartridgesRequest.getUrlString(BASE_URL);
try {
String listCartridgesRequestString =
new ListCartridgesRequestJsonMarshaller().marshall(listCartridgesRequest);
- String request = new OpenshiftEnvelopeFactory(password, listCartridgesRequestString).createString();
+ String request = new OpenshiftEnvelopeFactory(user.getPassword(), listCartridgesRequestString)
+ .createString();
String listCatridgesReponse = createHttpClient(url).post(request);
listCatridgesReponse = JsonSanitizer.sanitize(listCatridgesReponse);
OpenshiftResponse<List<Cartridge>> response =
@@ -110,37 +99,27 @@
}
@Override
- public SSHKeyPair createKey(String passPhrase, String privateKeyPath, String publicKeyPath) throws OpenshiftException {
- return SSHKeyPair.create(passPhrase, privateKeyPath, publicKeyPath);
+ public Domain createDomain(String name, ISSHPublicKey sshKey, User user) throws OpenshiftException {
+ return requestDomainAction(new CreateDomainRequest(name, sshKey, user.getRhlogin(), true), user);
}
@Override
- public SSHKeyPair loadKey(String privateKeyPath, String publicKeyPath) throws OpenshiftException {
- return SSHKeyPair.load(privateKeyPath, publicKeyPath);
+ public Domain changeDomain(String newName, ISSHPublicKey sshKey, User user) throws OpenshiftException {
+ return requestDomainAction(new ChangeDomainRequest(newName, sshKey, user.getRhlogin(), true), user);
}
- @Override
- public Domain createDomain(String name, ISSHPublicKey sshKey) throws OpenshiftException {
- return requestDomainAction(new CreateDomainRequest(name, sshKey, username, true));
- }
-
- @Override
- public Domain changeDomain(String newName, ISSHPublicKey sshKey) throws OpenshiftException {
- return requestDomainAction(new ChangeDomainRequest(newName, sshKey, username, true));
- }
-
- protected Domain requestDomainAction(AbstractDomainRequest request) throws OpenshiftException {
+ protected Domain requestDomainAction(AbstractDomainRequest request, User user) throws OpenshiftException {
String url = request.getUrlString(BASE_URL);
try {
String requestString =
new OpenshiftEnvelopeFactory(
- password,
+ user.getPassword(),
new DomainRequestJsonMarshaller().marshall(request))
.createString();
String responseString = createHttpClient(url).post(requestString);
responseString = JsonSanitizer.sanitize(responseString);
OpenshiftResponse<Domain> response =
- new DomainResponseUnmarshaller(request.getName()).unmarshall(responseString);
+ new DomainResponseUnmarshaller(request.getName(), user).unmarshall(responseString);
return response.getOpenshiftObject();
} catch (MalformedURLException e) {
throw new OpenshiftEndpointException(url, e, "Could not list available cartridges at \"{0}\"", url);
@@ -150,31 +129,33 @@
}
@Override
- public Application createApplication(String name, Cartridge cartridge) throws OpenshiftException {
- return requestApplicationAction(new ApplicationRequest(name, cartridge, ApplicationAction.CONFIGURE, username,
- true));
+ public Application createApplication(String name, Cartridge cartridge, User user) throws OpenshiftException {
+ return requestApplicationAction(new ApplicationRequest(name, cartridge, ApplicationAction.CONFIGURE,
+ user.getRhlogin(), true), user);
}
@Override
- public Application destroyApplication(String name, Cartridge cartridge) throws OpenshiftException {
+ public Application destroyApplication(String name, Cartridge cartridge, User user) throws OpenshiftException {
return requestApplicationAction(new ApplicationRequest(name, cartridge, ApplicationAction.DECONFIGURE,
- username, true));
+ user.getRhlogin(), true), user);
}
@Override
- public Application startApplication(String name, Cartridge cartridge) throws OpenshiftException {
- return requestApplicationAction(new ApplicationRequest(name, cartridge, ApplicationAction.START, username, true));
+ public Application startApplication(String name, Cartridge cartridge, User user) throws OpenshiftException {
+ return requestApplicationAction(new ApplicationRequest(name, cartridge, ApplicationAction.START,
+ user.getRhlogin(), true), user);
}
@Override
- public Application restartApplication(String name, Cartridge cartridge) throws OpenshiftException {
- return requestApplicationAction(new ApplicationRequest(name, cartridge, ApplicationAction.RESTART, username,
- true));
+ public Application restartApplication(String name, Cartridge cartridge, User user) throws OpenshiftException {
+ return requestApplicationAction(new ApplicationRequest(name, cartridge, ApplicationAction.RESTART,
+ user.getRhlogin(), true), user);
}
@Override
- public Application stopApplication(String name, Cartridge cartridge) throws OpenshiftException {
- return requestApplicationAction(new ApplicationRequest(name, cartridge, ApplicationAction.STOP, username, true));
+ public Application stopApplication(String name, Cartridge cartridge, User user) throws OpenshiftException {
+ return requestApplicationAction(new ApplicationRequest(name, cartridge, ApplicationAction.STOP,
+ user.getRhlogin(), true), user);
}
/**
@@ -189,14 +170,14 @@
* ,"app_name","api"],"exit_code":0}
*/
@Override
- public String getStatus(String applicationName, Cartridge cartridge) throws OpenshiftException {
- ApplicationRequest applicationRequest =
- new ApplicationRequest(applicationName, cartridge, ApplicationAction.STATUS, username, true);
+ public String getStatus(String applicationName, Cartridge cartridge, User user) throws OpenshiftException {
+ ApplicationRequest applicationRequest =
+ new ApplicationRequest(applicationName, cartridge, ApplicationAction.STATUS, user.getRhlogin(), true);
String url = applicationRequest.getUrlString(BASE_URL);
try {
String applicationRequestString =
new ApplicationRequestJsonMarshaller().marshall(applicationRequest);
- String request = new OpenshiftEnvelopeFactory(password, applicationRequestString).createString();
+ String request = new OpenshiftEnvelopeFactory(user.getPassword(), applicationRequestString).createString();
String response = createHttpClient(url).post(request);
response = JsonSanitizer.sanitize(response);
@@ -211,8 +192,8 @@
throw new InvalidCredentialsOpenshiftException(
url, e,
"Could not {0} application \"{1}\" at \"{2}\": Invalid credentials user \"{3}\", password \"{4}\"",
- applicationRequest.getAction().toHumanReadable(), applicationRequest.getName(), url, username,
- password);
+ applicationRequest.getAction().toHumanReadable(), applicationRequest.getName(), url,
+ user.getRhlogin(), user.getPassword());
} catch (HttpClientException e) {
throw new OpenshiftEndpointException(
url, e, "Could not {0} application \"{1}\" at \"{2}\"",
@@ -220,18 +201,19 @@
}
}
- protected Application requestApplicationAction(ApplicationRequest applicationRequest) throws OpenshiftException {
+ protected Application requestApplicationAction(ApplicationRequest applicationRequest, User user)
+ throws OpenshiftException {
String url = applicationRequest.getUrlString(BASE_URL);
try {
String applicationRequestString =
new ApplicationRequestJsonMarshaller().marshall(applicationRequest);
- String request = new OpenshiftEnvelopeFactory(password, applicationRequestString).createString();
+ String request = new OpenshiftEnvelopeFactory(user.getPassword(), applicationRequestString).createString();
String response = createHttpClient(url).post(request);
response = JsonSanitizer.sanitize(response);
OpenshiftResponse<Application> openshiftResponse =
new ApplicationResponseUnmarshaller(applicationRequest.getName(),
- applicationRequest.getCartridge(), this).unmarshall(response);
+ applicationRequest.getCartridge(), user, this).unmarshall(response);
return openshiftResponse.getOpenshiftObject();
} catch (MalformedURLException e) {
throw new OpenshiftException(
@@ -241,8 +223,9 @@
throw new InvalidCredentialsOpenshiftException(
url, e,
"Could not {0} application \"{1}\" at \"{2}\": Invalid credentials user \"{3}\", password \"{4}\"",
- applicationRequest.getAction().toHumanReadable(), applicationRequest.getName(), url, username,
- password);
+ applicationRequest.getAction().toHumanReadable(), applicationRequest.getName(), url,
+ user.getRhlogin(),
+ user.getPassword());
} catch (HttpClientException e) {
throw new OpenshiftEndpointException(
url, e, "Could not {0} application \"{1}\" at \"{2}\"",
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/response/ApplicationResponseUnmarshaller.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/response/ApplicationResponseUnmarshaller.java 2011-09-23 13:26:18 UTC (rev 34997)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/response/ApplicationResponseUnmarshaller.java 2011-09-23 13:38:47 UTC (rev 34998)
@@ -14,24 +14,27 @@
import org.jboss.ide.eclipse.as.openshift.core.Application;
import org.jboss.ide.eclipse.as.openshift.core.Cartridge;
import org.jboss.ide.eclipse.as.openshift.core.IOpenshiftService;
+import org.jboss.ide.eclipse.as.openshift.core.User;
/**
* @author André Dietisheim
*/
public class ApplicationResponseUnmarshaller extends AbstractOpenshiftJsonResponseUnmarshaller<Application> {
+ private User user;
private String applicationName;
private Cartridge cartridge;
private IOpenshiftService service;
- public ApplicationResponseUnmarshaller(String applicationName, Cartridge cartridge, IOpenshiftService service) {
+ public ApplicationResponseUnmarshaller(String applicationName, Cartridge cartridge, User user, IOpenshiftService service) {
this.applicationName = applicationName;
this.cartridge = cartridge;
+ this.user = user;
this.service = service;
}
@Override
protected Application createOpenshiftObject(ModelNode node) {
- return new Application(applicationName, cartridge, service);
+ return new Application(applicationName, cartridge, user, service);
}
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/response/DomainResponseUnmarshaller.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/response/DomainResponseUnmarshaller.java 2011-09-23 13:26:18 UTC (rev 34997)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/response/DomainResponseUnmarshaller.java 2011-09-23 13:38:47 UTC (rev 34998)
@@ -12,6 +12,7 @@
import org.jboss.dmr.ModelNode;
import org.jboss.ide.eclipse.as.openshift.core.Domain;
+import org.jboss.ide.eclipse.as.openshift.core.User;
/**
* @author André Dietisheim
@@ -19,13 +20,15 @@
public class DomainResponseUnmarshaller extends AbstractOpenshiftJsonResponseUnmarshaller<Domain> {
private String domainName;
-
- public DomainResponseUnmarshaller(String domainName) {
+ private User user;
+
+ public DomainResponseUnmarshaller(String domainName, User user) {
this.domainName = domainName;
+ this.user = user;
}
@Override
protected Domain createOpenshiftObject(ModelNode node) {
- return new Domain(domainName);
+ return new Domain(domainName, user);
}
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/response/UserInfoResponseUnmarshaller.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/response/UserInfoResponseUnmarshaller.java 2011-09-23 13:26:18 UTC (rev 34997)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/response/UserInfoResponseUnmarshaller.java 2011-09-23 13:38:47 UTC (rev 34998)
@@ -17,14 +17,9 @@
import javax.xml.datatype.DatatypeConfigurationException;
import org.jboss.dmr.ModelNode;
-import org.jboss.ide.eclipse.as.openshift.core.Application;
+import org.jboss.ide.eclipse.as.openshift.core.ApplicationInfo;
import org.jboss.ide.eclipse.as.openshift.core.Cartridge;
-import org.jboss.ide.eclipse.as.openshift.core.Domain;
import org.jboss.ide.eclipse.as.openshift.core.IOpenshiftJsonConstants;
-import org.jboss.ide.eclipse.as.openshift.core.IOpenshiftService;
-import org.jboss.ide.eclipse.as.openshift.core.ISSHPublicKey;
-import org.jboss.ide.eclipse.as.openshift.core.SSHPublicKey;
-import org.jboss.ide.eclipse.as.openshift.core.User;
import org.jboss.ide.eclipse.as.openshift.core.UserInfo;
/**
@@ -32,12 +27,6 @@
*/
public class UserInfoResponseUnmarshaller extends AbstractOpenshiftJsonResponseUnmarshaller<UserInfo> {
- private IOpenshiftService service;
-
- public UserInfoResponseUnmarshaller(IOpenshiftService service) {
- this.service = service;
- }
-
@Override
protected UserInfo createOpenshiftObject(ModelNode node) throws DatatypeConfigurationException {
ModelNode dataNode = node.get(IOpenshiftJsonConstants.PROPERTY_DATA);
@@ -50,47 +39,34 @@
return null;
}
- ISSHPublicKey sshKey = createSSHKey(userInfoNode);
- User user = createUser(userInfoNode, sshKey, createDomain(userInfoNode));
- List<Application> applications = createApplications(dataNode.get(IOpenshiftJsonConstants.PROPERTY_APP_INFO), user);
+ String sshPublicKey = getString(IOpenshiftJsonConstants.PROPERTY_SSH_KEY, userInfoNode);
+ String rhlogin = getString(IOpenshiftJsonConstants.PROPERTY_RHLOGIN, userInfoNode);
+ String uuid = getString(IOpenshiftJsonConstants.PROPERTY_UUID, userInfoNode);
+ String namespace = getString(IOpenshiftJsonConstants.PROPERTY_NAMESPACE, userInfoNode);
+ String rhcDomain = getString(IOpenshiftJsonConstants.PROPERTY_RHC_DOMAIN, userInfoNode);
- return new UserInfo(user, applications);
- }
+ List<ApplicationInfo> applicationInfos = createApplicationInfos(dataNode.get(IOpenshiftJsonConstants.PROPERTY_APP_INFO));
- private ISSHPublicKey createSSHKey(ModelNode userInfoNode) {
- String sshPublicKey = getString(IOpenshiftJsonConstants.PROPERTY_SSH_KEY, userInfoNode);
- return new SSHPublicKey(sshPublicKey);
+ return new UserInfo(rhlogin, uuid, sshPublicKey, rhcDomain, namespace, applicationInfos);
}
- private List<Application> createApplications(ModelNode appInfoNode, User user) throws DatatypeConfigurationException {
- List<Application> applications = new ArrayList<Application>();
+ private List<ApplicationInfo> createApplicationInfos(ModelNode appInfoNode) throws DatatypeConfigurationException {
+ List<ApplicationInfo> applicationInfos = new ArrayList<ApplicationInfo>();
if (!isSet(appInfoNode)) {
- return applications;
+ return applicationInfos;
}
for (String name : appInfoNode.keys()) {
- applications.add(createApplication(name, appInfoNode.get(name), user));
+ applicationInfos.add(createApplicationInfo(name, appInfoNode.get(name)));
}
- return applications;
+ return applicationInfos;
}
- private Application createApplication(String name, ModelNode appNode, User user) throws DatatypeConfigurationException {
- String embedded = getString(IOpenshiftJsonConstants.PROPERTY_EMBEDDED, appNode);
+ private ApplicationInfo createApplicationInfo(String name, ModelNode appNode) throws DatatypeConfigurationException {
String uuid = getString(IOpenshiftJsonConstants.PROPERTY_UUID, appNode);
+ String embedded = getString(IOpenshiftJsonConstants.PROPERTY_EMBEDDED, appNode);
Cartridge cartrdige = new Cartridge(getString(IOpenshiftJsonConstants.PROPERTY_FRAMEWORK, appNode));
Date creationTime = getDate(IOpenshiftJsonConstants.PROPERTY_CREATION_TIME, appNode);
- return new Application(name, uuid, cartrdige, embedded, creationTime, user, service);
+ return new ApplicationInfo(name, uuid, embedded, cartrdige, creationTime);
}
-
- private User createUser(ModelNode userInfoNode, ISSHPublicKey sshKey, Domain domain) {
- String rhlogin = getString(IOpenshiftJsonConstants.PROPERTY_RHLOGIN, userInfoNode);
- String uuid = getString(IOpenshiftJsonConstants.PROPERTY_UUID, userInfoNode);
- return new User(rhlogin, uuid, sshKey, domain);
- }
-
- private Domain createDomain(ModelNode userInfoNode) {
- String namespace = getString(IOpenshiftJsonConstants.PROPERTY_NAMESPACE, userInfoNode);
- String rhcDomain = getString(IOpenshiftJsonConstants.PROPERTY_RHC_DOMAIN, userInfoNode);
- return new Domain(namespace, rhcDomain);
- }
}
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ApplicationIntegrationTest.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ApplicationIntegrationTest.java 2011-09-23 13:26:18 UTC (rev 34997)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ApplicationIntegrationTest.java 2011-09-23 13:38:47 UTC (rev 34998)
@@ -18,6 +18,7 @@
import org.jboss.ide.eclipse.as.openshift.core.IOpenshiftService;
import org.jboss.ide.eclipse.as.openshift.core.InvalidCredentialsOpenshiftException;
import org.jboss.ide.eclipse.as.openshift.core.OpenshiftException;
+import org.jboss.ide.eclipse.as.openshift.core.User;
import org.jboss.ide.eclipse.as.openshift.core.internal.OpenshiftService;
import org.junit.Before;
import org.junit.Ignore;
@@ -28,23 +29,26 @@
*/
public class ApplicationIntegrationTest {
- private IOpenshiftService openshiftService;
+ private IOpenshiftService service;
private IOpenshiftService invalidCredentialsOpenshiftService;
- private static final String USERNAME = "toolsjboss(a)gmail.com";
+ private static final String RHLOGIN = "toolsjboss(a)gmail.com";
private static final String PASSWORD = "1q2w3e";
-
+ private User user;
+ private User invalidUser;
+
@Ignore
@Before
public void setUp() {
- this.openshiftService = new OpenshiftService(USERNAME, PASSWORD);
- this.invalidCredentialsOpenshiftService = new OpenshiftService(USERNAME, "bogus");
+ this.service = new OpenshiftService();
+ this.user = new User(RHLOGIN, PASSWORD);
+ this.invalidUser = new User(RHLOGIN, "bogusPassword");
}
@Ignore
@Test(expected = InvalidCredentialsOpenshiftException.class)
public void createApplicationWithInvalidCredentialsThrowsException() throws Exception {
- invalidCredentialsOpenshiftService.createApplication(createRandomApplicationName(), Cartridge.JBOSSAS_7);
+ service.createApplication(createRandomApplicationName(), Cartridge.JBOSSAS_7, invalidUser);
}
@Test
@@ -52,12 +56,12 @@
String applicationName = createRandomApplicationName();
try {
Cartridge cartridge = Cartridge.JBOSSAS_7;
- Application application = openshiftService.createApplication(applicationName, cartridge);
+ Application application = service.createApplication(applicationName, cartridge, user);
assertNotNull(application);
assertEquals(applicationName, application.getName());
assertEquals(cartridge, application.getCartridge());
} finally {
- silentlyDestroyAS7Application(applicationName, openshiftService);
+ silentlyDestroyAS7Application(applicationName, service);
}
}
@@ -65,8 +69,8 @@
@Test
public void canDestroyApplication() throws Exception {
String applicationName = createRandomApplicationName();
- openshiftService.createApplication(applicationName, Cartridge.JBOSSAS_7);
- openshiftService.destroyApplication(applicationName, Cartridge.JBOSSAS_7);
+ service.createApplication(applicationName, Cartridge.JBOSSAS_7, user);
+ service.destroyApplication(applicationName, Cartridge.JBOSSAS_7, user);
}
@Ignore
@@ -74,10 +78,10 @@
public void createDuplicateApplicationThrowsException() throws Exception {
String applicationName = createRandomApplicationName();
try {
- openshiftService.createApplication(applicationName, Cartridge.JBOSSAS_7);
- openshiftService.createApplication(applicationName, Cartridge.JBOSSAS_7);
+ service.createApplication(applicationName, Cartridge.JBOSSAS_7, user);
+ service.createApplication(applicationName, Cartridge.JBOSSAS_7, user);
} finally {
- silentlyDestroyAS7Application(applicationName, openshiftService);
+ silentlyDestroyAS7Application(applicationName, service);
}
}
@@ -86,10 +90,10 @@
public void canStopApplication() throws Exception {
String applicationName = createRandomApplicationName();
try {
- openshiftService.createApplication(applicationName, Cartridge.JBOSSAS_7);
- openshiftService.stopApplication(applicationName, Cartridge.JBOSSAS_7);
+ service.createApplication(applicationName, Cartridge.JBOSSAS_7, user);
+ service.stopApplication(applicationName, Cartridge.JBOSSAS_7, user);
} finally {
- silentlyDestroyAS7Application(applicationName, openshiftService);
+ silentlyDestroyAS7Application(applicationName, service);
}
}
@@ -98,11 +102,11 @@
public void canStartStoppedApplication() throws Exception {
String applicationName = createRandomApplicationName();
try {
- openshiftService.createApplication(applicationName, Cartridge.JBOSSAS_7);
- openshiftService.stopApplication(applicationName, Cartridge.JBOSSAS_7);
- openshiftService.startApplication(applicationName, Cartridge.JBOSSAS_7);
+ service.createApplication(applicationName, Cartridge.JBOSSAS_7, user);
+ service.stopApplication(applicationName, Cartridge.JBOSSAS_7, user);
+ service.startApplication(applicationName, Cartridge.JBOSSAS_7, user);
} finally {
- silentlyDestroyAS7Application(applicationName, openshiftService);
+ silentlyDestroyAS7Application(applicationName, service);
}
}
@@ -117,10 +121,10 @@
* @link
* https://github.com/openshift/os-client-tools/blob/master/express/doc/API
*/
- openshiftService.createApplication(applicationName, Cartridge.JBOSSAS_7);
- openshiftService.startApplication(applicationName, Cartridge.JBOSSAS_7);
+ service.createApplication(applicationName, Cartridge.JBOSSAS_7, user);
+ service.startApplication(applicationName, Cartridge.JBOSSAS_7, user);
} finally {
- silentlyDestroyAS7Application(applicationName, openshiftService);
+ silentlyDestroyAS7Application(applicationName, service);
}
}
@@ -135,11 +139,11 @@
* @link
* https://github.com/openshift/os-client-tools/blob/master/express/doc/API
*/
- openshiftService.createApplication(applicationName, Cartridge.JBOSSAS_7);
- openshiftService.stopApplication(applicationName, Cartridge.JBOSSAS_7);
- openshiftService.stopApplication(applicationName, Cartridge.JBOSSAS_7);
+ service.createApplication(applicationName, Cartridge.JBOSSAS_7, user);
+ service.stopApplication(applicationName, Cartridge.JBOSSAS_7, user);
+ service.stopApplication(applicationName, Cartridge.JBOSSAS_7, user);
} finally {
- silentlyDestroyAS7Application(applicationName, openshiftService);
+ silentlyDestroyAS7Application(applicationName, service);
}
}
@@ -154,10 +158,10 @@
* @link
* https://github.com/openshift/os-client-tools/blob/master/express/doc/API
*/
- openshiftService.createApplication(applicationName, Cartridge.JBOSSAS_7);
- openshiftService.restartApplication(applicationName, Cartridge.JBOSSAS_7);
+ service.createApplication(applicationName, Cartridge.JBOSSAS_7, user);
+ service.restartApplication(applicationName, Cartridge.JBOSSAS_7, user);
} finally {
- silentlyDestroyAS7Application(applicationName, openshiftService);
+ silentlyDestroyAS7Application(applicationName, service);
}
}
@@ -165,11 +169,11 @@
public void canGetStatus() throws Exception {
String applicationName = createRandomApplicationName();
try {
- Application application = openshiftService.createApplication(applicationName, Cartridge.JBOSSAS_7);
- String applicationStatus = openshiftService.getStatus(application.getName(), application.getCartridge());
+ Application application = service.createApplication(applicationName, Cartridge.JBOSSAS_7, user);
+ String applicationStatus = service.getStatus(application.getName(), application.getCartridge(), user);
assertNotNull(applicationStatus);
} finally {
- silentlyDestroyAS7Application(applicationName, openshiftService);
+ silentlyDestroyAS7Application(applicationName, service);
}
}
@@ -178,12 +182,12 @@
public void getStatusReturnsTheWholeLog() throws Exception {
String applicationName = createRandomApplicationName();
try {
- Application application = openshiftService.createApplication(applicationName, Cartridge.JBOSSAS_7);
- String applicationStatus = openshiftService.getStatus(application.getName(), application.getCartridge());
- String applicationStatus2 = openshiftService.getStatus(application.getName(), application.getCartridge());
+ Application application = service.createApplication(applicationName, Cartridge.JBOSSAS_7, user);
+ String applicationStatus = service.getStatus(application.getName(), application.getCartridge(), user);
+ String applicationStatus2 = service.getStatus(application.getName(), application.getCartridge(), user);
assertEquals(applicationStatus, applicationStatus2);
} finally {
- silentlyDestroyAS7Application(applicationName, openshiftService);
+ silentlyDestroyAS7Application(applicationName, service);
}
}
@@ -193,7 +197,7 @@
private void silentlyDestroyAS7Application(String name, IOpenshiftService service) {
try {
- service.destroyApplication(name, Cartridge.JBOSSAS_7);
+ service.destroyApplication(name, Cartridge.JBOSSAS_7, user);
} catch (OpenshiftException e) {
e.printStackTrace();
}
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ApplicationTest.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ApplicationTest.java 2011-09-23 13:26:18 UTC (rev 34997)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ApplicationTest.java 2011-09-23 13:38:47 UTC (rev 34998)
@@ -19,9 +19,9 @@
import java.util.Arrays;
import org.jboss.ide.eclipse.as.openshift.core.Application;
+import org.jboss.ide.eclipse.as.openshift.core.ApplicationInfo;
import org.jboss.ide.eclipse.as.openshift.core.ApplicationLogReader;
import org.jboss.ide.eclipse.as.openshift.core.Cartridge;
-import org.jboss.ide.eclipse.as.openshift.core.Domain;
import org.jboss.ide.eclipse.as.openshift.core.IOpenshiftService;
import org.jboss.ide.eclipse.as.openshift.core.OpenshiftException;
import org.jboss.ide.eclipse.as.openshift.core.User;
@@ -43,28 +43,28 @@
*/
public class ApplicationTest {
- private static final String USERNAME = "toolsjboss(a)gmail.com";
- private static final String PASSWORD = "1q2w3e";
+ private User user = new User(ApplicationResponseFake.RHLOGIN, ApplicationResponseFake.PASSWORD, new NoopOpenshiftServiceFake());
@Test
public void canMarshallApplicationCreateRequest() throws Exception {
String expectedRequestString =
"password="
- + PASSWORD
+ + URLEncoder.encode(ApplicationResponseFake.PASSWORD, "UTF-8")
+ "&json_data=%7B"
+ "%22rhlogin%22+%3A+%22"
- + URLEncoder.encode(USERNAME, "UTF-8")
+ + URLEncoder.encode(ApplicationResponseFake.RHLOGIN, "UTF-8")
+ "%22"
+ "%2C+%22debug%22+%3A+%22true%22"
+ "%2C+%22cartridge%22+%3A+%22jbossas-7.0%22"
- + "%2C+%22action%22+%3A+%22configure%22"
- + "%2C+%22app_name%22+%3A+%22test-application%22"
+ + "%2C+%22action%22+%3A+%22"
+ + "configure"
+ + "%22%2C+%22app_name%22+%3A+%22test-application%22"
+ "%7D";
String createApplicationRequest = new ApplicationRequestJsonMarshaller().marshall(
new ApplicationRequest(
- "test-application", Cartridge.JBOSSAS_7, ApplicationAction.CONFIGURE, USERNAME, true));
- String effectiveRequest = new OpenshiftEnvelopeFactory(PASSWORD, createApplicationRequest).createString();
+ "test-application", Cartridge.JBOSSAS_7, ApplicationAction.CONFIGURE, ApplicationResponseFake.RHLOGIN, true));
+ String effectiveRequest = new OpenshiftEnvelopeFactory(ApplicationResponseFake.PASSWORD, createApplicationRequest).createString();
assertEquals(expectedRequestString, effectiveRequest);
}
@@ -73,20 +73,21 @@
public void canMarshallApplicationDestroyRequest() throws Exception {
String expectedRequestString =
"password="
- + PASSWORD
+ + URLEncoder.encode(ApplicationResponseFake.PASSWORD, "UTF-8")
+ "&json_data=%7B"
+ "%22rhlogin%22+%3A+"
- + "%22" + URLEncoder.encode(USERNAME, "UTF-8") + "%22"
+ + "%22" + URLEncoder.encode(ApplicationResponseFake.RHLOGIN, "UTF-8") + "%22"
+ "%2C+%22debug%22+%3A+%22true%22"
+ "%2C+%22cartridge%22+%3A+%22jbossas-7.0%22"
- + "%2C+%22action%22+%3A+%22deconfigure%22"
- + "%2C+%22app_name%22+%3A+%22test-application%22"
+ + "%2C+%22action%22+%3A+%22"
+ + "deconfigure"
+ + "%22%2C+%22app_name%22+%3A+%22test-application%22"
+ "%7D";
String createApplicationRequest = new ApplicationRequestJsonMarshaller().marshall(
new ApplicationRequest(
- "test-application", Cartridge.JBOSSAS_7, ApplicationAction.DECONFIGURE, USERNAME, true));
- String effectiveRequest = new OpenshiftEnvelopeFactory(PASSWORD, createApplicationRequest).createString();
+ "test-application", Cartridge.JBOSSAS_7, ApplicationAction.DECONFIGURE, ApplicationResponseFake.RHLOGIN, true));
+ String effectiveRequest = new OpenshiftEnvelopeFactory(ApplicationResponseFake.PASSWORD, createApplicationRequest).createString();
assertEquals(expectedRequestString, effectiveRequest);
}
@@ -97,7 +98,7 @@
OpenshiftResponse<Application> openshiftResponse =
new ApplicationResponseUnmarshaller(
ApplicationResponseFake.APPLICATION_NAME, ApplicationResponseFake.APPLICATION_CARTRIDGE,
- new NoopOpenshiftServiceFake())
+ user, new NoopOpenshiftServiceFake())
.unmarshall(response);
Application application = openshiftResponse.getOpenshiftObject();
assertNotNull(application);
@@ -110,29 +111,26 @@
String response = JsonSanitizer.sanitize(ApplicationResponseFake.appResponse);
IOpenshiftService service = new NoopOpenshiftServiceFake() {
@Override
- public UserInfo getUserInfo() throws OpenshiftException {
- Domain domain =
- new Domain("adietish", "openshift.redhat.com");
- User user = new User(
- ApplicationResponseFake.USERNAME,
- "1234567890abcdef",
- null,
- domain);
- Application application = new Application(
+ public UserInfo getUserInfo(User user) throws OpenshiftException {
+ ApplicationInfo applicationInfo = new ApplicationInfo(
ApplicationResponseFake.APPLICATION_NAME,
ApplicationResponseFake.APPLICATION_UUID,
- ApplicationResponseFake.APPLICATION_CARTRIDGE,
ApplicationResponseFake.APPLICATION_EMBEDDED,
- ApplicationResponseFake.APPLICATION_CREATIONTIME,
- user,
- this);
- return new UserInfo(user, Arrays.asList(new Application[] { application }));
+ ApplicationResponseFake.APPLICATION_CARTRIDGE,
+ ApplicationResponseFake.APPLICATION_CREATIONTIME);
+ return new UserInfo(
+ ApplicationResponseFake.RHLOGIN,
+ ApplicationResponseFake.UUID,
+ ApplicationResponseFake.SSHPUBLICKEY,
+ ApplicationResponseFake.RHC_DOMAIN,
+ ApplicationResponseFake.NAMESPACE,
+ Arrays.asList(new ApplicationInfo[] { applicationInfo }));
}
};
OpenshiftResponse<Application> openshiftResponse =
new ApplicationResponseUnmarshaller(
ApplicationResponseFake.APPLICATION_NAME, ApplicationResponseFake.APPLICATION_CARTRIDGE,
- service)
+ user, service)
.unmarshall(response);
Application application = openshiftResponse.getOpenshiftObject();
assertNotNull(application);
@@ -155,15 +153,15 @@
IOpenshiftService service = new NoopOpenshiftServiceFake() {
@Override
- public String getStatus(String applicationName, Cartridge cartridge) throws OpenshiftException {
+ public String getStatus(String applicationName, Cartridge cartridge, User user) throws OpenshiftException {
return ApplicationResponseFake.tail;
}
};
Application application =
new Application(ApplicationResponseFake.APPLICATION_NAME,
- ApplicationResponseFake.APPLICATION_CARTRIDGE, service);
- ApplicationLogReader reader = new ApplicationLogReader(application, service);
+ ApplicationResponseFake.APPLICATION_CARTRIDGE, user, service);
+ ApplicationLogReader reader = new ApplicationLogReader(application, user, service);
int toMatchIndex = 0;
for (int character = -1; (character = reader.read()) != -1;) {
Added: trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/CartridgeTest.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/CartridgeTest.java (rev 0)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/CartridgeTest.java 2011-09-23 13:38:47 UTC (rev 34998)
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.openshift.test.internal.core;
+
+import static org.jboss.ide.eclipse.as.openshift.test.internal.core.utils.CartridgeAsserts.assertThatContainsCartridge;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.List;
+
+import org.jboss.ide.eclipse.as.openshift.core.Cartridge;
+import org.jboss.ide.eclipse.as.openshift.core.OpenshiftException;
+import org.jboss.ide.eclipse.as.openshift.core.internal.response.JsonSanitizer;
+import org.jboss.ide.eclipse.as.openshift.core.internal.response.ListCartridgesResponseUnmarshaller;
+import org.jboss.ide.eclipse.as.openshift.core.internal.response.OpenshiftResponse;
+import org.jboss.ide.eclipse.as.openshift.test.internal.core.fakes.CartridgeResponseFake;
+import org.junit.Test;
+
+/**
+ * @author André Dietisheim
+ */
+public class CartridgeTest {
+
+ @Test
+ public void canUnmarshallApplicationResponse() throws OpenshiftException {
+ String response = JsonSanitizer.sanitize(CartridgeResponseFake.RESPONSE);
+ OpenshiftResponse<List<Cartridge>> openshiftResponse =
+ new ListCartridgesResponseUnmarshaller().unmarshall(response);
+ List<Cartridge> cartridges = openshiftResponse.getOpenshiftObject();
+ assertNotNull(cartridges);
+ assertThatContainsCartridge(CartridgeResponseFake.CARTRIDGE_JBOSSAS70, cartridges);
+ assertThatContainsCartridge(CartridgeResponseFake.CARTRIDGE_PERL5, cartridges);
+ assertThatContainsCartridge(CartridgeResponseFake.CARTRIDGE_PHP53, cartridges);
+ assertThatContainsCartridge(CartridgeResponseFake.CARTRIDGE_RACK11, cartridges);
+ assertThatContainsCartridge(CartridgeResponseFake.CARTRIDGE_WSGI32, cartridges);
+ }
+}
Property changes on: trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/CartridgeTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/CartridgesIntegrationTest.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/CartridgesIntegrationTest.java 2011-09-23 13:26:18 UTC (rev 34997)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/CartridgesIntegrationTest.java 2011-09-23 13:38:47 UTC (rev 34998)
@@ -6,6 +6,7 @@
import java.util.List;
import org.jboss.ide.eclipse.as.openshift.core.Cartridge;
+import org.jboss.ide.eclipse.as.openshift.core.User;
import org.jboss.ide.eclipse.as.openshift.core.internal.OpenshiftService;
import org.junit.Before;
import org.junit.Ignore;
@@ -15,18 +16,21 @@
private OpenshiftService openshiftService;
- private static final String USERNAME = "toolsjboss(a)gmail.com";
+ private static final String RHLOGIN = "toolsjboss(a)gmail.com";
private static final String PASSWORD = "1q2w3e";
-
+
+ private User user;
+
@Before
public void setUp() {
- this.openshiftService = new OpenshiftService(USERNAME, PASSWORD);
+ this.openshiftService = new OpenshiftService();
+ this.user = new User(RHLOGIN, PASSWORD);
}
@Ignore
@Test
public void canRequestListCartridges() throws Exception {
- List<Cartridge> cartridges = openshiftService.getCartridges();
+ List<Cartridge> cartridges = openshiftService.getCartridges(user);
assertNotNull(cartridges);
assertTrue(cartridges.size() > 0);
}
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/DomainIntegrationTest.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/DomainIntegrationTest.java 2011-09-23 13:26:18 UTC (rev 34997)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/DomainIntegrationTest.java 2011-09-23 13:38:47 UTC (rev 34998)
@@ -15,6 +15,7 @@
import org.jboss.ide.eclipse.as.openshift.core.Domain;
import org.jboss.ide.eclipse.as.openshift.core.SSHKeyPair;
+import org.jboss.ide.eclipse.as.openshift.core.User;
import org.jboss.ide.eclipse.as.openshift.core.internal.OpenshiftService;
import org.jboss.ide.eclipse.as.openshift.test.internal.core.fakes.TestSSHKey;
import org.junit.Before;
@@ -24,12 +25,12 @@
private OpenshiftService openshiftService;
- private static final String USERNAME = "toolsjboss(a)gmail.com";
+ private static final String RHLOGIN = "toolsjboss(a)gmail.com";
private static final String PASSWORD = "1q2w3e";
@Before
public void setUp() {
- this.openshiftService = new OpenshiftService(USERNAME, PASSWORD);
+ this.openshiftService = new OpenshiftService();
}
@Test
@@ -37,7 +38,8 @@
String domainName = createRandomString();
SSHKeyPair sshKey = TestSSHKey.create();
- Domain domain = openshiftService.createDomain(domainName, sshKey);
+ User user = new User(RHLOGIN, PASSWORD);
+ Domain domain = openshiftService.createDomain(domainName, sshKey, user);
assertNotNull(domain);
assertEquals(domainName, domain.getNamespace());
@@ -48,7 +50,8 @@
String domainName = createRandomString();
SSHKeyPair sshKey = TestSSHKey.create();
- Domain domain = openshiftService.changeDomain(domainName, sshKey);
+ User user = new User(RHLOGIN, PASSWORD);
+ Domain domain = openshiftService.changeDomain(domainName, sshKey, user);
assertNotNull(domain);
assertEquals(domainName, domain.getNamespace());
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/DomainTest.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/DomainTest.java 2011-09-23 13:26:18 UTC (rev 34997)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/DomainTest.java 2011-09-23 13:38:47 UTC (rev 34998)
@@ -20,6 +20,7 @@
import org.jboss.ide.eclipse.as.openshift.core.Domain;
import org.jboss.ide.eclipse.as.openshift.core.OpenshiftException;
import org.jboss.ide.eclipse.as.openshift.core.SSHKeyPair;
+import org.jboss.ide.eclipse.as.openshift.core.User;
import org.jboss.ide.eclipse.as.openshift.core.internal.request.ChangeDomainRequest;
import org.jboss.ide.eclipse.as.openshift.core.internal.request.CreateDomainRequest;
import org.jboss.ide.eclipse.as.openshift.core.internal.request.OpenshiftEnvelopeFactory;
@@ -27,6 +28,7 @@
import org.jboss.ide.eclipse.as.openshift.core.internal.response.DomainResponseUnmarshaller;
import org.jboss.ide.eclipse.as.openshift.core.internal.response.JsonSanitizer;
import org.jboss.ide.eclipse.as.openshift.core.internal.response.OpenshiftResponse;
+import org.jboss.ide.eclipse.as.openshift.test.internal.core.fakes.NoopOpenshiftServiceFake;
import org.jboss.ide.eclipse.as.openshift.test.internal.core.fakes.TestSSHKey;
import org.junit.Test;
@@ -35,17 +37,17 @@
*/
public class DomainTest {
- private static final String USERNAME = "toolsjboss(a)gmail.com";
+ private static final String RHLOGIN = "toolsjboss(a)gmail.com";
private static final String PASSWORD = "1q2w3e";
private static final String UUID = "0c82860dae904a4d87f8e5d87a5af840";
@Test
public void canMarshallDomainCreateRequest() throws IOException, OpenshiftException {
SSHKeyPair sshKey = TestSSHKey.create();
- String expectedRequestString = createDomainRequestString(PASSWORD, USERNAME, true, "myDomain", false,
+ String expectedRequestString = createDomainRequestString(PASSWORD, RHLOGIN, true, "myDomain", false,
sshKey.getPublicKey());
- CreateDomainRequest request = new CreateDomainRequest("myDomain", sshKey, USERNAME, true);
+ CreateDomainRequest request = new CreateDomainRequest("myDomain", sshKey, RHLOGIN, true);
String requestString =
new OpenshiftEnvelopeFactory(
PASSWORD,
@@ -57,10 +59,11 @@
@Test
public void canUnmarshallDomainCreateResponse() throws IOException, OpenshiftException {
String domainName = "myDomain";
- String responseString = createDomainResponseString(USERNAME, UUID);
+ String responseString = createDomainResponseString(RHLOGIN, UUID);
responseString = JsonSanitizer.sanitize(responseString);
- OpenshiftResponse<Domain> response = new DomainResponseUnmarshaller(domainName).unmarshall(responseString);
+ User user = new User(RHLOGIN, PASSWORD, new NoopOpenshiftServiceFake());
+ OpenshiftResponse<Domain> response = new DomainResponseUnmarshaller(domainName, user).unmarshall(responseString);
assertNotNull(response);
Domain domain = response.getOpenshiftObject();
@@ -70,10 +73,10 @@
@Test
public void canMarshallDomainAlterRequest() throws IOException, OpenshiftException {
SSHKeyPair sshKey = TestSSHKey.create();
- String expectedRequestString = createDomainRequestString(PASSWORD, USERNAME, true, "myDomain", true,
+ String expectedRequestString = createDomainRequestString(PASSWORD, RHLOGIN, true, "myDomain", true,
sshKey.getPublicKey());
- ChangeDomainRequest request = new ChangeDomainRequest("myDomain", sshKey, USERNAME, true);
+ ChangeDomainRequest request = new ChangeDomainRequest("myDomain", sshKey, RHLOGIN, true);
String requestString =
new OpenshiftEnvelopeFactory(
PASSWORD,
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ListCartridgesIntegrationTest.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ListCartridgesIntegrationTest.java 2011-09-23 13:26:18 UTC (rev 34997)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ListCartridgesIntegrationTest.java 2011-09-23 13:38:47 UTC (rev 34998)
@@ -10,13 +10,14 @@
******************************************************************************/
package org.jboss.ide.eclipse.as.openshift.test.internal.core;
+import static org.jboss.ide.eclipse.as.openshift.test.internal.core.utils.CartridgeAsserts.assertThatContainsCartridge;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import static org.jboss.ide.eclipse.as.openshift.test.internal.core.utils.CartridgeAsserts.assertThatContainsCartridge;
import java.util.List;
import org.jboss.ide.eclipse.as.openshift.core.Cartridge;
+import org.jboss.ide.eclipse.as.openshift.core.User;
import org.jboss.ide.eclipse.as.openshift.core.internal.OpenshiftService;
import org.junit.Before;
import org.junit.Test;
@@ -33,12 +34,12 @@
@Before
public void setUp() {
- this.openshiftService = new OpenshiftService(USERNAME, PASSWORD);
+ this.openshiftService = new OpenshiftService();
}
@Test
public void canListCartridges() throws Exception {
- List<Cartridge> cartridges = openshiftService.getCartridges();
+ List<Cartridge> cartridges = openshiftService.getCartridges(new User(USERNAME, PASSWORD));
assertNotNull(cartridges);
assertTrue(cartridges.size() > 0);
assertThatContainsCartridge("jbossas-7.0", cartridges);
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/OpenshiftTestSuite.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/OpenshiftTestSuite.java 2011-09-23 13:26:18 UTC (rev 34997)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/OpenshiftTestSuite.java 2011-09-23 13:38:47 UTC (rev 34998)
@@ -20,6 +20,8 @@
ListCartridgesTest.class,
DomainTest.class,
UserInfoTest.class,
+ UserTest.class,
+ CartridgeTest.class,
SSHKeyTest.class
})
/**
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/UserInfoIntegrationTest.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/UserInfoIntegrationTest.java 2011-09-23 13:26:18 UTC (rev 34997)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/UserInfoIntegrationTest.java 2011-09-23 13:38:47 UTC (rev 34998)
@@ -15,7 +15,7 @@
import java.util.List;
-import org.jboss.ide.eclipse.as.openshift.core.Application;
+import org.jboss.ide.eclipse.as.openshift.core.ApplicationInfo;
import org.jboss.ide.eclipse.as.openshift.core.Cartridge;
import org.jboss.ide.eclipse.as.openshift.core.IOpenshiftService;
import org.jboss.ide.eclipse.as.openshift.core.ISSHPublicKey;
@@ -23,7 +23,7 @@
import org.jboss.ide.eclipse.as.openshift.core.User;
import org.jboss.ide.eclipse.as.openshift.core.UserInfo;
import org.jboss.ide.eclipse.as.openshift.core.internal.OpenshiftService;
-import org.jboss.ide.eclipse.as.openshift.test.internal.core.utils.ApplicationAsserts;
+import org.jboss.ide.eclipse.as.openshift.test.internal.core.utils.ApplicationInfoAsserts;
import org.junit.Before;
import org.junit.Test;
@@ -34,39 +34,39 @@
private IOpenshiftService openshiftService;
- private static final String USERNAME = "toolsjboss(a)gmail.com";
+ private static final String RHLOGIN = "toolsjboss(a)gmail.com";
private static final String PASSWORD = "1q2w3e";
@Before
public void setUp() {
- this.openshiftService = new OpenshiftService(USERNAME, PASSWORD);
+ this.openshiftService = new OpenshiftService();
}
@Test
public void canGetUserInfo() throws Exception {
- UserInfo userInfo = openshiftService.getUserInfo();
+ UserInfo userInfo = openshiftService.getUserInfo(new User(RHLOGIN, PASSWORD));
assertNotNull(userInfo);
- User user = userInfo.getUser();
- assertEquals(USERNAME, user.getRhlogin());
+ assertEquals(RHLOGIN, userInfo.getRhLogin());
}
@Test
public void userInfoContainsOneMoreApplicationAfterCreatingNewApplication() throws Exception {
- UserInfo userInfo = openshiftService.getUserInfo();
+ User user = new User(RHLOGIN, PASSWORD);
+ UserInfo userInfo = openshiftService.getUserInfo(user);
assertNotNull(userInfo);
- List<Application> applications = userInfo.getApplications();
- assertNotNull(applications);
- int numberOfApplications = applications.size();
+ List<ApplicationInfo> applicationInfos = userInfo.getApplicationInfos();
+ assertNotNull(applicationInfos);
+ int numberOfApplicationInfos = applicationInfos.size();
String applicationName = createRandomName();
try {
- openshiftService.createApplication(applicationName, Cartridge.JBOSSAS_7);
+ openshiftService.createApplication(applicationName, Cartridge.JBOSSAS_7, user);
- UserInfo userInfo2 = openshiftService.getUserInfo();
- assertEquals(numberOfApplications + 1, userInfo2.getApplications().size());
- ApplicationAsserts.assertThatContainsApplication(applicationName, userInfo2.getApplications());
+ UserInfo userInfo2 = openshiftService.getUserInfo(user);
+ assertEquals(numberOfApplicationInfos + 1, userInfo2.getApplicationInfos().size());
+ ApplicationInfoAsserts.assertThatContainsApplicationInfo(applicationName, userInfo2.getApplicationInfos());
} finally {
silentlyDestroyAS7Application(applicationName, openshiftService);
}
@@ -74,13 +74,12 @@
@Test
public void canUseReturnedSSHKeyToChangeDomain() throws Exception {
- UserInfo userInfo = openshiftService.getUserInfo();
+ User user = new User(RHLOGIN, PASSWORD);
+ UserInfo userInfo = openshiftService.getUserInfo(user);
assertNotNull(userInfo);
- User user = userInfo.getUser();
- assertNotNull(user);
- ISSHPublicKey sshKey = user.getSshKey();
- openshiftService.changeDomain(createRandomName(), sshKey);
+ ISSHPublicKey sshKey = userInfo.getSshPublicKey();
+ openshiftService.changeDomain(createRandomName(), sshKey, user);
}
private String createRandomName() {
@@ -89,10 +88,9 @@
private void silentlyDestroyAS7Application(String name, IOpenshiftService service) {
try {
- service.destroyApplication(name, Cartridge.JBOSSAS_7);
+ service.destroyApplication(name, Cartridge.JBOSSAS_7, new User(RHLOGIN, PASSWORD));
} catch (OpenshiftException e) {
e.printStackTrace();
}
}
-
}
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/UserInfoTest.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/UserInfoTest.java 2011-09-23 13:26:18 UTC (rev 34997)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/UserInfoTest.java 2011-09-23 13:38:47 UTC (rev 34998)
@@ -10,18 +10,16 @@
******************************************************************************/
package org.jboss.ide.eclipse.as.openshift.test.internal.core;
-import static org.jboss.ide.eclipse.as.openshift.test.internal.core.utils.ApplicationAsserts.assertThatContainsApplication;
+import static org.jboss.ide.eclipse.as.openshift.test.internal.core.utils.ApplicationInfoAsserts.assertThatContainsApplicationInfo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.net.URLEncoder;
import java.util.List;
-import org.jboss.ide.eclipse.as.openshift.core.Application;
-import org.jboss.ide.eclipse.as.openshift.core.Domain;
+import org.jboss.ide.eclipse.as.openshift.core.ApplicationInfo;
import org.jboss.ide.eclipse.as.openshift.core.ISSHPublicKey;
import org.jboss.ide.eclipse.as.openshift.core.OpenshiftException;
-import org.jboss.ide.eclipse.as.openshift.core.User;
import org.jboss.ide.eclipse.as.openshift.core.UserInfo;
import org.jboss.ide.eclipse.as.openshift.core.internal.request.OpenshiftEnvelopeFactory;
import org.jboss.ide.eclipse.as.openshift.core.internal.request.UserInfoRequest;
@@ -29,7 +27,6 @@
import org.jboss.ide.eclipse.as.openshift.core.internal.response.JsonSanitizer;
import org.jboss.ide.eclipse.as.openshift.core.internal.response.OpenshiftResponse;
import org.jboss.ide.eclipse.as.openshift.core.internal.response.UserInfoResponseUnmarshaller;
-import org.jboss.ide.eclipse.as.openshift.test.internal.core.fakes.NoopOpenshiftServiceFake;
import org.jboss.ide.eclipse.as.openshift.test.internal.core.fakes.UserInfoResponseFake;
import org.junit.Test;
@@ -43,12 +40,13 @@
String expectedRequestString =
"password=" + URLEncoder.encode(UserInfoResponseFake.PASSWORD, "UTF-8")
+ "&json_data=%7B"
- + "%22rhlogin%22+%3A+%22" + URLEncoder.encode(UserInfoResponseFake.USERNAME, "UTF-8") + "%22%2C+"
+ + "%22rhlogin%22+%3A+%22" + URLEncoder.encode(UserInfoResponseFake.RHLOGIN, "UTF-8")
+ + "%22%2C+"
+ "%22debug%22+%3A+%22true%22"
+ "%7D";
String userInfoRequest = new UserInfoRequestJsonMarshaller().marshall(
- new UserInfoRequest(UserInfoResponseFake.USERNAME, true));
+ new UserInfoRequest(UserInfoResponseFake.RHLOGIN, true));
String effectiveRequest =
new OpenshiftEnvelopeFactory(UserInfoResponseFake.PASSWORD, userInfoRequest).createString();
@@ -60,50 +58,45 @@
UserInfo userInfo = getUserInfo(JsonSanitizer.sanitize(UserInfoResponseFake.RESPONSE));
assertNotNull(userInfo);
- User user = userInfo.getUser();
- assertNotNull(user);
- assertEquals(UserInfoResponseFake.USERNAME, user.getRhlogin());
- assertEquals(UserInfoResponseFake.UUID, user.getUuid());
- ISSHPublicKey sshKey = user.getSshKey();
- assertNotNull(sshKey);
- assertEquals(UserInfoResponseFake.SSH_KEY, sshKey.getPublicKey());
+ assertEquals(UserInfoResponseFake.RHLOGIN, userInfo.getRhLogin());
+ assertEquals(UserInfoResponseFake.UUID, userInfo.getUuid());
+ ISSHPublicKey sshPublicKey = userInfo.getSshPublicKey();
+ assertNotNull(sshPublicKey);
+ assertEquals(UserInfoResponseFake.SSH_KEY, sshPublicKey.getPublicKey());
- Domain domain = user.getDomain();
- assertEquals(UserInfoResponseFake.NAMESPACE, domain.getNamespace());
- assertEquals(UserInfoResponseFake.RHC_DOMAIN, domain.getRhcDomain());
+ assertEquals(UserInfoResponseFake.NAMESPACE, userInfo.getNamespace());
+ assertEquals(UserInfoResponseFake.RHC_DOMAIN, userInfo.getRhcDomain());
- List<Application> applications = userInfo.getApplications();
- assertNotNull(applications);
- assertEquals(2, applications.size());
- assertThatContainsApplication(
+ List<ApplicationInfo> applicationInfos = userInfo.getApplicationInfos();
+ assertNotNull(applicationInfos);
+ assertEquals(2, applicationInfos.size());
+ assertThatContainsApplicationInfo(
UserInfoResponseFake.APP1_NAME,
UserInfoResponseFake.APP1_EMBEDDED,
UserInfoResponseFake.APP1_UUID,
UserInfoResponseFake.APP1_CARTRIDGE,
UserInfoResponseFake.APP1_CREATION_TIME,
- applications);
- assertThatContainsApplication(
+ applicationInfos);
+ assertThatContainsApplicationInfo(
UserInfoResponseFake.APP2_NAME,
UserInfoResponseFake.APP2_EMBEDDED,
UserInfoResponseFake.APP2_UUID,
UserInfoResponseFake.APP2_CARTRIDGE,
UserInfoResponseFake.APP2_CREATION_TIME,
- applications);
+ applicationInfos);
}
-
+
@Test
public void canGetApplicationByName() throws OpenshiftException {
UserInfo userInfo = getUserInfo(JsonSanitizer.sanitize(UserInfoResponseFake.RESPONSE));
- Application application = userInfo.getApplicationByName(UserInfoResponseFake.APP1_NAME);
- assertNotNull(application);
- assertEquals(UserInfoResponseFake.APP1_NAME, application.getName());
+ ApplicationInfo applicationInfo = userInfo.getApplicationInfoByName(UserInfoResponseFake.APP1_NAME);
+ assertNotNull(applicationInfo);
+ assertEquals(UserInfoResponseFake.APP1_NAME, applicationInfo.getName());
}
protected UserInfo getUserInfo(String response) throws OpenshiftException {
- UserInfoResponseUnmarshaller unmarshaller = new UserInfoResponseUnmarshaller(new NoopOpenshiftServiceFake());
- OpenshiftResponse<UserInfo> openshiftResponse =
- unmarshaller.unmarshall(response);
-
+ UserInfoResponseUnmarshaller unmarshaller = new UserInfoResponseUnmarshaller();
+ OpenshiftResponse<UserInfo> openshiftResponse = unmarshaller.unmarshall(response);
return openshiftResponse.getOpenshiftObject();
}
}
Added: trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/UserTest.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/UserTest.java (rev 0)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/UserTest.java 2011-09-23 13:38:47 UTC (rev 34998)
@@ -0,0 +1,153 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.openshift.test.internal.core;
+
+import static org.jboss.ide.eclipse.as.openshift.test.internal.core.utils.ApplicationAsserts.assertApplication;
+import static org.jboss.ide.eclipse.as.openshift.test.internal.core.utils.CartridgeAsserts.assertThatContainsCartridge;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+import javax.xml.datatype.DatatypeConfigurationException;
+
+import org.jboss.ide.eclipse.as.openshift.core.Application;
+import org.jboss.ide.eclipse.as.openshift.core.ApplicationInfo;
+import org.jboss.ide.eclipse.as.openshift.core.Cartridge;
+import org.jboss.ide.eclipse.as.openshift.core.Domain;
+import org.jboss.ide.eclipse.as.openshift.core.ISSHPublicKey;
+import org.jboss.ide.eclipse.as.openshift.core.OpenshiftException;
+import org.jboss.ide.eclipse.as.openshift.core.User;
+import org.jboss.ide.eclipse.as.openshift.core.UserInfo;
+import org.jboss.ide.eclipse.as.openshift.core.internal.OpenshiftService;
+import org.jboss.ide.eclipse.as.openshift.core.internal.utils.RFC822DateUtils;
+import org.jboss.ide.eclipse.as.openshift.test.internal.core.fakes.CartridgeResponseFake;
+import org.jboss.ide.eclipse.as.openshift.test.internal.core.fakes.NoopOpenshiftServiceFake;
+import org.jboss.ide.eclipse.as.openshift.test.internal.core.fakes.UserInfoResponseFake;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author André Dietisheim
+ */
+public class UserTest {
+
+ private OpenshiftService userInfoservice;
+ private User user;
+
+ @Before
+ public void setUp() throws OpenshiftException, DatatypeConfigurationException {
+ UserInfo userInfo = createUserInfo();
+ this.userInfoservice = createUserInfoService(userInfo);
+ this.user = new User(UserInfoResponseFake.RHLOGIN, UserInfoResponseFake.PASSWORD, userInfoservice);
+ }
+
+ @Test
+ public void canGetUserUUID() throws OpenshiftException {
+ assertEquals(UserInfoResponseFake.UUID, user.getUUID());
+ }
+
+ @Test
+ public void canGetPublicKey() throws OpenshiftException {
+ ISSHPublicKey key = user.getSshKey();
+ assertNotNull(key);
+ assertEquals(UserInfoResponseFake.SSH_KEY, key.getPublicKey());
+ }
+
+ @Test
+ public void canGetDomain() throws OpenshiftException {
+ Domain domain = user.getDomain();
+ assertNotNull(domain);
+ assertEquals(UserInfoResponseFake.RHC_DOMAIN, domain.getRhcDomain());
+ assertEquals(UserInfoResponseFake.NAMESPACE, domain.getNamespace());
+ }
+
+ @Test
+ public void canGetCartridges() throws OpenshiftException {
+ OpenshiftService cartridgeListService = new NoopOpenshiftServiceFake() {
+
+ @Override
+ public List<Cartridge> getCartridges(User user) throws OpenshiftException {
+ ArrayList<Cartridge> cartridges = new ArrayList<Cartridge>();
+ cartridges.add(new Cartridge(CartridgeResponseFake.CARTRIDGE_JBOSSAS70));
+ cartridges.add(new Cartridge(CartridgeResponseFake.CARTRIDGE_PERL5));
+ cartridges.add(new Cartridge(CartridgeResponseFake.CARTRIDGE_PHP53));
+ cartridges.add(new Cartridge(CartridgeResponseFake.CARTRIDGE_RACK11));
+ cartridges.add(new Cartridge(CartridgeResponseFake.CARTRIDGE_WSGI32));
+ return cartridges;
+ }
+ };
+ User user = new User(UserInfoResponseFake.RHLOGIN, UserInfoResponseFake.PASSWORD, cartridgeListService);
+ Collection<Cartridge> cartridges = user.getCartridges();
+ assertNotNull(cartridges);
+ assertEquals(5, cartridges.size());
+ assertThatContainsCartridge(CartridgeResponseFake.CARTRIDGE_JBOSSAS70, cartridges);
+ assertThatContainsCartridge(CartridgeResponseFake.CARTRIDGE_PERL5, cartridges);
+ assertThatContainsCartridge(CartridgeResponseFake.CARTRIDGE_PHP53, cartridges);
+ assertThatContainsCartridge(CartridgeResponseFake.CARTRIDGE_RACK11, cartridges);
+ assertThatContainsCartridge(CartridgeResponseFake.CARTRIDGE_WSGI32, cartridges);
+ }
+
+ @Test
+ public void canGetApplications() throws OpenshiftException {
+ /** response is UserInfoResponseFake */
+ Collection<Application> applications = user.getApplications();
+ assertNotNull(applications);
+ assertEquals(2, applications.size());
+ }
+
+ @Test
+ public void canGetApplicationByName() throws OpenshiftException, DatatypeConfigurationException {
+ Application application = user.getApplicationByName(UserInfoResponseFake.APP2_NAME);
+ assertApplication(
+ UserInfoResponseFake.APP2_NAME
+ , UserInfoResponseFake.APP2_UUID
+ , UserInfoResponseFake.APP2_CARTRIDGE
+ , UserInfoResponseFake.APP2_EMBEDDED
+ , UserInfoResponseFake.APP2_CREATION_TIME
+ , application);
+ }
+
+ private UserInfo createUserInfo() throws OpenshiftException, DatatypeConfigurationException {
+ ApplicationInfo[] applicationInfos = new ApplicationInfo[] {
+ new ApplicationInfo(UserInfoResponseFake.APP1_NAME
+ , UserInfoResponseFake.APP1_UUID
+ , UserInfoResponseFake.APP1_EMBEDDED
+ , Cartridge.valueOf(UserInfoResponseFake.APP1_CARTRIDGE)
+ , RFC822DateUtils.getDate(UserInfoResponseFake.APP1_CREATION_TIME))
+ , new ApplicationInfo(UserInfoResponseFake.APP2_NAME
+ , UserInfoResponseFake.APP2_UUID
+ , UserInfoResponseFake.APP2_EMBEDDED
+ , Cartridge.valueOf(UserInfoResponseFake.APP2_CARTRIDGE)
+ , RFC822DateUtils.getDate(UserInfoResponseFake.APP2_CREATION_TIME))
+ };
+ return new UserInfo(
+ UserInfoResponseFake.RHLOGIN
+ , UserInfoResponseFake.UUID
+ , UserInfoResponseFake.SSH_KEY
+ , UserInfoResponseFake.RHC_DOMAIN
+ , UserInfoResponseFake.NAMESPACE
+ , Arrays.asList(applicationInfos));
+ }
+
+ private OpenshiftService createUserInfoService(final UserInfo userInfo) {
+ return new NoopOpenshiftServiceFake() {
+
+ @Override
+ public UserInfo getUserInfo(User user) throws OpenshiftException {
+ return userInfo;
+ }
+ };
+ }
+}
Property changes on: trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/UserTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/fakes/ApplicationResponseFake.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/fakes/ApplicationResponseFake.java 2011-09-23 13:26:18 UTC (rev 34997)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/fakes/ApplicationResponseFake.java 2011-09-23 13:38:47 UTC (rev 34998)
@@ -19,8 +19,10 @@
*/
public class ApplicationResponseFake {
- public static final String USERNAME = "jbosstools(a)redhat.com";
+ public static final String RHLOGIN = "jbosstools(a)redhat.com";
public static final String PASSWORD = "$!445password%&";
+ public static final String UUID = "0123456789abcdefghijklmnopqrstuvwz";
+ public static final String SSHPUBLICKEY = "sshpublicKey&!%$123456";
public static final String RHC_DOMAIN = "rhcloud.com";
public static final String NAMESPACE = "1315839296868";
Added: trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/fakes/CartridgeResponseFake.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/fakes/CartridgeResponseFake.java (rev 0)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/fakes/CartridgeResponseFake.java 2011-09-23 13:38:47 UTC (rev 34998)
@@ -0,0 +1,45 @@
+package org.jboss.ide.eclipse.as.openshift.test.internal.core.fakes;
+
+/**
+ *
+ * @author André Dietisheim
+ *
+ */
+public class CartridgeResponseFake {
+
+ public static final String CARTRIDGE_PERL5 = "perl-5.10";
+ public static final String CARTRIDGE_JBOSSAS70 = "jbossas-7.0";
+ public static final String CARTRIDGE_WSGI32 = "wsgi-3.2";
+ public static final String CARTRIDGE_RACK11 = "rack-1.1";
+ public static final String CARTRIDGE_PHP53 = "php-5.3";
+
+ public static final String RESPONSE =
+ "{"
+ +" \"messages\":\"\","
+ +" \"debug\":\"\","
+ +" \"data\":\"{"
+ +" \\\"carts\\\":"
+ +" [\\\"" + CARTRIDGE_PERL5 +"\\\","
+ +" \\\"" + CARTRIDGE_JBOSSAS70 + "\\\","
+ +" \\\"" + CARTRIDGE_WSGI32+ "\\\","
+ +" \\\"" + CARTRIDGE_RACK11 + "\\\","
+ +" \\\"" + CARTRIDGE_PHP53 + "\\\"]"
+ +" }\","
+ +" \"api\":\"1.1.1\","
+ +" \"api_c\":[\"placeholder\"],"
+ +" \"result\":null,"
+ +" \"broker\":\"1.1.1\","
+ +" \"broker_c\":[\"namespace\","
+ +" \"rhlogin\","
+ +" \"ssh\","
+ +" \"app_uuid\","
+ +" \"debug\","
+ +" \"alter\","
+ +" \"cartridge\","
+ +" \"cart_type\","
+ +" \"action\","
+ +" \"app_name\","
+ +" \"api\"],"
+ +" \"exit_code\":0"
+ + "}";
+}
Property changes on: trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/fakes/CartridgeResponseFake.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/fakes/NoopOpenshiftServiceFake.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/fakes/NoopOpenshiftServiceFake.java 2011-09-23 13:26:18 UTC (rev 34997)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/fakes/NoopOpenshiftServiceFake.java 2011-09-23 13:38:47 UTC (rev 34998)
@@ -15,75 +15,64 @@
import org.jboss.ide.eclipse.as.openshift.core.Application;
import org.jboss.ide.eclipse.as.openshift.core.Cartridge;
import org.jboss.ide.eclipse.as.openshift.core.Domain;
-import org.jboss.ide.eclipse.as.openshift.core.IOpenshiftService;
import org.jboss.ide.eclipse.as.openshift.core.ISSHPublicKey;
import org.jboss.ide.eclipse.as.openshift.core.OpenshiftException;
-import org.jboss.ide.eclipse.as.openshift.core.SSHKeyPair;
+import org.jboss.ide.eclipse.as.openshift.core.User;
import org.jboss.ide.eclipse.as.openshift.core.UserInfo;
+import org.jboss.ide.eclipse.as.openshift.core.internal.OpenshiftService;
/**
* @author André Dietisheim
*/
-public class NoopOpenshiftServiceFake implements IOpenshiftService {
+public class NoopOpenshiftServiceFake extends OpenshiftService {
@Override
- public UserInfo getUserInfo() throws OpenshiftException {
+ public UserInfo getUserInfo(User user) throws OpenshiftException {
throw new UnsupportedOperationException();
}
@Override
- public List<Cartridge> getCartridges() throws OpenshiftException {
+ public List<Cartridge> getCartridges(User user) throws OpenshiftException {
throw new UnsupportedOperationException();
}
@Override
- public Application createApplication(String name, Cartridge cartridge) throws OpenshiftException {
+ public Application createApplication(String name, Cartridge cartridge, User user) throws OpenshiftException {
throw new UnsupportedOperationException();
}
@Override
- public Application destroyApplication(String name, Cartridge cartridge) throws OpenshiftException {
+ public Application destroyApplication(String name, Cartridge cartridge, User user) throws OpenshiftException {
throw new UnsupportedOperationException();
}
@Override
- public Application startApplication(String name, Cartridge cartridge) throws OpenshiftException {
+ public Application startApplication(String name, Cartridge cartridge, User user) throws OpenshiftException {
throw new UnsupportedOperationException();
}
@Override
- public Application restartApplication(String name, Cartridge cartridge) throws OpenshiftException {
+ public Application restartApplication(String name, Cartridge cartridge, User user) throws OpenshiftException {
throw new UnsupportedOperationException();
}
@Override
- public Application stopApplication(String name, Cartridge cartridge) throws OpenshiftException {
+ public Application stopApplication(String name, Cartridge cartridge, User user) throws OpenshiftException {
throw new UnsupportedOperationException();
}
@Override
- public String getStatus(String applicationName, Cartridge cartridge) throws OpenshiftException {
+ public String getStatus(String applicationName, Cartridge cartridge, User user) throws OpenshiftException {
throw new UnsupportedOperationException();
}
@Override
- public Domain changeDomain(String domainName, ISSHPublicKey sshKey) throws OpenshiftException {
+ public Domain changeDomain(String domainName, ISSHPublicKey sshKey, User user) throws OpenshiftException {
throw new UnsupportedOperationException();
}
@Override
- public Domain createDomain(String name, ISSHPublicKey keyPair) throws OpenshiftException {
+ public Domain createDomain(String name, ISSHPublicKey keyPair, User user) throws OpenshiftException {
throw new UnsupportedOperationException();
}
-
- @Override
- public SSHKeyPair createKey(String passPhrase, String privateKeyPath, String publicKeyPath) throws OpenshiftException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public SSHKeyPair loadKey(String privateKeyPath, String publicKeyPath) throws OpenshiftException {
- throw new UnsupportedOperationException();
- }
-
}
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/fakes/UserInfoResponseFake.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/fakes/UserInfoResponseFake.java 2011-09-23 13:26:18 UTC (rev 34997)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/fakes/UserInfoResponseFake.java 2011-09-23 13:38:47 UTC (rev 34998)
@@ -2,7 +2,7 @@
public class UserInfoResponseFake {
- public static final String USERNAME = "jbosstools(a)redhat.com";
+ public static final String RHLOGIN = "jbosstools(a)redhat.com";
public static final String PASSWORD = "$!445password%&";
public static final String RHC_DOMAIN = "rhcloud.com";
@@ -36,7 +36,7 @@
+ " \\\"user_info\\\":"
+ " {"
+ " \\\"rhc_domain\\\":\\\"" + RHC_DOMAIN + "\\\"," //
- + " \\\"rhlogin\\\":\\\"" + USERNAME + "\\\","
+ + " \\\"rhlogin\\\":\\\"" + RHLOGIN + "\\\","
+ " \\\"namespace\\\":\\\"" + NAMESPACE + "\\\","
+ " \\\"uuid\\\":\\\"" + UUID + "\\\","
+ " \\\"ssh_key\\\":\\\"" + SSH_KEY + "\\\""
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/utils/ApplicationAsserts.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/utils/ApplicationAsserts.java 2011-09-23 13:26:18 UTC (rev 34997)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/utils/ApplicationAsserts.java 2011-09-23 13:38:47 UTC (rev 34998)
@@ -34,7 +34,7 @@
if (application == null) {
fail(MessageFormat.format("Could not find application with name \"{0}\"", applicationName));
}
- assertApplication(embedded, applicationUUID, cartridgeName, creationTime, application);
+ assertApplication(applicationName, applicationUUID, cartridgeName, embedded, creationTime, application);
}
public static void assertThatContainsApplication(String applicationName, List<Application> applications) {
@@ -51,8 +51,8 @@
}
return matchingApplication;
}
-
- private static void assertApplication(String embedded, String uuid, String cartridgeName,
+
+ public static void assertApplication(String name, String uuid, String cartridgeName, String embedded,
String creationTime, Application application) throws OpenshiftException {
assertEquals(embedded, application.getEmbedded());
assertEquals(uuid, application.getUUID());
Added: trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/utils/ApplicationInfoAsserts.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/utils/ApplicationInfoAsserts.java (rev 0)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/utils/ApplicationInfoAsserts.java 2011-09-23 13:38:47 UTC (rev 34998)
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.openshift.test.internal.core.utils;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import java.text.MessageFormat;
+import java.util.List;
+
+import javax.xml.datatype.DatatypeConfigurationException;
+
+import org.jboss.ide.eclipse.as.openshift.core.ApplicationInfo;
+import org.jboss.ide.eclipse.as.openshift.core.OpenshiftException;
+import org.jboss.ide.eclipse.as.openshift.core.internal.utils.RFC822DateUtils;
+
+/**
+ * @author André Dietisheim
+ */
+public class ApplicationInfoAsserts {
+
+ public static void assertThatContainsApplicationInfo(String applicationName, String embedded, String applicationUUID,
+ String cartridgeName, String creationTime, List<ApplicationInfo> applicationInfos) throws OpenshiftException {
+ ApplicationInfo applicationInfo = getApplicationInfo(applicationName, applicationInfos);
+ if (applicationInfo == null) {
+ fail(MessageFormat.format("Could not find application with name \"{0}\"", applicationName));
+ }
+ assertApplicationInfo(embedded, applicationUUID, cartridgeName, creationTime, applicationInfo);
+ }
+
+ public static void assertThatContainsApplicationInfo(String applicationName, List<ApplicationInfo> applicationInfos) {
+ assertNotNull(getApplicationInfo(applicationName, applicationInfos));
+ }
+
+ private static ApplicationInfo getApplicationInfo(String name, List<ApplicationInfo> applicationInfos) {
+ ApplicationInfo matchingApplicationInfo = null;
+ for (ApplicationInfo applicationInfo : applicationInfos) {
+ if (name.equals(applicationInfo.getName())) {
+ matchingApplicationInfo = applicationInfo;
+ break;
+ }
+ }
+ return matchingApplicationInfo;
+ }
+
+ private static void assertApplicationInfo(String embedded, String uuid, String cartridgeName,
+ String creationTime, ApplicationInfo applicationInfo) throws OpenshiftException {
+ assertEquals(embedded, applicationInfo.getEmbedded());
+ assertEquals(uuid, applicationInfo.getUuid());
+ assertNotNull(applicationInfo.getCartridge());
+ assertEquals(cartridgeName, applicationInfo.getCartridge().getName());
+ try {
+ assertEquals(RFC822DateUtils.getDate(creationTime), applicationInfo.getCreationTime());
+ } catch (DatatypeConfigurationException e) {
+ fail(e.getMessage());
+ }
+ }
+
+}
Property changes on: trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/utils/ApplicationInfoAsserts.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/utils/CartridgeAsserts.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/utils/CartridgeAsserts.java 2011-09-23 13:26:18 UTC (rev 34997)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/utils/CartridgeAsserts.java 2011-09-23 13:38:47 UTC (rev 34998)
@@ -13,13 +13,16 @@
import static org.junit.Assert.fail;
import java.text.MessageFormat;
-import java.util.List;
+import java.util.Collection;
import org.jboss.ide.eclipse.as.openshift.core.Cartridge;
+/**
+ * @author André Dietisheim
+ */
public class CartridgeAsserts {
- public static void assertThatContainsCartridge(String cartridgeName, List<Cartridge> cartridges) {
+ public static void assertThatContainsCartridge(String cartridgeName, Collection<Cartridge> cartridges) {
boolean found = false;
for (Cartridge cartridge : cartridges) {
if (cartridgeName.equals(cartridge.getName())) {
14 years, 6 months
JBoss Tools SVN: r34997 - workspace/yradtsevich/browsersim.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2011-09-23 09:26:18 -0400 (Fri, 23 Sep 2011)
New Revision: 34997
Added:
workspace/yradtsevich/browsersim/browsersim-frame.html
Log:
https://issues.jboss.org/browse/JBIDE-9539
Added: workspace/yradtsevich/browsersim/browsersim-frame.html
===================================================================
--- workspace/yradtsevich/browsersim/browsersim-frame.html (rev 0)
+++ workspace/yradtsevich/browsersim/browsersim-frame.html 2011-09-23 13:26:18 UTC (rev 34997)
@@ -0,0 +1,87 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.js"></script>
+ <script src="http://swip.codylindley.com/jquery.popupWindow.js"></script>
+ <script>
+ $(function(){
+ $('#height').val(800);
+ $('#width').val(480);
+ $('.size-field').blur(function(){
+ update_size();
+ });
+ update_size();
+
+ $('#user-agent').val('Mozilla/5.0 (Linux; U; Android 2.1-update1; en-us;) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17');
+
+ $('#url').val('http://www.yahoo.com');
+ $('#iframe-browse').click(function() {
+ go_to_url_iframe();
+ });
+ $('#new-window-browse').click(function() {
+ go_to_url_new_window();
+ });
+ });
+
+ function update_size() {
+ var width = $('#width').val();
+ var height = $('#height').val();
+ if (96 <= height && height <= 2048 &&
+ 96 <= width && width <= 2048) {
+ $('#sim-frame').width(width);
+ $('#sim-frame').height(height);
+ }
+ }
+
+ function go_to_url_iframe() {
+ $('#sim-frame').attr('src', $('#url').val());
+ }
+
+ function go_to_url_new_window() {
+ var width = $('#width').val();
+ var height = $('#height').val();
+ if (96 <= height && height <= 2048 &&
+ 96 <= width && width <= 2048) {
+ window.open($('#url').val(), '', 'width=' + width +',height=' + height);
+ }
+ }
+ </script>
+</head>
+<body>
+ NOTE: To change the user-agent header, you need to run Chrome/Chromium with the following parameters:
+ <pre>chrome.exe --user-agent="Mozilla/5.0 (Linux; U; Android 2.1-update1; en-us;) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17"</pre>
+ <table>
+ <tr>
+ <td>Height:</td>
+ <td><input id="height" class="size-field" type="text"/></td>
+ <td>Must be between 96 and 2048. Would be selectable.</td>
+ </tr>
+ <tr>
+ <td>Width:</td>
+ <td><input id="width" class="size-field" type="text"/></td>
+ <td>Must be between 96 and 2048. Would be selectable.</td>
+ </tr>
+ <tr>
+ <td>User-Agent:</td>
+ <td><input id="user-agent" type="text"/></td>
+ <td>Does not affect anything yet (see the note above). Would be selectable.</td>
+ </tr>
+ <tr>
+ <td>URL:</td>
+ <td><input id="url" type="text"/></td>
+ <td>
+ <input id="iframe-browse" type="button" value="Browse in iframe">
+ <input id="new-window-browse" type="button" value="Browse in new window">
+ </td>
+
+ </tr>
+ </table>
+ <div style="text-align:center">
+ <div>
+ <input type="button" onclick="parent.simFrame.history.back();" value="<">
+ <input type="button" onclick="parent.simFrame.history.forward();" value=">">
+ </div>
+ <iframe name="simFrame" id="sim-frame"></iframe>
+ </div>
+</body>
+</html>
\ No newline at end of file
14 years, 6 months
JBoss Tools SVN: r34995 - in trunk/jsf/plugins/org.jboss.tools.jsf: META-INF and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2011-09-23 08:12:37 -0400 (Fri, 23 Sep 2011)
New Revision: 34995
Added:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/XHTMLValidator.java
Removed:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/XHTMLSyntaxValidator.java
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/META-INF/MANIFEST.MF
trunk/jsf/plugins/org.jboss.tools.jsf/plugin.properties
trunk/jsf/plugins/org.jboss.tools.jsf/plugin.xml
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/JSFValidationMessage.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/messages.properties
Log:
JBIDE-9588
Poor performance of XHTML template validation
XHTML Syntax Validator is re-factored
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/META-INF/MANIFEST.MF
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/META-INF/MANIFEST.MF 2011-09-23 11:38:13 UTC (rev 34994)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/META-INF/MANIFEST.MF 2011-09-23 12:12:37 UTC (rev 34995)
@@ -64,9 +64,9 @@
org.eclipse.wst.sse.ui;bundle-version="1.3.0",
org.eclipse.ltk.ui.refactoring;bundle-version="3.5.100",
org.eclipse.core.expressions;bundle-version="3.4.200",
- org.jboss.tools.common.text.ext;bundle-version="3.1.0",
+ org.jboss.tools.common.text.ext,
org.eclipse.jst.jsp.ui;bundle-version="1.1.600";visibility:=reexport,
- org.jboss.tools.jst.jsp;bundle-version="3.2.0",
+ org.jboss.tools.jst.jsp,
org.jboss.tools.common.validation
Bundle-Version: 3.3.0.qualifier
Bundle-ActivationPolicy: lazy
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/plugin.properties
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/plugin.properties 2011-09-23 11:38:13 UTC (rev 34994)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/plugin.properties 2011-09-23 12:12:37 UTC (rev 34995)
@@ -20,4 +20,6 @@
JSFELValidationDelegate=JSF EL Validator
ComponentCompositeProblemName=JSF Composite Component Problem
-ComponentCompositeValidator=JSF Composite Component Validator
\ No newline at end of file
+ComponentCompositeValidator=JSF Composite Component Validator
+
+XHTMLSyntaxProblemName=XHTML Problem
\ No newline at end of file
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/plugin.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/plugin.xml 2011-09-23 11:38:13 UTC (rev 34994)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/plugin.xml 2011-09-23 12:12:37 UTC (rev 34995)
@@ -391,16 +391,15 @@
</listener>
</extension>
-<!-- TODO https://issues.jboss.org/browse/JBIDE-9588
<extension id="xhtml" name="%XHTML_Validator.name"
point="org.eclipse.wst.validation.validatorV2">
<validator
build="true"
- class="org.jboss.tools.jsf.web.validation.XHTMLSyntaxValidator"
+ class="org.jboss.tools.jsf.web.validation.XHTMLValidator"
manual="true"
sourceid="org.eclipse.wst.xml.ui.internal.validation.DelegatingSourceValidatorForXML"
version="3"
- markerId="org.eclipse.wst.xml.core.validationMarker"
+ markerId="org.jboss.tools.jsf.xhtmlsyntaxproblem"
>
<include>
<rules>
@@ -421,7 +420,7 @@
</rules>
</include>
</validator>
- </extension -->
+ </extension>
<extension point="org.eclipse.wst.xml.core.catalogContributions">
<catalogContribution id="default">
@@ -499,6 +498,13 @@
</persistent>
</extension>
+ <extension id="xhtmlsyntaxproblem" name="%XHTMLSyntaxProblemName" point="org.eclipse.core.resources.markers">
+ <super type="org.eclipse.wst.xml.core.validationMarker">
+ </super>
+ <persistent value="true">
+ </persistent>
+ </extension>
+
<extension
id="CompositeComponentValidator"
point="org.jboss.tools.common.validation.validator">
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/JSFValidationMessage.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/JSFValidationMessage.java 2011-09-23 11:38:13 UTC (rev 34994)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/JSFValidationMessage.java 2011-09-23 12:12:37 UTC (rev 34995)
@@ -14,8 +14,10 @@
public static String VALIDATING_PROJECT;
public static String XHTML_VALIDATION;
-
+ public static String XHTML_VALIDATION_NO_START_TAG;
+ public static String XHTML_VALIDATION_NO_END_TAG;
+
static {
NLS.initializeMessages(BUNDLE_NAME, JSFValidationMessage.class);
}
-}
\ No newline at end of file
+}
Deleted: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/XHTMLSyntaxValidator.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/XHTMLSyntaxValidator.java 2011-09-23 11:38:13 UTC (rev 34994)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/XHTMLSyntaxValidator.java 2011-09-23 12:12:37 UTC (rev 34995)
@@ -1,304 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.jboss.tools.jsf.web.validation;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.io.StringReader;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolverPlugin;
-import org.eclipse.wst.validation.ValidationResult;
-import org.eclipse.wst.validation.ValidationState;
-import org.eclipse.wst.xml.core.internal.validation.ValidatorHelper;
-import org.eclipse.wst.xml.core.internal.validation.XMLValidationConfiguration;
-import org.eclipse.wst.xml.core.internal.validation.XMLValidationInfo;
-import org.eclipse.wst.xml.core.internal.validation.XMLValidationReport;
-import org.eclipse.wst.xml.core.internal.validation.core.NestedValidatorContext;
-import org.eclipse.wst.xml.core.internal.validation.core.ValidationReport;
-import org.eclipse.wst.xml.core.internal.validation.eclipse.ErrorCustomizationPluginRegistryReader;
-import org.eclipse.wst.xml.core.internal.validation.eclipse.Validator;
-import org.jboss.tools.jsf.JSFModelPlugin;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXNotRecognizedException;
-import org.xml.sax.SAXNotSupportedException;
-import org.xml.sax.SAXParseException;
-import org.xml.sax.XMLReader;
-import org.xml.sax.ext.LexicalHandler;
-
-/**
- * Syntax Validator for XHTML files.
- * @author Victor Rubezhny
- */
-public class XHTMLSyntaxValidator extends Validator {
-
- IProgressMonitor monitor;
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.wst.xml.core.internal.validation.eclipse.Validator#validationStarting(org.eclipse.core.resources.IProject, org.eclipse.wst.validation.ValidationState, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void validationStarting(IProject project, ValidationState state, IProgressMonitor monitor) {
- super.validationStarting(project, state, monitor);
- this.monitor = monitor;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.wst.xml.core.internal.validation.core.AbstractNestedValidator#validate(org.eclipse.core.resources.IResource, int, org.eclipse.wst.validation.ValidationState, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public ValidationResult validate(IResource resource, int kind, ValidationState state, IProgressMonitor monitor) {
- displaySubtask(monitor, JSFValidationMessage.XHTML_VALIDATION, resource.getFullPath());
- return super.validate(resource, kind, state, monitor);
- }
-
- private void displaySubtask(String message, Object... arguments) {
- displaySubtask(monitor, MessageFormat.format(message, arguments));
- }
-
- private void displaySubtask(IProgressMonitor monitor, String message, Object... arguments) {
- if(monitor!=null) {
- monitor.subTask(MessageFormat.format(message, arguments));
- }
- }
-
- /**
- * The method is overridden to setup our own XMLValidator to be used
- */
- @Override
- public ValidationReport validate(String uri, InputStream inputstream,
- NestedValidatorContext context, ValidationResult result) {
-
- displaySubtask(JSFValidationMessage.XHTML_VALIDATION, uri);
-
- long ct = 0;
- if (JSFModelPlugin.getDefault().isDebugging()) {
- ct = System.currentTimeMillis();
- }
-
- XMLValidator validator = XMLValidator.getInstance();
-
- XMLValidationConfiguration configuration = new XMLValidationConfiguration();
- try {
- configuration.setFeature(XMLValidationConfiguration.INDICATE_NO_GRAMMAR, 0); // None. No grammar indication is needed
- } catch (Exception e) {
- // Unable to set the preference. Log this problem.
- JSFModelPlugin.log("XHTMLSyntaxValidator was unable to set the preference", e);
- }
-
- XMLValidationReport valreport = validator.validate(uri, inputstream, configuration, context, result);
-
- if (JSFModelPlugin.getDefault().isDebugging()) {
- long et = System.currentTimeMillis() - ct;
- System.out.println("XHTMLSyntaxValidator: Elapsed time = " + (et) + " ms for " + uri);
- }
- return valreport;
- }
-
- /**
- * An XML validator specific to XHTML-files validation. This validator will wrap the internal
- * XML syntax validator.
- */
- public static class XMLValidator extends org.eclipse.wst.xml.core.internal.validation.XMLValidator {
- private static XMLValidator instance = null;
-
- /**
- * Return the one and only instance of the XML validator. The validator
- * can be reused and cannot be customized so there should only be one instance of it.
- *
- * @return The one and only instance of the XML validator.
- */
- public static XMLValidator getInstance() {
- if(instance == null) {
- instance = new XMLValidator();
- }
- return instance;
- }
-
- /**
- * Constructor. Create the XML validator, set the URI resolver and
- * get the extension error customizers from the registry.
- */
- protected XMLValidator() {
- setURIResolver(URIResolverPlugin.createResolver());
- new ErrorCustomizationPluginRegistryReader().readRegistry();
- }
-
- /**
- * Validate the inputStream
- *
- * @param uri
- * The URI of the file to validate.
- * @param inputstream
- * The inputStream of the file to validate
- * @param configuration
- * A configuration for this validation session.
- * @param result
- * The validation result
- * @return
- * Returns an XML validation report.
- */
- public XMLValidationReport validate(String uri, InputStream inputStream,
- XMLValidationConfiguration configuration, NestedValidatorContext context, ValidationResult result) {
- String grammarFile = "";
- Reader reader1 = null; // Used for the preparse.
- Reader reader2 = null; // Used for validation parse.
-
- if (inputStream != null) {
- String string = createStringForInputStream(inputStream);
- reader1 = new StringReader(string);
- reader2 = new StringReader(string);
- }
-
- XMLValidationInfo valinfo = new XMLValidationInfo(uri);
- XHTMLEntityResolver entityResolver = new XHTMLEntityResolver(uriResolver, context);
- XHTMLValidatorHelper helper = new XHTMLValidatorHelper(entityResolver);
-
- try {
- helper.computeValidationInformation(uri, reader1, uriResolver);
-
- // The syntax validation is to be performed
- valinfo.setDTDEncountered(false);
- valinfo.setElementDeclarationCount(0);
- valinfo.setNamespaceEncountered(false);
- valinfo.setGrammarEncountered(false);
-
- // No validation needed for native HTML files
- // The only XHTML files are to be validated here
- if (!helper.isXHTMLDoctype) {
- return valinfo;
- }
-
- XMLReader reader = createXMLReader(valinfo, entityResolver);
- XMLErrorHandler errorhandler = new XMLErrorHandler(valinfo);
- reader.setErrorHandler(errorhandler);
-
- InputSource inputSource = new InputSource(uri);
- inputSource.setCharacterStream(reader2);
- reader.parse(inputSource);
- } catch (SAXParseException saxParseException) {
- // These errors are caught by the error handler.
- //addValidationMessage(valinfo, saxParseException);
- } catch (IOException ioException) {
- addValidationMessage(valinfo, ioException);
- } catch (Exception exception) {
- JSFModelPlugin.log(exception.getLocalizedMessage(), exception);
- }
-
- // Now set up the dependencies
- // Wrap with try catch so that if something wrong happens, validation can
- // still proceed as before
- if (result != null) {
- try {
- IResource resource = getWorkspaceFileFromLocation(grammarFile);
- ArrayList resources = new ArrayList();
- if (resource != null)
- resources.add(resource);
- result.setDependsOn((IResource [])resources.toArray(new IResource [0]));
- } catch (Exception e) {
- JSFModelPlugin.log(e.getLocalizedMessage(), e);
- }
- }
- return valinfo;
- }
-
- final String createStringForInputStream(InputStream inputStream) {
- // Here we are reading the file and storing to a stringbuffer.
- StringBuilder fileString = new StringBuilder();
- try {
- InputStreamReader inputReader = new InputStreamReader(inputStream, "UTF-8");
- BufferedReader reader = new BufferedReader(inputReader);
- char[] chars = new char[1024];
- int numberRead = reader.read(chars);
- while (numberRead != -1) {
- fileString.append(chars, 0, numberRead);
- numberRead = reader.read(chars);
- }
- } catch (Exception e) {
- JSFModelPlugin.log(e.getLocalizedMessage(), e);
- }
- return fileString.toString();
- }
-
- /*
- * Custom validation helper to be used
- */
- class XHTMLValidatorHelper extends ValidatorHelper {
- public boolean isXHTMLDoctype = false;
- private XHTMLEntityResolver entityResolver;
-
- public XHTMLValidatorHelper(XHTMLEntityResolver entityResolver) {
- this.entityResolver = entityResolver;
- }
-
- protected XMLReader createXMLReader(String uri) throws SAXNotRecognizedException, SAXNotSupportedException
- {
- XMLReader reader = super.createXMLReader(uri);
-
- reader.setFeature("http://xml.org/sax/features/namespaces", false);
- reader.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
- reader.setFeature("http://xml.org/sax/features/validation", false);
- reader.setFeature("http://apache.org/xml/features/validation/schema", false);
- reader.setFeature("http://apache.org/xml/features/validation/schema-full-checking", false);
- reader.setFeature("http://apache.org/xml/features/validation/dynamic", false);
- reader.setFeature("http://apache.org/xml/features/continue-after-fatal-error", false);
- reader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
-// reader.setFeature("http://apache.org/xml/features/resolve-dtd-uris", false);
-
- LexicalHandler lexicalHandler = new LexicalHandler()
- {
- public void startDTD (String name, String publicId, String systemId) {
- isGrammarEncountered = true;
- isDTDEncountered = true;
- if (publicId != null && publicId.indexOf("W3C") != -1 &&
- publicId.indexOf("DTD") != -1 && publicId.indexOf("XHTML") != -1) {
- isXHTMLDoctype = true;
- }
- }
-
- public void endDTD() throws SAXException {
- }
-
- public void startEntity(String name) throws SAXException {
- }
-
- public void endEntity(String name) throws SAXException {
- }
-
- public void startCDATA() throws SAXException {
- }
-
- public void endCDATA() throws SAXException {
- }
-
- public void comment (char ch[], int start, int length) throws SAXException {
- }
- };
- reader.setProperty("http://xml.org/sax/properties/lexical-handler", lexicalHandler); //$NON-NLS-1$
- if (entityResolver != null) {
- reader.setProperty("http://apache.org/xml/properties/internal/entity-resolver", entityResolver); //$NON-NLS-1$
- }
- return reader;
- }
- }
- }
-}
\ No newline at end of file
Added: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/XHTMLValidator.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/XHTMLValidator.java (rev 0)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/XHTMLValidator.java 2011-09-23 12:12:37 UTC (rev 34995)
@@ -0,0 +1,475 @@
+/*******************************************************************************
+ * Copyright (c) 2009-2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.web.validation;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Stack;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.wst.validation.ValidationResult;
+import org.eclipse.wst.validation.ValidationState;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+import org.eclipse.wst.xml.core.internal.validation.XMLValidationInfo;
+import org.eclipse.wst.xml.core.internal.validation.core.NestedValidatorContext;
+import org.eclipse.wst.xml.core.internal.validation.core.ValidationMessage;
+import org.eclipse.wst.xml.core.internal.validation.core.ValidationReport;
+import org.eclipse.wst.xml.core.internal.validation.eclipse.Validator;
+import org.jboss.tools.common.util.FileUtil;
+import org.jboss.tools.jsf.JSFModelPlugin;
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.ext.LexicalHandler;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ *
+ * @author Victor V. Rubezhny
+ *
+ */
+@SuppressWarnings("restriction")
+public class XHTMLValidator extends Validator {
+ private static final String END_TAG_STRATEGY = "END_TAG";
+ private static final String START_TAG_STRATEGY = "START_TAG";
+ private static final String NO_START_TAG = "NO_START_TAG";
+ private static final String NO_END_TAG = "NO_END_TAG";
+
+ IProgressMonitor monitor;
+ IResource resource;
+
+ public boolean isXHTMLDoctype = false;
+
+ private String[] SAX_PARSER_FEATURES_TO_DISABLE = {
+ "http://xml.org/sax/features/namespaces",
+ "http://xml.org/sax/features/use-entity-resolver2",
+ "http://xml.org/sax/features/validation",
+ "http://apache.org/xml/features/validation/dynamic",
+ "http://apache.org/xml/features/validation/schema",
+ "http://apache.org/xml/features/validation/schema-full-checking",
+ "http://apache.org/xml/features/nonvalidating/load-external-dtd",
+ "http://apache.org/xml/features/nonvalidating/load-dtd-grammar",
+ "http://apache.org/xml/features/xinclude",
+ "http://xml.org/sax/features/resolve-dtd-uris"
+ };
+ private String[] SAX_PARSER_FEATURES_TO_ENABLE = {
+ "http://apache.org/xml/features/continue-after-fatal-error"
+ };
+
+ private void setSAXParserFeatures(SAXParser saxParser, String[] features, boolean set) {
+ XMLReader reader;
+ try {
+ reader = saxParser.getXMLReader();
+ } catch (SAXException e) {
+ JSFModelPlugin.getDefault().logError(e);
+ return;
+ }
+ for (String feature : features) {
+ try {
+ reader.setFeature(feature, set);
+ } catch (SAXException e) {
+ JSFModelPlugin.getDefault().logError(e);
+ }
+ }
+ }
+
+ private void setSAXParserProperty(SAXParser saxParser, String property, Object value) {
+ XMLReader reader;
+ try {
+ reader = saxParser.getXMLReader();
+ reader.setProperty(property, value);
+ } catch (SAXException e) {
+ JSFModelPlugin.getDefault().logError(e);
+ }
+ }
+
+ private IDocument getDocument(IFile file) {
+ if (file == null)
+ return null;
+
+ String content;
+ try {
+ content = FileUtil.readStream(file);
+ } catch (CoreException e) {
+ JSFModelPlugin.getDefault().logError(e);
+ return null;
+ }
+
+ return (content == null ? null : new Document(content));
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.wst.xml.core.internal.validation.core.AbstractNestedValidator#validate(org.eclipse.core.resources.IResource, int, org.eclipse.wst.validation.ValidationState, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public ValidationResult validate(IResource resource, int kind, ValidationState state, IProgressMonitor monitor) {
+ displaySubtask(monitor, JSFValidationMessage.XHTML_VALIDATION, resource.getFullPath());
+ this.resource = resource;
+ return super.validate(resource, kind, state, monitor);
+ }
+
+ @Override
+ public ValidationReport validate(String uri, InputStream inputstream,
+ NestedValidatorContext context) {
+ displaySubtask(JSFValidationMessage.XHTML_VALIDATION, uri);
+ this.resource = null;
+ return super.validate(uri, inputstream, context);
+ }
+
+ @Override
+ public ValidationReport validate(String uri, InputStream inputstream,
+ NestedValidatorContext context, ValidationResult result) {
+ displaySubtask(JSFValidationMessage.XHTML_VALIDATION, uri);
+ XMLValidationInfo report = new XMLValidationInfo(uri);
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ XHTMLElementHandler handler = new XHTMLElementHandler(
+ (resource instanceof IFile ? getDocument((IFile)resource) : null),
+ report);
+ SAXParser saxParser = null;
+ try {
+ saxParser = factory.newSAXParser();
+ setSAXParserFeatures(saxParser, SAX_PARSER_FEATURES_TO_DISABLE, false);
+ setSAXParserFeatures(saxParser, SAX_PARSER_FEATURES_TO_ENABLE, true);
+ setSAXParserProperty(saxParser, "http://xml.org/sax/properties/lexical-handler", handler);
+ isXHTMLDoctype = false;
+ if (inputstream != null) {
+ saxParser.parse(inputstream, handler);
+ } else {
+ saxParser.parse(uri, handler);
+ }
+ } catch (ParserConfigurationException e) {
+ JSFModelPlugin.getDefault().logError(e);
+ report.addError(e.getLocalizedMessage(), 0, 0, uri);
+ } catch (SAXException e) {
+ JSFModelPlugin.getDefault().logError(e);
+ report.addError(e.getLocalizedMessage(), 0, 0, uri);
+ } catch (IOException e) {
+ JSFModelPlugin.getDefault().logError(e);
+ report.addError(e.getLocalizedMessage(), 0, 0, uri);
+ }
+
+ List<ElementLocation> locations = handler.getNonPairedOpenElements();
+ if (!locations.isEmpty()) {
+ for (ElementLocation location : locations) {
+ String messageText = MessageFormat.format(JSFValidationMessage.XHTML_VALIDATION_NO_END_TAG, location.getName());
+ report.addError(messageText, location.getLine(), location.getColumn(), uri, NO_END_TAG, new Object[] {location});
+ }
+ }
+
+ locations = handler.getNonPairedCloseElements();
+ if (!locations.isEmpty()) {
+ for (ElementLocation location : locations) {
+ String messageText = MessageFormat.format(JSFValidationMessage.XHTML_VALIDATION_NO_START_TAG, location.getName());
+ report.addError(messageText, location.getLine(), location.getColumn(), uri, NO_START_TAG, new Object[] {location});
+ }
+ }
+
+ return report;
+ }
+
+ @Override
+ protected void addInfoToMessage(ValidationMessage validationMessage,
+ IMessage message) {
+ ElementLocation location = validationMessage.getMessageArguments() == null || validationMessage.getMessageArguments().length < 1 ?
+ null: (ElementLocation)validationMessage.getMessageArguments()[0];
+
+ String nameOrValue = location == null ? "" : location.getName();
+ String key = validationMessage.getKey();
+ if(key != null && (NO_START_TAG.equals(key) || NO_END_TAG.equals(key)) )
+ {
+ String selectionStrategy = START_TAG_STRATEGY;
+ if (NO_START_TAG.equals(key)) {
+ selectionStrategy = START_TAG_STRATEGY;
+ } else if (NO_END_TAG.equals(key)) {
+ selectionStrategy = END_TAG_STRATEGY;
+ }
+ message.setAttribute(COLUMN_NUMBER_ATTRIBUTE, new Integer(validationMessage.getColumnNumber()));
+ message.setAttribute(SQUIGGLE_SELECTION_STRATEGY_ATTRIBUTE, selectionStrategy);
+ message.setAttribute(SQUIGGLE_NAME_OR_VALUE_ATTRIBUTE, nameOrValue);
+ if (location != null) {
+ message.setLineNo(location.getLine());
+ message.setOffset(location.getStart());
+ message.setLength(location.getLength());
+ }
+ } else {
+ super.addInfoToMessage(validationMessage, message);
+ }
+ }
+
+ @Override
+ public void validationStarting(IProject project, ValidationState state,
+ IProgressMonitor monitor) {
+ super.validationStarting(project, state, monitor);
+ this.monitor = monitor;
+ }
+
+ private void displaySubtask(String message, Object... arguments) {
+ displaySubtask(monitor, MessageFormat.format(message, arguments));
+ }
+
+ private void displaySubtask(IProgressMonitor monitor, String message, Object... arguments) {
+ if(monitor!=null) {
+ monitor.subTask(MessageFormat.format(message, arguments));
+ }
+ }
+
+ class ElementLocation {
+ String name;
+ int line;
+ int column;
+ int start;
+ int length;
+
+ ElementLocation (String name, int line, int column, int start, int length) {
+ this.name = name;
+ this.line = line;
+ this.column = column;
+ this.start = start;
+ this.length = length;
+ }
+
+ String getName() {
+ return name;
+ }
+
+ int getLine() {
+ return line;
+ }
+
+ int getColumn() {
+ return column;
+ }
+
+ int getStart() {
+ return start;
+ }
+
+ int getLength() {
+ return length;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("'");
+ sb.append(name);
+ sb.append("', Line: ");
+ sb.append(line);
+ sb.append(", Column: ");
+ sb.append(column);
+ sb.append(", start: ");
+ sb.append(start);
+ sb.append(", end: ");
+ sb.append((start + length));
+ sb.append(", length: ");
+ sb.append(length);
+ return sb.toString();
+ }
+ }
+
+ class XHTMLElementHandler extends DefaultHandler implements LexicalHandler {
+ private Locator locator;
+ private IDocument document;
+ private XMLValidationInfo valinfo;
+
+ List<ElementLocation> elements = new ArrayList<ElementLocation>();
+ Stack<ElementLocation> nonPairedOpenElements = new Stack<XHTMLValidator.ElementLocation>();
+ Stack<ElementLocation> nonPairedCloseElements = new Stack<XHTMLValidator.ElementLocation>();
+
+ public XHTMLElementHandler(IDocument document, XMLValidationInfo valinfo) {
+ super();
+ this.document = document;
+ this.valinfo = valinfo;
+ }
+
+ @Override
+ public void setDocumentLocator(Locator locator) {
+ this.locator = locator;
+ }
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
+ if (!isXHTMLDoctype)
+ return;
+
+ int end = getCurrentLocation(), start = 0;
+ if(end > 0) {
+ start = document.get().lastIndexOf("<", end - 1);
+ }
+ currentElementLocation = new ElementLocation(qName, getLine(start), getColumn(start), start, end - start);
+ nonPairedOpenElements.push(currentElementLocation);
+ }
+
+ ElementLocation currentElementLocation = null;
+ @Override
+ public void endElement(String uri, String localName, String qName) throws SAXException {
+ if (!isXHTMLDoctype)
+ return;
+
+ int end = getCurrentLocation(), start = 0;
+ if(end > 0) {
+ start = document.get().lastIndexOf('<', end - 1);
+ }
+ if (document.get().charAt(end - 1) != '>') {
+ int newEnd = document.get().indexOf('>', end);
+ if (newEnd > 0) {
+ qName = getName(document.get().substring(start, newEnd));
+ end = newEnd+1;
+ }
+ }
+ currentElementLocation = new ElementLocation(qName, getLine(start), getColumn(start), start, end - start);
+ // Try to find according pair open element
+ ElementLocation pairOpenElement = null;
+ for (int i = nonPairedOpenElements.size() - 1; i >= 0 && pairOpenElement == null; i--) {
+ ElementLocation openedElement = nonPairedOpenElements.get(i);
+ if (openedElement != null && openedElement.getName().equals(qName)) {
+ pairOpenElement = openedElement;
+ }
+ }
+ if (pairOpenElement == null) {
+ // There is no open element for the current closing element
+ nonPairedCloseElements.push(currentElementLocation);
+ } else {
+ // The pair open element is found for the current closing element
+ nonPairedOpenElements.remove(pairOpenElement);
+ }
+ }
+
+ private String getName(String text) {
+ if (text.startsWith("<"))
+ text = text.substring(1);
+ if (text.startsWith("/"))
+ text = text.substring(1);
+ StringBuilder qName = new StringBuilder();
+ int i = 0;
+ while(i < text.length() && (Character.isJavaIdentifierPart(text.charAt(i)) || text.charAt(i) == ':')) {
+ qName.append(text.charAt(i));
+ i++;
+ }
+ return qName.toString();
+ }
+
+ @Override
+ public void error(SAXParseException e) throws SAXException {
+ }
+
+ @Override
+ public void fatalError(SAXParseException e) throws SAXException {
+ }
+
+ List<ElementLocation> getNonPairedOpenElements() {
+ return nonPairedOpenElements;
+ }
+
+ List<ElementLocation> getNonPairedCloseElements() {
+ return nonPairedCloseElements;
+ }
+
+ private int getCurrentLocation() {
+ if (locator == null)
+ return 0;
+
+ int line = locator.getLineNumber() - 1;
+ int lineOffset = locator.getColumnNumber() - 1;
+ try {
+ return document.getLineOffset(line) + lineOffset;
+ } catch (BadLocationException e) {
+ JSFModelPlugin.getDefault().logError(e);
+ }
+ return 0;
+ }
+
+ /**
+ * Returns line number in text for offset 'start'; the first line has number 1.
+ *
+ * @param start
+ * @return
+ */
+ private int getLine(int start) {
+ try {
+ return document.getLineOfOffset(start) + 1;
+ } catch (BadLocationException e) {
+ JSFModelPlugin.getPluginLog().logError(e);
+ return -1;
+ }
+ }
+
+ /**
+ * Returns line number in text for offset 'start'; the first line has number 1.
+ *
+ * @param start
+ * @return
+ */
+ private int getColumn(int start) {
+ try {
+ int line = getLine(start);
+ int lineStart = document.getLineOffset(line - 1);
+ return (start - lineStart) + 1;
+ } catch (BadLocationException e) {
+ JSFModelPlugin.getPluginLog().logError(e);
+ return -1;
+ }
+ }
+
+ @Override
+ public void startDTD(String name, String publicId, String systemId)
+ throws SAXException {
+ valinfo.setGrammarEncountered(true);
+ valinfo.setDTDEncountered(true);
+ if (publicId != null && publicId.indexOf("W3C") != -1 &&
+ publicId.indexOf("DTD") != -1 && publicId.indexOf("XHTML") != -1) {
+ isXHTMLDoctype = true;
+ }
+ }
+
+ @Override
+ public void endDTD() throws SAXException {
+ }
+
+ @Override
+ public void startEntity(String name) throws SAXException {
+ }
+
+ @Override
+ public void endEntity(String name) throws SAXException {
+ }
+
+ @Override
+ public void startCDATA() throws SAXException {
+ }
+
+ @Override
+ public void endCDATA() throws SAXException {
+ }
+
+ @Override
+ public void comment(char[] ch, int start, int length)
+ throws SAXException {
+ }
+ }
+}
Property changes on: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/XHTMLValidator.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/messages.properties
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/messages.properties 2011-09-23 11:38:13 UTC (rev 34994)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/messages.properties 2011-09-23 12:12:37 UTC (rev 34995)
@@ -7,4 +7,6 @@
VALIDATING_RESOURCE=project "{0}"; resource "{1}" (JSF Validator)
VALIDATING_PROJECT=project "{0}" (JSF Validator)
-XHTML_VALIDATION=XHTML Syntax Validation: {0}
\ No newline at end of file
+XHTML_VALIDATION=XHTML Syntax Validation: {0}
+XHTML_VALIDATION_NO_START_TAG=No start tag for element '{0}'
+XHTML_VALIDATION_NO_END_TAG=No end tag for element '{0}'
\ No newline at end of file
14 years, 6 months
JBoss Tools SVN: r34994 - in trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test: openon and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: jjankovi
Date: 2011-09-23 07:38:13 -0400 (Fri, 23 Sep 2011)
New Revision: 34994
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/CDIOpenOnTest.java
Log:
Change of HyperLinkTest name
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/CDIOpenOnTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/CDIOpenOnTest.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/CDIOpenOnTest.java 2011-09-23 11:38:13 UTC (rev 34994)
@@ -0,0 +1,86 @@
+package org.jboss.tools.cdi.bot.test.openon;
+
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
+import org.jboss.tools.cdi.bot.test.uiutils.actions.CDIUtil;
+import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
+import org.jboss.tools.ui.bot.ext.SWTJBTExt;
+import org.jboss.tools.ui.bot.ext.SWTTestExt;
+import org.jboss.tools.ui.bot.ext.Timing;
+import org.jboss.tools.ui.bot.ext.config.Annotations.Require;
+import org.jboss.tools.ui.bot.ext.config.Annotations.Server;
+import org.jboss.tools.ui.bot.ext.config.Annotations.ServerState;
+import org.jboss.tools.ui.bot.ext.types.ViewType;
+import org.jboss.tools.ui.bot.ext.view.ProblemsView;
+import org.junit.After;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/*
+ * Test operates on hyperlinks-openons
+ *
+ * @author Jaroslav Jankovic
+ */
+
+@Require(perspective = "Java EE", server = @Server(state = ServerState.NotRunning, version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class })
+public class CDIOpenOnTest extends SWTTestExt {
+
+ //private static final Logger LOGGER = Logger.getLogger(CDIQuickFixTest.class.getName());
+ private static final String PROJECT_NAME = "CDIProject";
+ private static final String PACKAGE_NAME = "org.cdi.test";
+
+
+ @BeforeClass
+ public static void setup() {
+ eclipse.showView(ViewType.PROJECT_EXPLORER);
+ CDIUtil.createAndCheckCDIProject(bot, util, projectExplorer, PROJECT_NAME);
+ }
+
+ @After
+ public void waitForJobs() {
+ util.waitForNonIgnoredJobs();
+ }
+
+ @Test
+ public void testInjectHyperlink() {
+ CDIUtil.bean(PACKAGE_NAME, "Animal", true, false, false, false, null,
+ null, null, null).finish();
+ bot.sleep(Timing.time1S());
+ util.waitForNonIgnoredJobs();
+
+ CDIUtil.bean(PACKAGE_NAME, "BrokenFarm", true, false, false, false, null,
+ null, null, null).finish();
+ util.waitForNonIgnoredJobs();
+ SWTBotEditor ed = bot.activeEditor();
+ CDIUtil.copyResourceToClass(ed, CDIOpenOnTest.class
+ .getResourceAsStream("/resources/cdi/BrokenFarm.java.cdi"), false);
+
+ SWTBotTreeItem warningNode = ProblemsView.getWarningsNode(bot);
+ assertNull("Warnings node should be empty.", warningNode);
+ String openOnString = "@Inject";
+ ed = SWTJBTExt.selectTextInSourcePane(bot, "BrokenFarm.java", openOnString, 1, openOnString.length()-1);
+ ed.setFocus();
+ bot.menu("Navigate").menu("Open Hyperlink").click();
+ bot.activeShell().bot().table(0).click(1, 0);
+ bot.sleep(Timing.time1S());
+ ed = bot.activeEditor();
+ assertTrue("ERROR: redirected to " + ed.getTitle(), ed.getTitle().equals("Animal.java"));
+ }
+
+ /*
+ * TO DO
+ *
+ * - https://issues.jboss.org/browse/JBIDE-8202
+ * - https://issues.jboss.org/browse/JBIDE-8692
+ * - OpenOn for Disposer/Produce and for injection point works
+ * - Classes indication for Open Injected Class works
+ * - OpenOn works in beans.xml => https://jira.jboss.org/browse/JBIDE-7025
+ *
+ *
+ */
+}
\ No newline at end of file
14 years, 6 months
JBoss Tools SVN: r34993 - in trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test: editor and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: jjankovi
Date: 2011-09-23 07:35:48 -0400 (Fri, 23 Sep 2011)
New Revision: 34993
Removed:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/hyperlinks/
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIAllBotTests.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/BeansEditorTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/CDIQuickFixTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/CDIUtil.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CdiATWizardTest.java
Log:
Refactoring and new QuickFix test added
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIAllBotTests.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIAllBotTests.java 2011-09-23 06:35:15 UTC (rev 34992)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIAllBotTests.java 2011-09-23 11:35:48 UTC (rev 34993)
@@ -11,7 +11,7 @@
package org.jboss.tools.cdi.bot.test;
import org.jboss.tools.cdi.bot.test.editor.BeansEditorTest;
-import org.jboss.tools.cdi.bot.test.hyperlinks.CDIHyperlinksTest;
+import org.jboss.tools.cdi.bot.test.openon.CDIOpenOnTest;
import org.jboss.tools.cdi.bot.test.quickfix.CDIQuickFixTest;
import org.jboss.tools.cdi.bot.test.wizard.CdiATWizardTest;
import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
@@ -34,7 +34,7 @@
* JAVA=1.6,/space/java/sdk/jdk1.6.0_22
*
*
- * Suite duration: aprox. 11min
+ * Suite duration: aprox. 12min
*
* @author Lukas Jungmann
* @author Jaroslav Jankovic
@@ -44,7 +44,7 @@
CdiATWizardTest.class,
BeansEditorTest.class,
CDIQuickFixTest.class,
- CDIHyperlinksTest.class
+ CDIOpenOnTest.class
})
public class CDIAllBotTests {
}
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/BeansEditorTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/BeansEditorTest.java 2011-09-23 06:35:15 UTC (rev 34992)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/BeansEditorTest.java 2011-09-23 11:35:48 UTC (rev 34993)
@@ -28,6 +28,7 @@
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
import org.jboss.tools.cdi.bot.test.uiutils.editor.BeansEditor;
import org.jboss.tools.cdi.bot.test.uiutils.editor.BeansEditor.Item;
import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
@@ -53,7 +54,7 @@
*/
@Require(clearProjects = false, perspective = "Java EE", server = @Server(state = ServerState.NotRunning, version = "6.0", operator = ">="))
@RunWith(RequirementAwareSuite.class)
-@SuiteClasses({ BeansEditorTest.class })
+@SuiteClasses({ CDIAllBotTests.class })
public class BeansEditorTest extends SWTTestExt {
private static final String descPath = "WebContent/WEB-INF/beans.xml";
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/CDIQuickFixTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/CDIQuickFixTest.java 2011-09-23 06:35:15 UTC (rev 34992)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/CDIQuickFixTest.java 2011-09-23 11:35:48 UTC (rev 34993)
@@ -16,7 +16,6 @@
import org.jboss.tools.ui.bot.ext.view.ProblemsView;
import org.junit.After;
import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Suite.SuiteClasses;
@@ -38,8 +37,8 @@
private static SWTBotTreeItem[] problemsTrees;
private static final String LINE_SEPARATOR = System.getProperty("line.separator");
private enum ANNOTATIONS {TARGET, RETENTION, NAMED, TYPED, DISPOSES, OBSERVES, INTERCEPTOR,
- SPECIALIZES, DECORATOR}
- private enum CDICOMPONENT {STEREOSCOPE, QUALIFIER, SCOPE, BEAN, ANNOTATION, INTERBINDING}
+ SPECIALIZES, DECORATOR, NONBINDING}
+ private enum CDICOMPONENT {STEREOSCOPE, QUALIFIER, SCOPE, BEAN, ANNOTATION, INTERBINDING, INTERCEPTOR}
private SWTBotEclipseEditor ed;
@BeforeClass
@@ -53,7 +52,7 @@
public void waitForJobs() {
util.waitForNonIgnoredJobs();
}
-
+
@Test
public void testSerializableQF() {
createComponent(CDICOMPONENT.BEAN, "B1");
@@ -148,7 +147,7 @@
"BrokenFarm.java", "CDI Problem");
assertTrue(problemsTrees.length == 0);
}
-
+
@Test
public void testStereoscopeQF() {
String className = "S1";
@@ -177,6 +176,10 @@
// 2.QF - https://issues.jboss.org/browse/JBIDE-7632
checkTargetAnnotation(CDICOMPONENT.QUALIFIER, className);
+
+ // 3.QF - https://issues.jboss.org/browse/JBIDE-7641
+ checkNonBindingAnnotation(CDICOMPONENT.QUALIFIER, className);
+
}
@Test
@@ -232,7 +235,8 @@
// 5.QF - https://issues.jboss.org/browse/JBIDE-7686
checkSpecializeAnnotation(CDICOMPONENT.BEAN, "TestBean");
- // https://issues.jboss.org/browse/JBIDE-7641 - NIE INTER DECOR
+ // 6.QF - https://issues.jboss.org/browse/JBIDE-7641
+ checkNonBindingAnnotation(CDICOMPONENT.INTERCEPTOR, "Interceptor");
}
private void prepareCdiComponent(CDICOMPONENT component, String name) {
@@ -592,10 +596,39 @@
checkQuickFix(ANNOTATIONS.SPECIALIZES, comp, className, replacement);
}
+ private void checkNonBindingAnnotation(CDICOMPONENT comp, String className) {
+ checkNonBindingAnnotationWithAddon(comp, className, "Annotation");
+ checkNonBindingAnnotationWithAddon(comp, className, "Array");
+ }
+
+ private void checkNonBindingAnnotationWithAddon(CDICOMPONENT comp, String className,
+ String replacement) {
+ if (comp == CDICOMPONENT.INTERCEPTOR) {
+ boolean interceptorCreated = projectExplorer.isFilePresent(PROJECT_NAME,
+ "Java Resources", "src", PACKAGE_NAME, className + ".java");
+ if (!interceptorCreated) {
+ CDIUtil.binding(PACKAGE_NAME, className, null, false, false).finish();
+ }
+ }
+ if (replacement.equals("Annotation")) {
+ boolean annotationCreated = projectExplorer.isFilePresent(PROJECT_NAME,
+ "Java Resources", "src", PACKAGE_NAME, "AAnnotation.java");
+ if (!annotationCreated) {
+ CDIUtil.annotation(open, util, PACKAGE_NAME, "AAnnotation");
+ bot.editorByTitle(className + ".java").show();
+ ed = bot.activeEditor().toTextEditor();
+ }
+ CDIUtil.insertInEditor(ed, bot, ed.getLineCount()-3, 1, "AAnnotation annotValue();" + LINE_SEPARATOR);
+ }else {
+ CDIUtil.insertInEditor(ed, bot, ed.getLineCount()-3, 1, "String[] array();" + LINE_SEPARATOR);
+ }
+ checkQuickFix(ANNOTATIONS.NONBINDING, comp, className, replacement);
+ }
+
private void checkQuickFix(ANNOTATIONS annonType, CDICOMPONENT comp,
String className, String replacement) {
String componentClass = className + ".java";
- problemsTrees = getProblems(annonType, comp, componentClass);
+ problemsTrees = getProblems(annonType, comp, componentClass);
assertTrue(problemsTrees.length != 0);
resolveQuickFix(annonType, comp, replacement);
problemsTrees = getProblems(annonType, comp, componentClass);
@@ -605,7 +638,7 @@
private SWTBotTreeItem[] getProblems(ANNOTATIONS annonType, CDICOMPONENT comp, String className) {
SWTBotTreeItem[] problemsTree;
boolean warningType = true;
- switch (annonType) {
+ switch (annonType) {
case NAMED:
case SPECIALIZES:
warningType = ((comp == CDICOMPONENT.BEAN)?true:false);
@@ -623,6 +656,9 @@
if (annonType == ANNOTATIONS.SPECIALIZES) {
problemsContains = "@Specializes";
}
+ if (annonType == ANNOTATIONS.NONBINDING) {
+ problemsContains = "@Nonbinding";
+ }
problemsTree = ProblemsView.getFilteredWarningsTreeItems(bot, problemsContains, "/"
+ PROJECT_NAME, className, "CDI Problem");
} else {
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/CDIUtil.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/CDIUtil.java 2011-09-23 06:35:15 UTC (rev 34992)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/CDIUtil.java 2011-09-23 11:35:48 UTC (rev 34993)
@@ -5,8 +5,10 @@
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
import org.eclipse.swtbot.swt.finder.results.Result;
+import org.eclipse.swtbot.swt.finder.utils.SWTUtils;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
@@ -15,8 +17,12 @@
import org.jboss.tools.cdi.bot.test.uiutils.wizards.CDIWizardType;
import org.jboss.tools.cdi.bot.test.uiutils.wizards.DynamicWebProjectWizard;
import org.jboss.tools.ui.bot.ext.SWTBotExt;
+import org.jboss.tools.ui.bot.ext.SWTOpenExt;
import org.jboss.tools.ui.bot.ext.SWTUtilExt;
import org.jboss.tools.ui.bot.ext.Timing;
+import org.jboss.tools.ui.bot.ext.gen.ActionItem;
+import org.jboss.tools.ui.bot.ext.gen.ActionItem.NewObject;
+import org.jboss.tools.ui.bot.ext.gen.ActionItem.NewObject.JavaAnnotation;
import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
import org.jboss.tools.ui.bot.ext.view.ProjectExplorer;
@@ -176,10 +182,12 @@
if (method != null) {
w = w.setMethodName(method);
}
- return w.addIBinding(ibinding);
+ if (ibinding != null) {
+ w = w.addIBinding(ibinding);
+ }
+ return w;
}
-
public static CDIWizard bean(String pkg, String name, boolean isPublic, boolean isAbstract,
boolean isFinal, boolean comments, String named,
String interfaces, String scope, String qualifier) {
@@ -203,6 +211,14 @@
return w;
}
+ public static void annotation(SWTOpenExt open, SWTUtilExt util, String pkg, String name) {
+ SWTBot openWizard = open.newObject(JavaAnnotation.LABEL);
+ openWizard.textWithLabel("Name:").setText(name);
+ openWizard.textWithLabel("Package:").setText(pkg);
+ openWizard.button("Finish").click();
+ util.waitForNonIgnoredJobs();
+ }
+
public static CDIWizard annLiteral(String pkg, String name, boolean isPublic, boolean isAbstract,
boolean isFinal, boolean comments, String qualifier) {
assert qualifier != null && !"".equals(qualifier.trim()) : "Qualifier has to be set";
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CdiATWizardTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CdiATWizardTest.java 2011-09-23 06:35:15 UTC (rev 34992)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CdiATWizardTest.java 2011-09-23 11:35:48 UTC (rev 34993)
@@ -17,6 +17,7 @@
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
import org.jboss.tools.cdi.bot.test.uiutils.actions.CDIUtil;
import org.jboss.tools.cdi.bot.test.uiutils.actions.NewCDIFileWizard;
import org.jboss.tools.cdi.bot.test.uiutils.actions.NewFileWizardAction;
@@ -37,7 +38,7 @@
@Require(perspective = "Java EE", server = @Server(state = ServerState.NotRunning, version = "6.0", operator = ">="))
@RunWith(RequirementAwareSuite.class)
-@SuiteClasses({ CdiATWizardTest.class })
+@SuiteClasses({ CDIAllBotTests.class })
public class CdiATWizardTest extends SWTTestExt {
private static final String PROJECT_NAME = "CDIProject";
14 years, 6 months
JBoss Tools SVN: r34992 - in trunk/cdi/tests: org.jboss.tools.cdi.core.test and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2011-09-23 02:35:15 -0400 (Fri, 23 Sep 2011)
New Revision: 34992
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/pom.xml
trunk/cdi/tests/pom.xml
Log:
moved coverage properties into cdi/tests/pom.xml
Modified: trunk/cdi/tests/org.jboss.tools.cdi.core.test/pom.xml
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/pom.xml 2011-09-23 06:08:22 UTC (rev 34991)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/pom.xml 2011-09-23 06:35:15 UTC (rev 34992)
@@ -11,11 +11,6 @@
<packaging>eclipse-test-plugin</packaging>
- <properties>
- <emma.filter>org.jboss.tools.cdi.core*,org.jboss.tools.cdi.internal.core*</emma.filter>
- <emma.instrument.bundles>org.jboss.tools.cdi.core</emma.instrument.bundles>
- </properties>
-
<build>
<plugins>
<plugin>
Modified: trunk/cdi/tests/pom.xml
===================================================================
--- trunk/cdi/tests/pom.xml 2011-09-23 06:08:22 UTC (rev 34991)
+++ trunk/cdi/tests/pom.xml 2011-09-23 06:35:15 UTC (rev 34992)
@@ -9,7 +9,10 @@
<groupId>org.jboss.tools.cdi</groupId>
<artifactId>tests</artifactId>
<name>cdi.tests</name>
-
+ <properties>
+ <emma.filter>org.jboss.tools.cdi*</emma.filter>
+ <emma.instrument.bundles>org.jboss.tools.cdi.core</emma.instrument.bundles>
+ </properties>
<packaging>pom</packaging>
<modules>
<module>org.jboss.tools.cdi.bot.test</module>
14 years, 6 months
JBoss Tools SVN: r34991 - trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2011-09-23 02:08:22 -0400 (Fri, 23 Sep 2011)
New Revision: 34991
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/pom.xml
Log:
updated coverage properties to include cdi.core and cdi.xml plugins
Modified: trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/pom.xml
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/pom.xml 2011-09-23 01:20:30 UTC (rev 34990)
+++ trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/pom.xml 2011-09-23 06:08:22 UTC (rev 34991)
@@ -12,8 +12,8 @@
<packaging>eclipse-test-plugin</packaging>
<properties>
- <emma.filter>org.jboss.tools.cdi.seam.config.core*</emma.filter>
- <emma.instrument.bundles>org.jboss.tools.cdi.seam.config.core</emma.instrument.bundles>
+ <emma.filter>org.jboss.tools.cdi*</emma.filter>
+ <emma.instrument.bundles>org.jboss.tools.cdi.xml,org.jboss.tools.cdi.core,org.jboss.tools.cdi.seam.config.core</emma.instrument.bundles>
</properties>
<build>
14 years, 6 months
JBoss Tools SVN: r34990 - branches/jbosstools-3.2.x/documentation/guides/JBDS_Release_Notes/en-US.
by jbosstools-commits@lists.jboss.org
Author: irooskov(a)redhat.com
Date: 2011-09-22 21:20:30 -0400 (Thu, 22 Sep 2011)
New Revision: 34990
Modified:
branches/jbosstools-3.2.x/documentation/guides/JBDS_Release_Notes/en-US/Fixed_Issues.xml
Log:
updated to remove trailing character
Modified: branches/jbosstools-3.2.x/documentation/guides/JBDS_Release_Notes/en-US/Fixed_Issues.xml
===================================================================
--- branches/jbosstools-3.2.x/documentation/guides/JBDS_Release_Notes/en-US/Fixed_Issues.xml 2011-09-23 01:18:48 UTC (rev 34989)
+++ branches/jbosstools-3.2.x/documentation/guides/JBDS_Release_Notes/en-US/Fixed_Issues.xml 2011-09-23 01:20:30 UTC (rev 34990)
@@ -1,4 +1,4 @@
-l<?xml version='1.0' encoding='utf-8' ?>
+<?xml version='1.0' encoding='utf-8' ?>
<section id="Issues-fixed-in-this-release">
<title>
Features added and issues fixed in version 4.1.1
14 years, 6 months
JBoss Tools SVN: r34989 - branches/jbosstools-3.2.x/documentation/guides/JBDS_Release_Notes/en-US.
by jbosstools-commits@lists.jboss.org
Author: irooskov(a)redhat.com
Date: 2011-09-22 21:18:48 -0400 (Thu, 22 Sep 2011)
New Revision: 34989
Modified:
branches/jbosstools-3.2.x/documentation/guides/JBDS_Release_Notes/en-US/Article_Info.xml
branches/jbosstools-3.2.x/documentation/guides/JBDS_Release_Notes/en-US/Fixed_Issues.xml
branches/jbosstools-3.2.x/documentation/guides/JBDS_Release_Notes/en-US/Need_Info_Issues.xml
Log:
updated with new fixed issue
Modified: branches/jbosstools-3.2.x/documentation/guides/JBDS_Release_Notes/en-US/Article_Info.xml
===================================================================
--- branches/jbosstools-3.2.x/documentation/guides/JBDS_Release_Notes/en-US/Article_Info.xml 2011-09-23 00:33:05 UTC (rev 34988)
+++ branches/jbosstools-3.2.x/documentation/guides/JBDS_Release_Notes/en-US/Article_Info.xml 2011-09-23 01:18:48 UTC (rev 34989)
@@ -8,7 +8,7 @@
<productname>JBoss Developer Studio</productname>
<productnumber>4.1</productnumber>
<edition>4.1.1</edition>
- <pubsnumber>22</pubsnumber>
+ <pubsnumber>23</pubsnumber>
<abstract>
<para>
These release notes contain important information related to the JBoss Developer Studio. New features, known issues, resources, and other current issues are addressed here.
Modified: branches/jbosstools-3.2.x/documentation/guides/JBDS_Release_Notes/en-US/Fixed_Issues.xml
===================================================================
--- branches/jbosstools-3.2.x/documentation/guides/JBDS_Release_Notes/en-US/Fixed_Issues.xml 2011-09-23 00:33:05 UTC (rev 34988)
+++ branches/jbosstools-3.2.x/documentation/guides/JBDS_Release_Notes/en-US/Fixed_Issues.xml 2011-09-23 01:18:48 UTC (rev 34989)
@@ -1,4 +1,4 @@
-<?xml version='1.0' encoding='utf-8' ?>
+l<?xml version='1.0' encoding='utf-8' ?>
<section id="Issues-fixed-in-this-release">
<title>
Features added and issues fixed in version 4.1.1
@@ -440,6 +440,11 @@
<itemizedlist>
<listitem>
<para>
+ <ulink url="http://jira.jboss.com/jira/browse/JBIDE-1781">JBIDE-1781</ulink>: When using the toolset on Ubuntu 11.04 with the Unity interface, only the <guilabel>Window</guilabel> menu item would appear in the top menu bar of the JBoss Developer Studio workspace. For the user this meant that all other menu functions were absent (for example, all options in the <guilabel>File</guilabel> and <guilabel> Edit</guilabel> menus). To correct the issue a new script is distributed with this JBoss Developer Studio release called <filename>jbdevstudio-unity</filename> that sets the environment variable <property>UBUNTU_MENUPROXY=0</property> prior to launching JBoss Developer Studio. By result of this script running is that Ubuntu Unity is forced to disable the global menu for JBoss Developer Studio, enabling the normal JBoss Developer Studio menu to be shown (containing all the usual menu options such as <guilabel>File</guilabel> and <guilabel> Edit</guilabel>). All other appli!
cation windows within Ubuntu Unity remain unaffected.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
<ulink url="http://jira.jboss.com/jira/browse/JBIDE-9514">JBIDE-9514</ulink>: Project Example ZIP files that contain empty folders, would not be imported correctly and the empty folders would be excluded, though they are necessary for the project to work (for example, the <filename>src</filename> folder). To fix this issue the <filename>NewProjectExamplesWizard.java</filename> has been modified to allow for empty folders within ZIP files to be imported correctly.
</para>
</listitem>
Modified: branches/jbosstools-3.2.x/documentation/guides/JBDS_Release_Notes/en-US/Need_Info_Issues.xml
===================================================================
--- branches/jbosstools-3.2.x/documentation/guides/JBDS_Release_Notes/en-US/Need_Info_Issues.xml 2011-09-23 00:33:05 UTC (rev 34988)
+++ branches/jbosstools-3.2.x/documentation/guides/JBDS_Release_Notes/en-US/Need_Info_Issues.xml 2011-09-23 01:18:48 UTC (rev 34989)
@@ -323,17 +323,6 @@
<emphasis>Question</emphasis>: Only a "fixed in trunk and 4.x branch" comment is given. No SVN/Fisheye links are recorded and no further information is provided. What was the cause of the issue? How was the issue fixed in the code? What is the result that the user will now see - does JBDS now start with the user-selected JRE?
</para>
</listitem>
- <listitem>
- <para>
- <ulink url="http://jira.jboss.com/jira/browse/JBDS-1781">JBDS-1781</ulink>: <emphasis>Developer</emphasis>: Denis Golovin.
- </para>
- <para>
- <emphasis>Title</emphasis>: All menus but one are missing on Ubuntu 11.04 (Unity).
- </para>
- <para>
- <remark>Updated</remark><emphasis>Question</emphasis>: How does the jbdevstudio-uniti script make it possible to negate those extra steps when using uniti? I'd like to let customers know so they can feel at ease with the script being run and not doing anything else to their systems.
- </para>
- </listitem>
</itemizedlist>
</para>
</formalpara>
14 years, 6 months