[embjopr-commits] EMBJOPR SVN: r235 - in trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit: as5 and 1 other directories.

embjopr-commits at lists.jboss.org embjopr-commits at lists.jboss.org
Tue Mar 17 14:39:30 EDT 2009


Author: ozizka at redhat.com
Date: 2009-03-17 14:39:30 -0400 (Tue, 17 Mar 2009)
New Revision: 235

Modified:
   trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
   trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/EarTest.java
   trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java
Log:
EAR tests: Added testEarConfigurationTabCancel()
EJTT: Added waitUntilNodeLoadedByAjax()
EmbJoprTestCase: Added getFormPropertiesValues()

Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java	2009-03-17 18:36:17 UTC (rev 234)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java	2009-03-17 18:39:30 UTC (rev 235)
@@ -246,7 +246,38 @@
         }
         
         throw new IllegalStateException("Value of '"+metricName+"' not found.");
-    } 
+    }
+
+
+
+		/**
+		 * Takes a Properties object, takes their names
+		 * and calls getFormPropertiesValues( Collection<String> ).
+		 */
+		public Properties getFormPropertiesValues( Properties propsTemplate ){
+			return getFormPropertiesValues(EmbJoprTestToolkit.stringPropertyNames(propsTemplate));
+		}
+
+		/**
+		 * Takes a list of properties to load
+		 * and returns a Properties object filled with their values.
+		 */
+		public Properties getFormPropertiesValues( Collection<String> propsToLoad ){
+
+			Properties props = new Properties();
+
+			//for( String propName : EmbJoprTestToolkit.stringPropertyNames(propsToLoad) )
+			for( String propName : propsToLoad )
+			{
+				HtmlInput input = getConfigFormInput(propName);
+				String propValue = getFormInputValueAsText(input);
+				props.setProperty(propName, propValue);
+			}
+
+			return props;
+			
+		}
+
     
     /**
      * fillOutForm sets the values of input boxes and "Yes/No" radio 

Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/EarTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/EarTest.java	2009-03-17 18:36:17 UTC (rev 234)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/EarTest.java	2009-03-17 18:39:30 UTC (rev 235)
@@ -403,25 +403,6 @@
 
 			// Read properties.
 			Properties props = new Properties();
-
-			/* Debug - Maven doesn't copy resources well due to <testSourceDirectory> hack
-			URL resUrl = this.getClass().getResource("props/ear-conf-basic.properties");
-			log.info("Res URL: "+ObjectUtils.toString(resUrl));
-			resUrl = this.getClass().getResource("ear-conf-basic.properties");
-			log.info("Res ./ URL: "+ObjectUtils.toString(resUrl));
-			resUrl = this.getClass().getResource("/org/jboss/jopr/jsfunit/as5/props/ear-conf-basic.properties");
-			log.info("Res full URL: "+ObjectUtils.toString(resUrl));
-
-			Enumeration<URL> resources = this.getClass().getClassLoader().getResources("ear-conf-basic.properties");
-			while( resources.hasMoreElements() ){
-				log.info("Resources URL: "+ObjectUtils.toString( resources.nextElement() ));
-			}
-			InputStream propsFile = this.getClass().getResourceAsStream(
-							//"/org/jboss/jopr/jsfunit/as5/props/ear-conf-basic.properties");
-							"props/ear-conf-basic.properties");
-			/**/
-
-
 			String filePath = ejtt.getTestDataDir()+"/ear/"+"ear-conf-basic.properties";
 			props.load(new FileInputStream( filePath ));
 
@@ -457,6 +438,57 @@
 	 *
 	 * FAILS because some of the values are read-only.  EMBJOPR-96
 	 */
