EMBJOPR SVN: r557 - trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit.
by embjopr-commits@lists.jboss.org
Author: ozizka(a)redhat.com
Date: 2009-07-14 15:33:13 -0400 (Tue, 14 Jul 2009)
New Revision: 557
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java
Log:
Ejb tests updated
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java 2009-07-14 18:11:59 UTC (rev 556)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java 2009-07-14 19:33:13 UTC (rev 557)
@@ -32,8 +32,10 @@
+ public enum ResourceTypes {
+
+ }
-
/**
* Information about deployable types -
* navigation tree labels, archive extensions,
@@ -50,16 +52,22 @@
RAR(AppConstants.NAV_RAR, "RAR", "rar", ".rar", null, "application/rar"),
EMB_RAR(AppConstants.NAV_EMB_RAR,"Embedded RAR", "", ".rar", null, "application/rar"),
MC_BEAN(AppConstants.NAV_MC, "?", "mc", "", null, "application/java-archive"),
- EMB_WAR(AppConstants.NAV_EMB_WAR,"Embbedded WAR", "", ".war", null, "application/war");
+ EMB_WAR(AppConstants.NAV_EMB_WAR,"Embbedded WAR", "", ".war", null, "application/war"),
+ // TODO: Create a superclass for non-app resource types - ResourceTypes.
+ JBCACHE(AppConstants.NAV_JBCACHE, "JBoss Cache", null, null, null, null),
+ HBN(AppConstants.NAV_HBN, "Hibernate", null, null, null, null);
+
+
static{
EJB2.jmxMBeanNameFormat = "jboss.j2ee:module=\"%s\",service=EjbModule";
- EJB3.jmxMBeanNameFormat = "jboss.j2ee:ear=%s,jar=%s,service=EJB3";
+ EJB3.jmxMBeanNameFormat = "jboss.j2ee:ear=%1s,jar=%1s,service=EJB3";
}
private String jmxMBeanNameFormat;
private void setJmxMBeanNameFormat( String name ){ this.jmxMBeanNameFormat = name; }
public String getJmxMBeanNameFormat(){ return this.jmxMBeanNameFormat; }
+ public String formatJmxMBeanName( String deployableName ){ return String.format(this.jmxMBeanNameFormat, deployableName); }
@@ -131,8 +139,11 @@
public static final String NAV_EMB_WAR = "Embedded WARs";
public static final String NAV_EMB_RAR = "Embedded RARs";
+ // Non-app resource types.
public static final String NAV_SBMS = "Service Binding Managers";
public static final String NAV_SBM = "ServiceBindingManager";
+ public static final String NAV_JBCACHE = "JBoss Cache";
+ public static final String NAV_HBN = "Hibernate";
public static final String EAR_MALFORMED_APP_FILENAME = "malformed-application-xml.ear";
15 years, 6 months
EMBJOPR SVN: r556 - in trunk/jsfunit: src/test/java/org/jboss/jopr/jsfunit and 1 other directories.
by embjopr-commits@lists.jboss.org
Author: ozizka(a)redhat.com
Date: 2009-07-14 14:11:59 -0400 (Tue, 14 Jul 2009)
New Revision: 556
Modified:
trunk/jsfunit/
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS5.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ejb/EjbTestBase.java
Log:
Ejb20 tests updated
Property changes on: trunk/jsfunit
___________________________________________________________________
Name: svn:ignore
- nb-configuration.xml
TEST-TestSuite-01.xsl
CHANGES.txt
pom_1.xml
TEST-TestSuite-02.xsl
pom_05-XSLT.xml
pom_3.xml
pom_2.xml
pom_pure_maven.xml
target
TEST-TestSuite.xsl
pom_4.xml
nbactions.xml
+ nb-configuration.xml
TEST-TestSuite-01.xsl
parent
CHANGES.txt
pom_1.xml
TEST-TestSuite-02.xsl
pom_05-XSLT.xml
pom_3.xml
pom_2.xml
pom_pure_maven.xml
target
TEST-TestSuite.xsl
pom_4.xml
nbactions.xml
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS5.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS5.java 2009-07-13 14:18:10 UTC (rev 555)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/ApplicationTestBaseAS5.java 2009-07-14 18:11:59 UTC (rev 556)
@@ -166,19 +166,19 @@
/* RAR */
public boolean isRarDeployed(String rarName) throws RuntimeException
- {
- try {
- String query = "jboss.deployment:id=\"vfszip:" +
- System.getProperty("jsfunit.deploy.dir") + "/" + rarName + "/\",*";
- //String query = String.format("jboss.deployment:id=\"vfszip:%s/%s/\",*",
- // System.getProperty("jsfunit.deploy.dir"), rarName );
+ {
+ try {
+ String query = "jboss.deployment:id=\"vfszip:" +
+ System.getProperty("jsfunit.deploy.dir") + "/" + rarName + "/\",*";
+ //String query = String.format("jboss.deployment:id=\"vfszip:%s/%s/\",*",
+ // System.getProperty("jsfunit.deploy.dir"), rarName );
- return isMBeanStateDeployedByQuery(query);
- }
- catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
+ return isMBeanStateDeployedByQuery(query);
+ }
+ catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
/* RAR in EAR */
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java 2009-07-13 14:18:10 UTC (rev 555)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java 2009-07-14 18:11:59 UTC (rev 556)
@@ -93,6 +93,7 @@
* because setUp() is called before each test, a new HttpSession will be
* created each time a test is run.
*/
+ @Override
public void setUp() throws IOException
{
@@ -172,7 +173,7 @@
*/
public HtmlAnchor getNavTreeLink(String linkLabel)
{
- return getLinkInsideForm("navTreeForm", linkLabel);
+ return getLinkInsideForm("navTreeForm", linkLabel);
}
/**
@@ -181,14 +182,14 @@
*/
public HtmlButtonInput getDeleteButton(String formId, String resourceName)
{
- HtmlAnchor link = getLinkInsideForm(formId, resourceName);
- // The id will look like "resourceSummaryForm:dataTable:2:resourceName"
- // I need the row number. (2 in the above example)
- String id = link.getIdAttribute();
- String[] idElements = id.split(":");
- String row = idElements[idElements.length - 2];
- // resourceSummaryForm:dataTable:2:removeButton
- return (HtmlButtonInput)client.getElement(formId + ":dataTable:" + row + ":removeButton");
+ HtmlAnchor link = getLinkInsideForm(formId, resourceName);
+ // The id will look like "resourceSummaryForm:dataTable:2:resourceName"
+ // I need the row number. (2 in the above example)
+ String id = link.getIdAttribute();
+ String[] idElements = id.split(":");
+ String row = idElements[idElements.length - 2];
+ // resourceSummaryForm:dataTable:2:removeButton
+ return (HtmlButtonInput)client.getElement(formId + ":dataTable:" + row + ":removeButton");
}
/**
@@ -196,19 +197,19 @@
*/
public HtmlAnchor getLinkInsideForm(String formId, String linkLabel)
{
- HtmlForm form = (HtmlForm)client.getElement(formId);
- List links = form.getByXPath(".//a"); // get all <a> tags inside form
+ HtmlForm form = (HtmlForm)client.getElement(formId);
+ List links = form.getByXPath(".//a"); // get all <a> tags inside form
- for (Iterator i = links.iterator(); i.hasNext();)
- {
- HtmlAnchor link = (HtmlAnchor)i.next();
- String linkText = link.getTextContent();
-
- linkText = linkText.trim(); // ignore any leading or trailing spaces
- if (linkText.equals(linkLabel)) return link;
- }
+ for (Iterator i = links.iterator(); i.hasNext();)
+ {
+ HtmlAnchor link = (HtmlAnchor)i.next();
+ String linkText = link.getTextContent();
- throw new IllegalStateException("Link for '"+ linkLabel +"' not found in form #"+formId);
+ linkText = linkText.trim(); // ignore any leading or trailing spaces
+ if (linkText.equals(linkLabel)) return link;
+ }
+
+ throw new IllegalStateException("Link for '"+ linkLabel +"' not found in form #"+formId);
}
/**
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ejb/EjbTestBase.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ejb/EjbTestBase.java 2009-07-13 14:18:10 UTC (rev 555)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ejb/EjbTestBase.java 2009-07-14 18:11:59 UTC (rev 556)
@@ -76,6 +76,8 @@
final String DEPLOYABLE_NAME = getArchiveNameBasic();
+ DebugUtils.writeFile("target/noForm.html", client.getPageAsText());///
+
try {
// Navigate to EJB Applications
HtmlAnchor ejbLink = getNavTreeLink(APP_TYPE.getNavTreeLabel());
@@ -159,7 +161,7 @@
Upload the fixed the achive, redeploy and
verify the archive has been successfully deployed.
*/
- public void testEjbDeployBadAndRedeploy() throws IOException, HtmlElementNotFoundException, ActionNotAvailableException {
+ public void testEjbDeployBadAndRedeploy() throws IOException, HtmlElementNotFoundException, ActionNotAvailableException, EmbJoprTestException {
final String REDEPLOY_JAR_NAME = getArchiveNameRedeploy();
@@ -183,7 +185,7 @@
assertTrue(FacesMessage.SEVERITY_INFO.equals(successMessage.getSeverity()));
assertTrue(successMessage.getDetail().contains("Resource " + REDEPLOY_JAR_NAME + " created successfully!"));
// Use JMX to assert that the EJB components really did deploy successfully.
- assertTrue("JMX should report " + REDEPLOY_JAR_NAME + " as deployed.", isEJBDeployed(REDEPLOY_JAR_NAME));
+ assertTrue("JMX should report " + REDEPLOY_JAR_NAME + " as deployed.", ejtt.deployment.isDeployedAccordingToJMX(APP_TYPE, REDEPLOY_JAR_NAME));
}
finally {
15 years, 6 months
EMBJOPR SVN: r555 - trunk/jsfunit.
by embjopr-commits@lists.jboss.org
Author: ozizka(a)redhat.com
Date: 2009-07-13 10:18:10 -0400 (Mon, 13 Jul 2009)
New Revision: 555
Modified:
trunk/jsfunit/pom.xml
Log:
Cargo timeout down to 5 mins (was 10) - shutdown is currently failing until cargo is fixed.
Modified: trunk/jsfunit/pom.xml
===================================================================
--- trunk/jsfunit/pom.xml 2009-07-13 12:13:50 UTC (rev 554)
+++ trunk/jsfunit/pom.xml 2009-07-13 14:18:10 UTC (rev 555)
@@ -327,7 +327,7 @@
<containerId>jboss5x</containerId>
<home>${JBOSS_HOME}</home> <!-- Binaries used by Cargo. -->
<log>${basedir}/target/jboss5.x.logs/cargo.log</log>
- <timeout>600000</timeout> <!-- 10 minutes -->
+ <timeout>300000</timeout> <!-- 5 minutes -->
<systemProperties>
<!-- Used in jboss-log4j.xml. See /testdata/... -->
<jboss.server.log.threshold>ALL</jboss.server.log.threshold>
@@ -418,16 +418,12 @@
<execution>
<id>start-container</id>
<phase>pre-integration-test</phase>
- <goals>
- <goal>start</goal>
- </goals>
+ <goals> <goal>start</goal> </goals>
</execution>
<execution>
<id>stop-container</id>
<phase>post-integration-test</phase>
- <goals>
- <goal>stop</goal>
- </goals>
+ <goals> <goal>stop</goal> </goals>
</execution>
</executions>
</plugin>
15 years, 6 months
EMBJOPR SVN: r554 - in trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit: as5/app/ear and 2 other directories.
by embjopr-commits@lists.jboss.org
Author: ozizka(a)redhat.com
Date: 2009-07-13 08:13:50 -0400 (Mon, 13 Jul 2009)
New Revision: 554
Added:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ear/AbstractProfileServiceTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ear/RepeatedDeploymentViaPSTest.java
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ejb/EjbTestBase.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java
Log:
EJB 2.0 tests updated.
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java 2009-07-08 19:13:36 UTC (rev 553)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java 2009-07-13 12:13:50 UTC (rev 554)
@@ -52,6 +52,17 @@
MC_BEAN(AppConstants.NAV_MC, "?", "mc", "", null, "application/java-archive"),
EMB_WAR(AppConstants.NAV_EMB_WAR,"Embbedded WAR", "", ".war", null, "application/war");
+ static{
+ EJB2.jmxMBeanNameFormat = "jboss.j2ee:module=\"%s\",service=EjbModule";
+ EJB3.jmxMBeanNameFormat = "jboss.j2ee:ear=%s,jar=%s,service=EJB3";
+ }
+
+ private String jmxMBeanNameFormat;
+ private void setJmxMBeanNameFormat( String name ){ this.jmxMBeanNameFormat = name; }
+ public String getJmxMBeanNameFormat(){ return this.jmxMBeanNameFormat; }
+
+
+
// -- Fields --
protected final String navTreeLabel;
Added: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ear/AbstractProfileServiceTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ear/AbstractProfileServiceTest.java (rev 0)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ear/AbstractProfileServiceTest.java 2009-07-13 12:13:50 UTC (rev 554)
@@ -0,0 +1,256 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jopr.jsfunit.as5.app.ear;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.naming.InitialContext;
+
+import javax.naming.NamingException;
+import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.deployers.spi.management.deploy.DeploymentManager;
+import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
+import org.jboss.jopr.jsfunit.EmbjoprTestCase;
+import org.jboss.managed.api.ComponentType;
+import org.jboss.managed.api.DeploymentTemplateInfo;
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.MetaValueFactory;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.ProfileService;
+import org.jboss.virtual.VFS;
+
+/**
+ * @author <a href="mailto:alex@jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 87016 $</tt>
+ */
+public abstract class AbstractProfileServiceTest
+ extends EmbjoprTestCase
+{
+
+ /** We use the default profile, defined by DeploymentManager to deploy apps. */
+ public static final ProfileKey defaultProfile = new ProfileKey(ProfileKey.DEFAULT);
+
+ protected ManagementView activeView;
+ protected DeploymentManager deployMgr;
+ private MetaValueFactory metaValueFactory;
+
+ public AbstractProfileServiceTest(String name){
+ //super(name);
+ super();
+ }
+ public AbstractProfileServiceTest(){
+ super();
+ }
+
+ /**
+ * @return the ProfileKey.name to use when loading the profile
+ */
+ protected String getProfileName()
+ {
+ return null;
+ }
+
+ protected ProfileKey getProfileKey()
+ {
+ if(getProfileName() == null)
+ return defaultProfile;
+
+ return new ProfileKey(getProfileName());
+ }
+
+ protected void removeDeployment(String deployment)
+ throws Exception
+ {
+ String names[] = new String[] {deployment};
+ DeploymentManager deployMgr = getDeploymentManager();
+ try
+ {
+ DeploymentProgress progress = deployMgr.stop(names);
+ progress.run();
+ assertFalse("failed: " + progress.getDeploymentStatus().getFailure(), progress.getDeploymentStatus().isFailed());
+ }
+ finally
+ {
+ DeploymentProgress progress = deployMgr.remove(names);
+ progress.run();
+ assertFalse("failed: " + progress.getDeploymentStatus().getFailure(), progress.getDeploymentStatus().isFailed());
+ }
+ }
+
+ protected void createComponentTest(String templateName,
+ Map<String, MetaValue> propValues,
+ String deploymentName,
+ ComponentType componentType, String componentName)
+ throws Exception
+ {
+ createComponentTest(templateName, propValues, deploymentName, componentType, componentName, true);
+ }
+
+ protected void createComponentTest(String templateName,
+ Map<String, MetaValue> propValues,
+ String deploymentName,
+ ComponentType componentType, String componentName,
+ boolean processChanges)
+ throws Exception
+ {
+ Set<String> removedPropNames = Collections.emptySet();
+ createComponentTest(templateName, propValues, removedPropNames,
+ deploymentName, componentType, componentName, processChanges);
+ }
+ protected void createComponentTest(String templateName,
+ Map<String, MetaValue> propValues,
+ Set<String> removedPropNames,
+ String deploymentName,
+ ComponentType componentType, String componentName,
+ boolean processChanges)
+ throws Exception
+ {
+ ManagementView mgtView = getManagementView();
+ DeploymentTemplateInfo info = mgtView.getTemplate(templateName);
+ assertNotNull("template " + templateName + " found", info);
+ Map<String, ManagedProperty> props = info.getProperties();
+ for(String propName : propValues.keySet())
+ {
+ ManagedProperty prop = props.get(propName);
+ log.debug("createComponentTest("+propName+") before: "+prop.getValue());
+ assertNotNull("property " + propName + " found in template " + templateName, prop);
+ prop.setValue(propValues.get(propName));
+ log.debug("createComponentTest("+propName+") after: "+prop.getValue());
+ }
+ for(String propName : removedPropNames)
+ {
+ ManagedProperty prop = props.get(propName);
+ prop.setRemoved(true);
+ log.debug("removed property: "+propName);
+ }
+
+ mgtView.applyTemplate(deploymentName, info);
+ if(processChanges)
+ {
+ mgtView.process();
+
+ // reload the view
+ activeView = null;
+ mgtView = getManagementView();
+ ManagedComponent dsMC = getManagedComponent(mgtView, componentType, componentName);
+ assertNotNull(dsMC);
+
+ Set<String> mcPropNames = new HashSet<String>(dsMC.getPropertyNames());
+ for(String propName : propValues.keySet())
+ {
+ ManagedProperty prop = dsMC.getProperty(propName);
+ assertNotNull(prop);
+ Object propValue = prop.getValue();
+ Object expectedValue = propValues.get(propName);
+ assertEquals(prop.getName(), expectedValue, propValue);
+
+ mcPropNames.remove(propName);
+ }
+
+ if(!mcPropNames.isEmpty())
+ {
+ log.warn(getName() + "> untested properties: " + mcPropNames);
+ }
+ }
+ }
+
+ /**
+ * Obtain the ProfileService.ManagementView
+ * @return
+ * @throws Exception
+ */
+ protected ManagementView getManagementView()
+ throws Exception
+ {
+ if( activeView == null )
+ {
+ InitialContext ctx = getInitialContext();
+ ProfileService ps = (ProfileService) ctx.lookup("ProfileService");
+ activeView = ps.getViewManager();
+ // Init the VFS to setup the vfs* protocol handlers
+ VFS.init();
+ }
+ // Reload
+ activeView.load();
+ return activeView;
+ }
+ /**
+ * Obtain the ProfileService.ManagementView
+ * @return
+ * @throws Exception
+ */
+ protected DeploymentManager getDeploymentManager()
+ throws Exception
+ {
+ if( deployMgr == null )
+ {
+ InitialContext ctx = getInitialContext();
+ ProfileService ps = (ProfileService) ctx.lookup("ProfileService");
+ deployMgr = ps.getDeploymentManager();
+ deployMgr.loadProfile(getProfileKey());
+ // Init the VFS to setup the vfs* protocol handlers
+ VFS.init();
+ }
+ return deployMgr;
+ }
+
+ /**
+ * Locate the given ComponentType with the given component name.
+ *
+ * @param mgtView -
+ * @return the matching ManagedComponent if found, null otherwise
+ * @throws Exception
+ */
+ protected ManagedComponent getManagedComponent(ManagementView mgtView, ComponentType type, String name)
+ throws Exception
+ {
+ Set<ManagedComponent> comps = mgtView.getComponentsForType(type);
+ ManagedComponent mc = null;
+ for (ManagedComponent comp : comps)
+ {
+ String cname = comp.getName();
+ if( cname.endsWith(name) )
+ {
+ mc = comp;
+ break;
+ }
+ }
+ return mc;
+ }
+
+ protected MetaValueFactory getMetaValueFactory()
+ {
+ if(metaValueFactory == null)
+ metaValueFactory = MetaValueFactory.getInstance();
+ return metaValueFactory;
+ }
+
+ InitialContext getInitialContext() throws NamingException{
+ return new InitialContext();
+ }
+
+}
Added: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ear/RepeatedDeploymentViaPSTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ear/RepeatedDeploymentViaPSTest.java (rev 0)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ear/RepeatedDeploymentViaPSTest.java 2009-07-13 12:13:50 UTC (rev 554)
@@ -0,0 +1,148 @@
+package org.jboss.jopr.jsfunit.as5.app.ear;
+
+
+
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Set;
+
+
+import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.deployers.spi.management.deploy.DeploymentManager;
+import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
+import org.jboss.deployers.spi.management.deploy.DeploymentStatus;
+import org.jboss.logging.Logger;
+import org.jboss.managed.api.ManagedDeployment;
+import org.jboss.deployers.spi.management.deploy.ProgressListener;
+import org.jboss.jopr.jsfunit.AppConstants;
+import org.jboss.jopr.jsfunit.exceptions.EmbJoprTestException;
+
+
+/**
+ * Mostly copied from
+ * jboss-as-5.x/testsuite/src/main/org/jboss/test/profileservice/test
+ */
+public class RepeatedDeploymentViaPSTest extends AbstractProfileServiceTest implements ProgressListener {
+
+
+
+ public void testRepeatedDeploymentViaProfileService() throws Exception {
+
+
+ final String DEPLOYABLE_NAME = AppConstants.BASIC_EAR;
+ int TURNS = 100;
+
+ String earFilePath = ejtt.getTestDataDir() + "/ear/"+DEPLOYABLE_NAME;
+
+ for (int i = TURNS; i > 0; i--) {
+ log.info("Remaining EAR deploys: "+i);
+ // Deploy and undeploy the EAR.
+ doDeployment(earFilePath, "ear", null);
+ }
+
+ }
+
+
+
+
+
+
+
+ public void progressEvent(org.jboss.deployers.spi.management.deploy.ProgressEvent eventInfo) {
+ getLog().debug(eventInfo);
+ }
+
+ public URL getDeployURL( String file ) throws MalformedURLException{
+ return new URL("file:///"+ System.getProperty(AppConstants.SYSPROP_DEPLOY_DIR)+'/'+file );
+ }
+
+
+
+ protected final Logger log = Logger.getLogger(this.getClass().getName());
+ Logger getLog(){ return log; }
+
+ @SuppressWarnings("deprecation")
+ protected void doDeployment(String name, String type, ManagedDeploymentTester tester) throws Exception
+ {
+ DeploymentManager deployMgr = getDeploymentManager();
+ URL contentURL = getDeployURL(name);
+ assertNotNull(contentURL);
+ getLog().debug(contentURL);
+ // TODO - hack to get off JDK's url handling
+ String urlString = contentURL.toExternalForm();
+ int p = urlString.indexOf(":/");
+ contentURL = new URL("vfszip" + urlString.substring(p));
+ getLog().debug(contentURL);
+
+ DeploymentStatus status;
+ DeploymentProgress progress = deployMgr.distribute(name, contentURL, true);
+ progress.addProgressListener(this);
+ progress.run();
+ String[] uploadedNames = {};
+ try
+ {
+ status = progress.getDeploymentStatus();
+ assertTrue("DeploymentStatus.isCompleted: " + status, status.isCompleted());
+ // It should not be running yet
+ assertFalse("DeploymentStatus.isRunning: " + status, status.isRunning());
+ assertFalse("DeploymentStatus.isFailed: " + status, status.isFailed());
+
+ // Get the unique deployment name
+ uploadedNames = progress.getDeploymentID().getRepositoryNames();
+ getLog().debug("Uploaded deployment names: "+Arrays.asList(uploadedNames));
+ // Now start the deployment
+ progress = deployMgr.start(uploadedNames);
+ progress.addProgressListener(this);
+ progress.run();
+ try
+ {
+ status = progress.getDeploymentStatus();
+ assertTrue("DeploymentStatus.isCompleted: " + status, status.isCompleted());
+ assertFalse("DeploymentStatus.isRunning: " + status, status.isRunning());
+ assertFalse("DeploymentStatus.isFailed: " + status, status.isFailed());
+ // Check for a
+ ManagementView mgtView = getManagementView();
+ ManagedDeployment deployment = mgtView.getDeployment(uploadedNames[0]);
+ assertNotNull(deployment);
+ getLog().info("Found " + type + " deployment: " + deployment);
+ Set<String> types = deployment.getTypes();
+ if (types != null && types.isEmpty() == false)
+ assertTrue("Missing type: " + type + ", available: " + types, types.contains(type));
+ if (tester != null)
+ {
+ tester.testManagedDeployment();
+ }
+ }
+ finally
+ {
+ //Thread.sleep(15 * 1000); // 15 secs >> more than it takes for reaper to run :-)
+
+ // Stop/remove the deployment
+ progress = deployMgr.stop(uploadedNames);
+ progress.addProgressListener(this);
+ progress.run();
+ status = progress.getDeploymentStatus();
+ assertTrue("DeploymentStatus.isCompleted: " + status, status.isCompleted());
+ assertFalse("DeploymentStatus.isFailed: " + status, status.isFailed());
+ }
+ }
+ finally
+ {
+ progress = deployMgr.remove(uploadedNames);
+ progress.addProgressListener(this);
+ progress.run();
+ status = progress.getDeploymentStatus();
+ assertTrue("DeploymentStatus.isCompleted: " + status, status.isCompleted());
+ assertFalse("DeploymentStatus.isFailed: " + status, status.isFailed());
+ }
+ }
+
+
+ private interface ManagedDeploymentTester
+ {
+ void testManagedDeployment() throws Exception;
+ }
+
+}
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ejb/EjbTestBase.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ejb/EjbTestBase.java 2009-07-08 19:13:36 UTC (rev 553)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/app/ejb/EjbTestBase.java 2009-07-13 12:13:50 UTC (rev 554)
@@ -123,7 +123,8 @@
// Use JMX to assert that the EJB components really did deploy successfully
- assertTrue("JMX doesn't report '"+DEPLOYABLE_NAME+"' as deployed.", isEJBDeployed(DEPLOYABLE_NAME));
+ //assertTrue("JMX doesn't report '"+DEPLOYABLE_NAME+"' as deployed.", isEJBDeployed(DEPLOYABLE_NAME));
+ assertTrue("JMX doesn't report '"+DEPLOYABLE_NAME+"' as deployed.", ejtt.deployment.isDeployedAccordingToJMX(APP_TYPE, DEPLOYABLE_NAME));
// Undeploy the EJB JAR
HtmlButtonInput deleteButton = getAppDeleteButton(DEPLOYABLE_NAME);
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-07-08 19:13:36 UTC (rev 553)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EmbJoprTestToolkit.java 2009-07-13 12:13:50 UTC (rev 554)
@@ -7,6 +7,8 @@
import java.net.UnknownHostException;
import java.util.*;
+import java.util.logging.Level;
+import javax.management.MalformedObjectNameException;
import org.jboss.jopr.jsfunit.exceptions.*;
import com.gargoylesoftware.htmlunit.html.*;
import com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine;
@@ -23,6 +25,9 @@
import java.util.zip.ZipInputStream;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
+import javax.management.JMException;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.NumberUtils;
@@ -32,6 +37,7 @@
import org.jboss.jopr.jsfunit.EmbjoprTestCase;
import org.jboss.jsfunit.jsfsession.*;
import org.jboss.logging.Logger;
+import org.jboss.mx.util.MBeanServerLocator;
import org.mozilla.javascript.NativeFunction;
import org.w3c.dom.Element;
@@ -45,7 +51,7 @@
*/
public class EmbJoprTestToolkit {
- private Logger log = Logger.getLogger(EmbJoprTestToolkit.class.getName());
+ private static Logger log = Logger.getLogger(EmbJoprTestToolkit.class.getName());
protected JSFClientSession client;
protected JSFServerSession server;
@@ -1709,17 +1715,67 @@
*/
public class Deployment {
- // TODO: Shortcuts:
- /*
- private void deployWAR( String warFilePath ){}
- private void undeployWAR( String warFileName ){}
- private void deployEAR( String warFilePath ){}
- private void undeployEAR( String warFileName ){}
- // Etc. */
+ /**
+ * Makes an MBean name and checks via JMX whether it is deployed.
+ */
+ public boolean isDeployedAccordingToJMX( AppConstants.DeployableTypes type, String deployableName )
+ throws EmbJoprTestException, IOException
+ {
+ // Get the MBean name.
+ String mBeanNameFormat = type.getJmxMBeanNameFormat();
+ if( null == mBeanNameFormat )
+ throw new UnsupportedOperationException("JMX name for this filled yet.");
+ String mBeanName = String.format( mBeanNameFormat, deployableName );
+ // Check whether the mBean is deployed.
+ try {
+ return isMBeanStateDeployedByQuery(mBeanName);
+ } catch (MalformedObjectNameException ex) {
+ throw new EmbJoprTestException("Malformed name: "+mBeanName, ex);
+ } catch (JMException ex) {
+ throw new EmbJoprTestException(ex);
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+
+
/**
+ * Queries JBoss via JMX for given query and checks whether the
+ * StateString property of the first result is "Started".
+ *
+ * @param mBeanName
+ * @return true if the StateString property of the first MBean found is "Started".
+ * @throws javax.management.JMException
+ * @throws java.io.IOException
+ */
+ protected boolean isMBeanStateDeployedByQuery(String mBeanName) throws JMException, IOException, MalformedObjectNameException
+ {
+ log.info("Querying JMX: "+mBeanName);
+ ObjectName objName = new ObjectName(mBeanName);
+ MBeanServer jmxServer = MBeanServerLocator.locateJBoss();
+ Set mBeans = jmxServer.queryNames(objName, null);
+ if (mBeans.size() != 1) {
+ log.info(mBeanName+" not found.");
+ return false;
+ }
+ ObjectName deploymentMBean = (ObjectName) mBeans.iterator().next();
+ // Returns org.jboss.deployers.spi.DeploymentState.
+ Object state = jmxServer.getAttribute(deploymentMBean, "State");
+ log.info("State is '"+state.toString()+"'.");
+ return
+ "DEPLOYED".equals(state.toString()) // AS 4
+ || "3".equals(state.toString()) // AS 5; StateString = "Deployed"
+ || "8".equals(state.toString()) // EJB: "Registered"
+ ;
+ }
+
+
+
+
+ /**
* Deploys the deployable using EmbJopr's web UI.
*
* @param type Type of the deployable - EAR, SAR, WAR, ...
@@ -1804,8 +1860,6 @@
throw new EmbJoprTestException(ex.getClass().getName()+": "+ex.getMessage(), ex);
}
-
-
}
@@ -1859,6 +1913,7 @@
return isDeployedAccordingToEmbJopr( type, deployableName, false );
}
+
/**
* Returns true if EmbJopr lists a deployable of given type and name,
* and it's State is UP; false otherwise.
@@ -1870,25 +1925,6 @@
// Refresh / go to the appropriate page.
getNavTree().getNodeByLabel( type.getNavTreeLabel() ).click();
- // Pagination
- //int totalItemsCount = getTabMenu().getTabContentBox().getPagination().getTotalItemsCount();
-
- /*
- ContentTableRow appRow = null;
-
- // Search trough all pages.
- int currentPage = 1;
- do {
- appRow = getDefaultContentTable().findFirstRowContainingLink(deployableName);
- if( null != appRow ){
- break;
- }else{
- log.debug("Row with "+deployableName+" not present on page "+currentPage+".");
- }
- } while( currentPage++ < 20 && getTabMenu().getTabContentBox().getPagination().goNext() );
-
- */
-
// Find the row containing the deployable. Use the pagination if needed.
ContentTableRow appRow = getTabMenu().getTabContentBox().
findLinkRowInDataTableUsingPagination(deployableName);
@@ -1983,14 +2019,14 @@
* Returns true if there's a file of the given name in server's deploy dir;
* false otherwise.
*/
- private boolean isDeployedAccordingToFileSystem( DeployableTypes type, String name )
+ public boolean isDeployedAccordingToFileSystem( DeployableTypes type, String name )
{
String deployPath = getDeployDir();
String fileName = deployPath+"/"+name;
return (new File(fileName)).exists();
}
- private void undeployViaFileSystem( String name ) throws EmbJoprTestException{
+ public void undeployViaFileSystem( String name ) throws EmbJoprTestException{
String deployPath = getDeployDir();
String fileName = deployPath+"/"+name;
File fileToDelete = new File(fileName);
15 years, 6 months
EMBJOPR SVN: r553 - trunk/jbas5.
by embjopr-commits@lists.jboss.org
Author: ips
Date: 2009-07-08 15:13:36 -0400 (Wed, 08 Jul 2009)
New Revision: 553
Modified:
trunk/jbas5/pom.xml
Log:
add the Hibernate plugin to the WAR's plugins dir (https://jira.jboss.org/jira/browse/EMBJOPR-203)
Modified: trunk/jbas5/pom.xml
===================================================================
--- trunk/jbas5/pom.xml 2009-06-23 05:37:47 UTC (rev 552)
+++ trunk/jbas5/pom.xml 2009-07-08 19:13:36 UTC (rev 553)
@@ -68,6 +68,12 @@
<!-- other plugins -->
<artifactItem>
<groupId>${jopr.groupId}</groupId>
+ <artifactId>jopr-hibernate-plugin</artifactId>
+ <version>${jopr.version}</version>
+ </artifactItem>
+
+ <artifactItem>
+ <groupId>${jopr.groupId}</groupId>
<artifactId>jopr-jboss-cache5-plugin</artifactId>
<version>${jopr.version}</version>
</artifactItem>
15 years, 6 months