Skip to content

Commit

Permalink
Conversation tests, restart jboss during tck run...
Browse files Browse the repository at this point in the history
git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@1815 1c488680-804c-0410-94cd-c6b725194a0e
  • Loading branch information
pmuir committed Mar 8, 2009
1 parent 8f1bb8d commit 1422b2c
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 42 deletions.
3 changes: 2 additions & 1 deletion impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
Expand Up @@ -37,6 +37,7 @@

import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.context.DependentInstancesStore;
import org.jboss.webbeans.conversation.ConversationImpl;
import org.jboss.webbeans.injection.AnnotatedInjectionPoint;
import org.jboss.webbeans.introspector.AnnotatedField;
import org.jboss.webbeans.introspector.AnnotatedItem;
Expand All @@ -62,7 +63,7 @@ public abstract class AbstractBean<T, E> extends RIBean<T>
{

@SuppressWarnings("unchecked")
private static Set<Class<?>> STANDARD_WEB_BEAN_CLASSES = new HashSet<Class<?>>(Arrays.asList(Event.class, ManagerImpl.class));
private static Set<Class<?>> STANDARD_WEB_BEAN_CLASSES = new HashSet<Class<?>>(Arrays.asList(Event.class, ManagerImpl.class, ConversationImpl.class));

private boolean proxyable;

Expand Down
Expand Up @@ -222,7 +222,7 @@ protected void initDeploymentType()
}
else if (deploymentTypes.size() > 1)
{
throw new DefinitionException("At most one scope may be specified");
throw new DefinitionException("At most one deployment type may be specified");
}
}

