http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/usage/test-support/src/main/java/org/apache/brooklyn/test/TestUtils.java ---------------------------------------------------------------------- diff --git a/usage/test-support/src/main/java/org/apache/brooklyn/test/TestUtils.java b/usage/test-support/src/main/java/org/apache/brooklyn/test/TestUtils.java new file mode 100644 index 0000000..d2bf55e --- /dev/null +++ b/usage/test-support/src/main/java/org/apache/brooklyn/test/TestUtils.java @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.brooklyn.test; + +import static org.testng.Assert.fail; + +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.Set; +import java.util.concurrent.ExecutionException; + +import org.codehaus.groovy.runtime.InvokerInvocationException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Helper functions for tests of Tomcat, JBoss and others. + * + * @deprecated Since 0.8. Methods moving to {@link Asserts}. + */ +@Deprecated +public class TestUtils { + private static final Logger log = LoggerFactory.getLogger(TestUtils.class); + + private TestUtils() { } + + /** @deprecated since 0.8; use Asserts.BooleanWithMessage */ + public static class BooleanWithMessage { + boolean value; String message; + public BooleanWithMessage(boolean value, String message) { + this.value = value; this.message = message; + } + public boolean asBoolean() { + return value; + } + public String toString() { + return message; + } + } + + /** @deprecated since 0.8; use Exceptions.getFirstInteresting */ + public static Throwable unwrapThrowable(Throwable t) { + if (t.getCause() == null) { + return t; + } else if (t instanceof ExecutionException) { + return unwrapThrowable(t.getCause()); + } else if (t instanceof InvokerInvocationException) { + return unwrapThrowable(t.getCause()); + } else { + return t; + } + } + + /** @deprecated since 0.8; use Asserts.assertEqualsIgnoringOrder */ + public static void assertSetsEqual(Collection c1, Collection c2) { + Set s = new LinkedHashSet(); + s.addAll(c1); s.removeAll(c2); + if (!s.isEmpty()) fail("First argument contains additional contents: "+s); + s.clear(); s.addAll(c2); s.removeAll(c1); + if (!s.isEmpty()) fail("Second argument contains additional contents: "+s); + } + +}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/utils/common/src/main/java/org/apache/brooklyn/test/Asserts.java ---------------------------------------------------------------------- diff --git a/utils/common/src/main/java/org/apache/brooklyn/test/Asserts.java b/utils/common/src/main/java/org/apache/brooklyn/test/Asserts.java index 20fc98d..0bf6936 100644 --- a/utils/common/src/main/java/org/apache/brooklyn/test/Asserts.java +++ b/utils/common/src/main/java/org/apache/brooklyn/test/Asserts.java @@ -32,7 +32,6 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicReference; -import org.apache.brooklyn.test.Asserts; import org.apache.brooklyn.util.collections.MutableSet; import org.apache.brooklyn.util.exceptions.Exceptions; import org.apache.brooklyn.util.time.Duration; @@ -60,8 +59,8 @@ import com.google.common.collect.Sets; public class Asserts { /** - * The default timeout for assertions. Alter in individual tests by giving a - * "timeout" entry in method flags. + * The default timeout for assertions - 30s. + * Alter in individual tests by giving a "timeout" entry in method flags. */ public static final Duration DEFAULT_TIMEOUT = Duration.THIRTY_SECONDS; @@ -178,20 +177,21 @@ public class Asserts { /** - * Asserts given runnable succeeds in default duration. - * @see #DEFAULT_TIMEOUT + * @see #succeedsContinually(Map, Callable) */ public static void succeedsEventually(Runnable r) { succeedsEventually(ImmutableMap.<String,Object>of(), r); } + /** + * @see #succeedsContinually(Map, Callable) + */ public static void succeedsEventually(Map<String,?> flags, Runnable r) { succeedsEventually(flags, toCallable(r)); } /** - * Asserts given callable succeeds (runs without failure) in default duration. - * @see #DEFAULT_TIMEOUT + * @see #succeedsContinually(Map, Callable) */ public static <T> T succeedsEventually(Callable<T> c) { return succeedsEventually(ImmutableMap.<String,Object>of(), c); @@ -220,7 +220,7 @@ public class Asserts { * <ul> * <li>abortOnError (boolean, default true) * <li>abortOnException - (boolean, default false) - * <li>timeout - (a Duration or an integer in millis, defaults to 30*SECONDS) + * <li>timeout - (a Duration or an integer in millis, defaults to {@link Asserts#DEFAULT_TIMEOUT}) * <li>period - (a Duration or an integer in millis, for fixed retry time; if not set, defaults to exponentially increasing from 1 to 500ms) * <li>minPeriod - (a Duration or an integer in millis; only used if period not explicitly set; the minimum period when exponentially increasing; defaults to 1ms) * <li>maxPeriod - (a Duration or an integer in millis; only used if period not explicitly set; the maximum period when exponentially increasing; defaults to 500ms) @@ -357,6 +357,7 @@ public class Asserts { }); } + @SafeVarargs public static void assertFailsWith(Runnable c, final Class<? extends Throwable> validException, final Class<? extends Throwable> ...otherValidExceptions) { final List<Class<?>> validExceptions = ImmutableList.<Class<?>>builder() .add(validException) http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/utils/common/src/main/java/org/apache/brooklyn/util/internal/BrooklynSystemProperties.java ---------------------------------------------------------------------- diff --git a/utils/common/src/main/java/org/apache/brooklyn/util/internal/BrooklynSystemProperties.java b/utils/common/src/main/java/org/apache/brooklyn/util/internal/BrooklynSystemProperties.java index 06b5a3b..3d0048b 100644 --- a/utils/common/src/main/java/org/apache/brooklyn/util/internal/BrooklynSystemProperties.java +++ b/utils/common/src/main/java/org/apache/brooklyn/util/internal/BrooklynSystemProperties.java @@ -33,7 +33,8 @@ public class BrooklynSystemProperties { public static IntegerSystemProperty JSCH_EXEC_DELAY = new IntegerSystemProperty("brooklyn.jsch.exec.delay"); /** allows specifying a particular geo lookup service (to lookup IP addresses), as the class FQN to use */ - // -Dbrooklyn.location.geo.HostGeoLookup=brooklyn.location.geo.UtraceHostGeoLookup - public static StringSystemProperty HOST_GEO_LOOKUP_IMPL = new StringSystemProperty("brooklyn.location.geo.HostGeoLookup"); + // -Dorg.apache.brooklyn.core.brooklyn.location.geo.HostGeoLookup=org.apache.brooklyn.core.brooklyn.location.geo.UtraceHostGeoLookup + public static StringSystemProperty HOST_GEO_LOOKUP_IMPL_LEGACY = new StringSystemProperty("brooklyn.location.geo.HostGeoLookup"); + public static StringSystemProperty HOST_GEO_LOOKUP_IMPL = new StringSystemProperty("org.apache.brooklyn.core.location.geo.HostGeoLookup"); } http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/utils/common/src/main/java/org/apache/brooklyn/util/javalang/StackTraceSimplifier.java ---------------------------------------------------------------------- diff --git a/utils/common/src/main/java/org/apache/brooklyn/util/javalang/StackTraceSimplifier.java b/utils/common/src/main/java/org/apache/brooklyn/util/javalang/StackTraceSimplifier.java index cdfbe1e..0468d33 100644 --- a/utils/common/src/main/java/org/apache/brooklyn/util/javalang/StackTraceSimplifier.java +++ b/utils/common/src/main/java/org/apache/brooklyn/util/javalang/StackTraceSimplifier.java @@ -41,10 +41,10 @@ public class StackTraceSimplifier { private static final Logger log = LoggerFactory.getLogger(StackTraceSimplifier.class); /** comma-separated prefixes (not regexes) */ - public static final String DEFAULT_BLACKLIST_SYSTEM_PROPERTY_NAME = "brooklyn.util.javalang.StackTraceSimplifier.blacklist"; + public static final String DEFAULT_BLACKLIST_SYSTEM_PROPERTY_NAME = "org.apache.brooklyn.util.javalang.StackTraceSimplifier.blacklist"; - /** @deprecated since 0.6.0 use {@link #DEFAULT_BLACKLIST_SYSTEM_PROPERTY_NAME} */ @Deprecated - public static final String LEGACY_DEFAULT_BLACKLIST_SYSTEM_PROPERTY_NAME = "groovy.sanitized.stacktraces"; + /** @deprecated since 0.8.0 use {@link #DEFAULT_BLACKLIST_SYSTEM_PROPERTY_NAME} */ @Deprecated + public static final String LEGACY_DEFAULT_BLACKLIST_SYSTEM_PROPERTY_NAME = "brooklyn.util.javalang.StackTraceSimplifier.blacklist"; private static final Collection<String> DEFAULT_BLACKLIST;
