pull/2071/head
Phillip Webb 10 years ago
parent 0a8bc482fa
commit 447c9ff204

@ -57,7 +57,7 @@ class JmsAnnotationDrivenConfiguration {
ConnectionFactory connectionFactory) { ConnectionFactory connectionFactory) {
DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory(); DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
factory.setConnectionFactory(connectionFactory); factory.setConnectionFactory(connectionFactory);
factory.setPubSubDomain(properties.isPubSubDomain()); factory.setPubSubDomain(this.properties.isPubSubDomain());
if (this.transactionManager != null) { if (this.transactionManager != null) {
factory.setTransactionManager(this.transactionManager); factory.setTransactionManager(this.transactionManager);
} }

@ -33,8 +33,8 @@ import org.springframework.jms.annotation.EnableJms;
import org.springframework.jms.config.DefaultJmsListenerContainerFactory; import org.springframework.jms.config.DefaultJmsListenerContainerFactory;
import org.springframework.jms.config.JmsListenerConfigUtils; import org.springframework.jms.config.JmsListenerConfigUtils;
import org.springframework.jms.config.JmsListenerContainerFactory; import org.springframework.jms.config.JmsListenerContainerFactory;
import org.springframework.jms.config.SimpleJmsListenerContainerFactory;
import org.springframework.jms.config.JmsListenerEndpoint; import org.springframework.jms.config.JmsListenerEndpoint;
import org.springframework.jms.config.SimpleJmsListenerContainerFactory;
import org.springframework.jms.core.JmsMessagingTemplate; import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.jms.core.JmsTemplate; import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.listener.DefaultMessageListenerContainer; import org.springframework.jms.listener.DefaultMessageListenerContainer;

@ -62,6 +62,16 @@ public class CommandException extends RuntimeException {
this.options = asEnumSet(options); this.options = asEnumSet(options);
} }
/**
* Create a new {@link CommandException} with the specified options.
* @param cause the underlying cause
* @param options the exception options
*/
public CommandException(Throwable cause, Option... options) {
super(cause);
this.options = asEnumSet(options);
}
private EnumSet<Option> asEnumSet(Option[] options) { private EnumSet<Option> asEnumSet(Option[] options) {
if (options == null || options.length == 0) { if (options == null || options.length == 0) {
return EnumSet.noneOf(Option.class); return EnumSet.noneOf(Option.class);
@ -100,6 +110,7 @@ public class CommandException extends RuntimeException {
* Re-throw the exception rather than dealing with it. * Re-throw the exception rather than dealing with it.
*/ */
RETHROW RETHROW
} }
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2014 original authors * Copyright 2012-2014 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -13,16 +13,21 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.boot.cli.command.test; package org.springframework.boot.cli.command.test;
import org.springframework.boot.cli.command.CommandException;
/** /**
* Thrown when tests fail to execute * Thrown when tests fail to execute.
* *
* @author Graeme Rocher * @author Graeme Rocher
* @since 1.2 * @since 1.2.0
*/ */
public class TestFailedException extends RuntimeException { public class TestFailedException extends CommandException {
public TestFailedException(Throwable cause) { public TestFailedException(Throwable cause) {
super(cause); super(cause, Option.HIDE_MESSAGE);
} }
} }

@ -17,18 +17,19 @@
package org.springframework.boot.cli.command.test; package org.springframework.boot.cli.command.test;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.springframework.boot.cli.compiler.GroovyCompiler; import org.springframework.boot.cli.compiler.GroovyCompiler;
import org.springframework.boot.groovy.DelegateTestRunner; import org.springframework.boot.groovy.DelegateTestRunner;
import org.springframework.util.ReflectionUtils;
/** /**
* Compile and run groovy based tests. * Compile and run groovy based tests.
* *
* @author Phillip Webb * @author Phillip Webb
* @author Graeme Rocher
*/ */
public class TestRunner { public class TestRunner {
@ -63,17 +64,16 @@ public class TestRunner {
runThread.start(); runThread.start();
runThread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { runThread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override @Override
public void uncaughtException(Thread t, Throwable e) { public void uncaughtException(Thread t, Throwable ex) {
// rethrow exception TestRunner.this.threadException = ex;
threadException = e;
} }
}); });
runThread.join(); runThread.join();
if(threadException != null) { if (this.threadException != null) {
Throwable t = threadException; TestFailedException ex = new TestFailedException(this.threadException);
threadException = null; this.threadException = null;
throw new TestFailedException(t); throw ex;
} }
} }
@ -151,29 +151,21 @@ public class TestRunner {
.getContextClassLoader(); .getContextClassLoader();
Class<?> delegateClass = contextClassLoader Class<?> delegateClass = contextClassLoader
.loadClass(DelegateTestRunner.class.getName()); .loadClass(DelegateTestRunner.class.getName());
Class resultClass = contextClassLoader.loadClass("org.junit.runner.Result"); Class<?> resultClass = contextClassLoader
Method runMethod = delegateClass.getMethod("run", Class[].class, resultClass); .loadClass("org.junit.runner.Result");
Method runMethod = delegateClass.getMethod("run", Class[].class,
resultClass);
Object result = resultClass.newInstance(); Object result = resultClass.newInstance();
runMethod.invoke(null, this.testClasses, result); runMethod.invoke(null, this.testClasses, result);
Boolean wasSuccessful = (Boolean)resultClass.getMethod("wasSuccessful").invoke(result); boolean wasSuccessful = (Boolean) resultClass.getMethod(
"wasSuccessful").invoke(result);
if (!wasSuccessful) { if (!wasSuccessful) {
try {
throw new RuntimeException("Tests Failed."); throw new RuntimeException("Tests Failed.");
} catch (Throwable throwable) {
throw new RuntimeException(throwable);
} }
} }
} }
} catch (ClassNotFoundException e) { catch (Exception ex) {
throw new RuntimeException("Exception occurred running tests: " + e.getMessage(), e); ReflectionUtils.rethrowRuntimeException(ex);
} catch (NoSuchMethodException e) {
throw new RuntimeException("Exception occurred running tests: " + e.getMessage(), e);
} catch (InstantiationException e) {
throw new RuntimeException("Exception occurred running tests: " + e.getMessage(), e);
} catch (IllegalAccessException e) {
throw new RuntimeException("Exception occurred running tests: " + e.getMessage(), e);
} catch (InvocationTargetException e) {
throw new RuntimeException("Exception occurred running tests: " + e.getMessage(), e);
} }
} }
} }

@ -81,7 +81,7 @@ public class CliTester implements TestRule {
try { try {
this.commands.add(future.get(this.timeout, TimeUnit.MILLISECONDS)); this.commands.add(future.get(this.timeout, TimeUnit.MILLISECONDS));
return getOutput(); return getOutput();
} catch (Exception e) { } catch (Exception ex) {
return getOutput(); return getOutput();
} }
} }

@ -26,7 +26,8 @@ package org.springframework.boot.context.embedded;
public class Ssl { public class Ssl {
/** /**
* Whether client authentication is wanted ("want") or needed ("need"). Requires a trust store. * Whether client authentication is wanted ("want") or needed ("need"). Requires a
* trust store.
*/ */
private ClientAuth clientAuth; private ClientAuth clientAuth;

Loading…
Cancel
Save