Author: ozizka(a)redhat.com
Date: 2009-02-04 12:37:12 -0500 (Wed, 04 Feb 2009)
New Revision: 134
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as4/DatasourceTest.java
Log:
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as4/DatasourceTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as4/DatasourceTest.java 2009-02-04
05:01:05 UTC (rev 133)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as4/DatasourceTest.java 2009-02-04
17:37:12 UTC (rev 134)
@@ -27,10 +27,10 @@
import org.jboss.jopr.jsfunit.*;
import com.gargoylesoftware.htmlunit.html.*;
import java.io.IOException;
+import java.util.*;
import junit.framework.Test;
import junit.framework.TestSuite;
import javax.management.ObjectName;
-import java.util.Map;
import javax.management.JMException;
@@ -56,6 +56,11 @@
/**
* Create a new datasource using the given template and properties.
+ *
+ * Scenario:
+ * NavTree -> Datasources;
+ * Template select;
+ * Fill the form and save.
*
* @param datasourceType is not used.
* @param datasourceTemplate is the value of the HTML select option.
@@ -71,20 +76,18 @@
// Click on the "Add new resource" button
client.click("actionHeaderForm:addNewNotContent"); // 404 if
setThrowExceptionOnFailingStatusCode(true) above
- // Select the default datasource (other options: Oracle)
+ // Select the datasource (options: default, Oracle XA, Oracle Local TX)
HtmlSelect menu =
(HtmlSelect)client.getElement("resourceCreateForm:selectedTemplate");
-
menu.setSelectedAttribute(datasourceTemplate, true);
// Submit the form. [Continue]
- //HtmlSubmitInput submit = (HtmlSubmitInput)
util.getFirstElementByXPath(util.getTabMenuBoxElement(),
".//input[@type='submit']");
- //if( null == submit ){ fail("\"Continue\" button not found.");
}
- //submit.click();
-
client.click("resourceCreateForm:addButton");
// Configure the properties associated with this datasource
+ propertiesMap.put("type",
DatasourceType.LOCAL_TX_DATASOURCE.getHtmlRadioValue() );
fillOutForm(propertiesMap);
+ // Remove the type property not to be treated later as regular properties.
+ propertiesMap.remove("type");
}
@@ -102,7 +105,11 @@
// Additional or different properties for AS 4
+ // AS 4 has type set through radio button.
+ //propertiesMap.put("type",
DatasourceType.LOCAL_TX_DATASOURCE.getHtmlRadioValue() );
+ // Inappropriate - type is then represented other way than other properties.
+
return propertiesMap;
}
@@ -114,15 +121,17 @@
/**
* Delete the datasource given by datasourceName.
*/
- protected void deleteDatasource(String datasourceName) throws IOException {
+ protected void deleteDatasource(String datasourceName) throws IOException,
AssertException {
HtmlAnchor datasourceLink = getNavTreeLink("Datasources");
datasourceLink.click();
//HtmlButtonInput deleteButton = getDeleteButton("resourceSummaryForm",
datasourceName); /*categorySummaryForm*/
//deleteButton.click();
try {
- ((HtmlInput) getFirstElementByXPath(getRowByName(datasourceName),
".//input[text()='Delete']")).click();
+ ((HtmlInput) getFirstElementByXPath(getRowByName(datasourceName),
+ ".//input[ @value = 'Delete' ]")).click();
} catch (AssertException ex) {
Logger.getLogger(DatasourceTest.class.getName()).log(Level.SEVERE, null, ex);
+ throw ex;
}
}
@@ -165,26 +174,59 @@
* Create a new datasource. Leave some property values that aren't
* required unset.
*/
- public void testCreateDatasource() throws IOException {
+ @Override
+ public void testCreateDatasource() throws IOException, AssertException {
+ /* // Works
+ JMXUtils jmxu = JMXUtils.getInstanceForLocalJBoss();
+ try {
+ Object mBeanAttribute =
jmxu.getMBeanAttribute("jboss.j2ee:service=ClientDeployer", "State");
+ log.info("State: "+mBeanAttribute.toString());
+ } catch (JMException ex) {
+ log.fatal(ex.getMessage());
+ ex.printStackTrace();
+ } /**/
+
+ log.info("Printing MBeans info");
+ JMXUtils.getInstanceForLocalJBoss().dumpInfo();///
+
+
Map<String, String> propertiesMap = getDatasourceProperties();
/* AS 4:
<option value="Oracle Local TX__Datasource">Oracle Local TX
(Datasource)</option>
<option value="Oracle XA__Datasource">Oracle XA
(Datasource)</option>
<option value="default__Datasource">default
(Datasource)</option>
- /**/
createDatasource(DatasourceType.LOCAL_TX_DATASOURCE, // unsued for AS 4
// TODO: Differs! Split DatasourceType accordingly...
- DatasourceTemplate.DEFAULT.getTemplateHtmlSelectValue(),
+ DatasourceTemplate.AS4_DEFAULT.getTemplateHtmlSelectValue(),
propertiesMap);
+ /**/
+
+ /*
+ // Option - "No TX datasource" / value = no-tx-datasource TODO: XSLT
+ //((HtmlRadioButtonInput)client.getElement("resourceConfigurationForm:rhq_prop-287459352_3575610:0")).setChecked(true);
+ ((HtmlRadioButtonInput)util.getFirstElementByXPath(tabMenuBox,
".//input[@value='no-tx-datasource']"))
+ .setChecked(true);
+ */
+
+
+ log.info("Clicking Save...");
client.click("resourceConfigurationForm:saveButton");
-
- // Check for the appropriate success messages
- String expectedMessage = "Successfully added new Local TX Datasource";
+ log.info("Clicked");
+
+
+ DebugUtils.writeFile("/home/ondra/work/JOPRembedded/emb.html",
client.getPageAsText());////
+
+ log.info("Printing MBeans info"); ////
+ JMXUtils.getInstanceForLocalJBoss().dumpInfo();////
+
+ // Check for the appropriate success messages.
+ String expectedMessage = "Successfully added new Datasource.";
checkClientAndServerMessages(expectedMessage, expectedMessage, false);
-
+
+ // Check whether the dataource is deployed.
assertTrue(isDatasourceDeployed(propertiesMap.get("jndi-name"),
DatasourceType.LOCAL_TX_DATASOURCE));
assertTrue(checkProperties(propertiesMap.get("jndi-name"),
@@ -195,20 +237,52 @@
// set for properties that were not specified above
// Clean up
- deleteDatasource(propertiesMap.get("jndi-name"));
- expectedMessage = "Successfully deleted Local TX Datasource '"
- + propertiesMap.get("jndi-name") +
"'";
+ deleteDatasource(propertiesMap.get("jndi-name"));
+
+ expectedMessage = "Successfully deleted Datasource '"
+ + propertiesMap.get("jndi-name") + "
Datasource'.";
+
checkClientAndServerMessages(expectedMessage, expectedMessage, false);
+
}
+/*
+ @Override
+ public void testCreateDatasourceMissingRequiredValues() throws IOException {
+ // Leave jndi-name and connection-url unset
+ Map<String, String> propertiesMap = new HashMap<String, String>();
+ propertiesMap.put("user-name", "testUser");
+ propertiesMap.put("max-pool-size", "10");
+ propertiesMap.put("idle-timeout-minutes", "20");
+ createDatasource(DatasourceType.NO_TX_DATASOURCE,
+ //"default__No TX Datasource",
+ isJBoss4 ?
+ DatasourceTemplate.DEFAULT.getTemplateHtmlSelectValue() :
+ DatasourceTemplate.DEFAULT_NO_TX.getTemplateHtmlSelectValue(),
+ propertiesMap);
+ client.click("resourceConfigurationForm:saveButton");
+ // Check for the appropriate error messages
+ checkClientAndServerMessages(
+ "An invalid value was specified for one or more properties",
+ "Value is required", true);
+ }
+*/
+
+
+
+
+
+
+
+
/**
* @return the suite of tests being tested
*/
@@ -220,8 +294,6 @@
-
-
/**
* AS 4 uses State and StateString attributes.
* @param deploymentMBean
@@ -236,7 +308,7 @@
Object state = jmxUtils.getMBeanAttribute(deploymentMBean, "StateString");
//if(!("3".equals(state.toString()))) return false; // started state
- return !( "Started".equals(state.toString()) );
+ return ( "Started".equals(state.toString()) );
}