Expand Down
Expand Up @@ -172,7 +172,7 @@ public AnnotatedMethod<?> getDisposalMethod()
public String toString()
{
StringBuilder buffer = new StringBuilder();
buffer.append("Annotated " + Names.scopeTypeToString(getScopeType()));
buffer.append(Names.scopeTypeToString(getScopeType()));
if (getName() == null)
{
buffer.append("unnamed producer method bean");
Expand Down
Expand Up @@ -21,8 +21,8 @@
import javax.context.Conversation;
import javax.context.RequestScoped;
import javax.inject.Initializer;
import javax.inject.Standard;

import org.jboss.webbeans.WebBean;
import org.jboss.webbeans.conversation.bindings.ConversationInactivityTimeout;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
Expand All @@ -35,7 +35,7 @@
*/
@RequestScoped
@Named("conversation")
@WebBean
@Standard
public class ConversationImpl implements Conversation
{

Expand Down
Expand Up @@ -4,7 +4,6 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
Expand Down Expand Up @@ -34,6 +33,8 @@ public abstract class AbstractContainersImpl implements Configurable, Containers
public static final String JBOSS_AS_DIR_PROPERTY_NAME = "jboss-as.dir";
public static final String JBOSS_BOOT_TIMEOUT_PROPERTY_NAME = "jboss.boot.timeout";
public static final String FORCE_RESTART_PROPERTY_NAME = "jboss.force.restart";
public static final String MAX_DEPLOYMENTS_PROPERTY_NAME = "jboss.deployments.restart";
public static final String SHUTDOWN_DELAY_PROPERTY_NAME = "jboss.shutdown.delay";

private static Logger log = Logger.getLogger(AbstractContainersImpl.class);

Expand All @@ -46,6 +47,12 @@ public abstract class AbstractContainersImpl implements Configurable, Containers
private long bootTimeout;
private String javaOpts;

private boolean forceRestart;

protected int maxDeployments;

private int jbossShutdownDelay;

public AbstractContainersImpl()
{
this.properties = new DeploymentProperties();
Expand Down Expand Up @@ -127,15 +134,23 @@ public void setup() throws IOException
jbossHome = jbossHomeFile.getPath();
log.info("Using JBoss instance in " + jbossHome + " at URL " + configuration.getHost());
this.bootTimeout = properties.getLongValue(JBOSS_BOOT_TIMEOUT_PROPERTY_NAME, 240000, false);
if (properties.getBooleanValue(FORCE_RESTART_PROPERTY_NAME, false, false))
this.forceRestart = properties.getBooleanValue(FORCE_RESTART_PROPERTY_NAME, false, false);
this.maxDeployments = properties.getIntValue(MAX_DEPLOYMENTS_PROPERTY_NAME, 25, false);
this.jbossShutdownDelay = properties.getIntValue(SHUTDOWN_DELAY_PROPERTY_NAME, 15000, false);
restartJboss();
}

protected void restartJboss() throws IOException
{
if (forceRestart)
{
if (isJBossUp())
{
log.info("Shutting down JBoss instance as in force-restart mode");
shutDownJBoss();
try
{
Thread.sleep(10000);
Thread.sleep(jbossShutdownDelay);
}
catch (InterruptedException e)
{
Expand Down Expand Up @@ -176,10 +191,6 @@ public void setup() throws IOException
launch("shutdown", "-S");
throw new IllegalStateException("Error connecting to JBoss instance");
}
else
{
return;
}
}

protected void loadProperties(File file) throws IOException
Expand Down
Expand Up @@ -29,6 +29,7 @@ public class ProfileServiceContainersImpl extends AbstractContainersImpl

private DeploymentManager deploymentManager;
private final File tmpdir;
private int deploymentCounter = 0;


public ProfileServiceContainersImpl() throws Exception
Expand Down Expand Up @@ -76,7 +77,7 @@ public void deploy(InputStream archiveStream, String name) throws DeploymentExce
if (status.isFailed())
{
failure = status.getFailure();
undeploy(name);
doUndeploy(name);
}
}
catch (Exception e)
Expand All @@ -102,7 +103,7 @@ public void deploy(InputStream archiveStream, String name) throws DeploymentExce
}
}

public void undeploy(String name) throws IOException
private void doUndeploy(String name) throws IOException
{
try
{
Expand All @@ -113,14 +114,54 @@ public void undeploy(String name) throws IOException
undeployProgress.run();
if (undeployProgress.getDeploymentStatus().isFailed())
{
failedUndeployments.add(name);
failedUndeployments.add(name);
}
else
{
deploymentCounter++;
}
}
catch (Exception e)
{
IOException ioe = new IOException();
ioe.initCause(e);
throw ioe;
IOException ioe = new IOException();
ioe.initCause(e);
throw ioe;
}
}

public void undeploy(String name) throws IOException
{
try
{
doUndeploy(name);
}
finally
{
if (deploymentCounter >= maxDeployments)
{
deploymentCounter = 0;
// Let everything stablise
removeFailedUnDeployments();
try
{
Thread.sleep(5000);
}
catch (InterruptedException e)
{
Thread.currentThread().interrupt();
}
restartJboss();
try
{
initDeploymentManager();
}
catch (Exception e)
{
IOException ioe = new IOException();
ioe.initCause(e);
throw ioe;
}
}
}
}

Expand All @@ -143,30 +184,36 @@ protected void initDeploymentManager() throws Exception
@Override
public void cleanup() throws IOException
{
removeFailedUnDeployments();
super.cleanup();
List<String> remainingDeployments = new ArrayList<String>();
for (String name : failedUndeployments)
{
try
{
DeploymentProgress undeployProgress = deploymentManager.undeploy(DeploymentPhase.APPLICATION, name);
undeployProgress.run();
if (undeployProgress.getDeploymentStatus().isFailed())
{
remainingDeployments.add(name);
}
}
catch (Exception e)
{
IOException ioe = new IOException();
ioe.initCause(e);
throw ioe;
}
}
if (remainingDeployments.size() > 0)
{
//log.error("Failed to undeploy these artifacts: " + remainingDeployments);
}
}

private void removeFailedUnDeployments() throws IOException
{
List<String> remainingDeployments = new ArrayList<String>();
for (String name : failedUndeployments)
{
try
{
DeploymentProgress undeployProgress = deploymentManager.undeploy(DeploymentPhase.APPLICATION, name);
undeployProgress.run();
if (undeployProgress.getDeploymentStatus().isFailed())
{
remainingDeployments.add(name);
}
}
catch (Exception e)
{
IOException ioe = new IOException();
ioe.initCause(e);
throw ioe;
}
}
if (remainingDeployments.size() > 0)
{
//log.error("Failed to undeploy these artifacts: " + remainingDeployments);
}
failedUndeployments.clear();
}

}
2 changes: 1 addition & 1 deletion jboss-tck-runner/src/test/resources/log4j.xml
Expand Up @@ -6,7 +6,7 @@
<param name="Target" value="System.out"/>
<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
<param name="ConversionPattern" value="%-5p [%c{6}] %m%n"/>
<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{6}] %m%n"/>
</layout>
</appender>

Expand Down

0 comments on commit 1422b2c

Please sign in to comment.