+	public void testEarConfigurationTabCancel() throws IOException, EmbJoprTestException {
+
+		// Deploy the EAR.
+		String earFilePath = ejtt.getTestDataDir() +"/ear/"+ BASIC_EAR;
+		deployEar( earFilePath );
+
+		try {
+
+			ejtt.getNavTree().getNodeByLabel(NAV_EAR).click();
+			waitActivelyForDeployment(DeployableTypes.EAR, BASIC_EAR, 3000, 15);
+
+			// Navigate to the Configuration tab
+			ContentTableRow earRow = ejtt.getDefaultContentTable().getFirstRowContainingLink(BASIC_EAR);
+			earRow.getLinkByLabel(BASIC_EAR).click();
+			ejtt.tabMenu.clickConfigurationTab();
+
+
+			// Load properties (we will use their names).
+			Properties propsToSet = new Properties();
+			String filePath = ejtt.getTestDataDir()+"/ear/"+"ear-conf-basic.properties";
+			propsToSet.load(new FileInputStream( filePath ));
+
+			// Get the current properties.
+			Properties propsOriginal = getFormPropertiesValues( propsToSet );
+
+
+			// Set the configuration options and CANCEL
+			fillOutForm( propsToSet );
+			ejtt.getClickableByID("resourceConfigurationForm:cancelButton").click();
+
+
+			// TODO: We should get back to Conf tab automatically: EMBJOPR-100
+			ejtt.tabMenu.clickConfigurationTab();
+
+			// Now check whether the values are the same as before editing.
+			checkForm( propsOriginal );
+
+		}
+		finally {
+			undeployEar(BASIC_EAR);
+		}
+
+	}
+
+
+
+	/**
+	 * Changes EAR configuration, and checks whether the changes were saved.
+	 *
+	 * FAILS because some of the values are read-only.  EMBJOPR-96
+	 */
 	public void testEarRedeployment() throws IOException, EmbJoprTestException {
 
 		// Deploy the EAR.

Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java	2009-03-17 18:36:17 UTC (rev 234)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java	2009-03-17 18:39:30 UTC (rev 235)
@@ -147,7 +147,14 @@
 
 
 		/**
-		 * Waits
+		 * Waits and refreshes the page until ProfileService plugin 
+		 * has loaded the data for the nav tree.
+		 * 
+		 * The difference from #waitUntilReady() is that this method
+		 * waits for JOPR backend data to be ready (server side),
+		 * while waitUntilReady() waits until the Tree.Item JavaScript object
+		 * is initialized (client side).
+		 *
 		 * @param msInterval  Milliseconds to wait between tries.
 		 * @param retries     Number of retries. Total time = (retries - 1) * msInterval.
 		 * @throws java.lang.Exception  Whatever exception is thrown from the isTrue() method.
@@ -171,9 +178,32 @@
 
 
 
+		/**
+		 * Waits until the node with given label exists in the nav tree.
+		 */
+		public void waitUntilNodeLoadedByAjax( final String nodeLabel, int msInterval, int retries )
+						throws EmbJoprTestException
+		{
+			final NavTree self = this;
 
+			try {
+				new ActiveConditionChecker( new DescribedCondition("Nav tree contains "+nodeLabel+" node.") {
+					int callsMade = 0;
+					public boolean isTrue() throws HtmlElementNotFoundException {
+						// If found, return true.
+						return null != self.findNodeByLabel(nodeLabel);
+					}
+				}).throwOnTimeout().waitWithTimeout(1000, 3);
+			}
+			catch( Exception ex ){
+				throw new EmbJoprTestException(
+								"Exception when finding node '"+nodeLabel+"': "+ex.getMessage(), ex);
+			}
+		}
 
 
+
+
 		/**
 		 * Finds the nav tree node by it's link label.
 		 *
@@ -262,7 +292,7 @@
 			}
 			catch( Exception ex ){
 				throw new EmbJoprTestException(
-								"Caught when checking Tree.Item JS object: "+ex.getMessage(), ex);
+								"Exception when checking Tree.Item JS object: "+ex.getMessage(), ex);
 			}
 		}
 




More information about the embjopr-commits mailing list