mirror of https://github.com/apache/jclouds.git
Making test assertions use the system line separator rather than always '\n'
This commit is contained in:
parent
992def18b0
commit
5914436ae0
|
@ -20,6 +20,7 @@ package org.jclouds.concurrent.config;
|
||||||
|
|
||||||
import static com.google.common.base.Throwables.getStackTraceAsString;
|
import static com.google.common.base.Throwables.getStackTraceAsString;
|
||||||
import static com.google.inject.name.Names.named;
|
import static com.google.inject.name.Names.named;
|
||||||
|
import static java.lang.String.format;
|
||||||
import static org.easymock.EasyMock.createMock;
|
import static org.easymock.EasyMock.createMock;
|
||||||
import static org.easymock.EasyMock.expect;
|
import static org.easymock.EasyMock.expect;
|
||||||
import static org.easymock.EasyMock.replay;
|
import static org.easymock.EasyMock.replay;
|
||||||
|
@ -49,6 +50,7 @@ import com.google.inject.Key;
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public class ExecutorServiceModuleTest {
|
public class ExecutorServiceModuleTest {
|
||||||
|
private static final String LINE_SEPARATOR = System.getProperty("line.separator");
|
||||||
|
|
||||||
private Injector injector;
|
private Injector injector;
|
||||||
|
|
||||||
|
@ -107,7 +109,7 @@ public class ExecutorServiceModuleTest {
|
||||||
try {
|
try {
|
||||||
// this is sensitive to formatting as we are looking for the stack traces to match. if you wrap the below
|
// this is sensitive to formatting as we are looking for the stack traces to match. if you wrap the below
|
||||||
// line again, you'll need to change incrementInitialElement to 3 line numbers instead of 2.
|
// line again, you'll need to change incrementInitialElement to 3 line numbers instead of 2.
|
||||||
submission = getStackTraceAsString(incrementInitialElement(new RuntimeException(), 2)).replaceFirst(".*\n",
|
submission = getStackTraceAsString(incrementInitialElement(new RuntimeException(), 2)).replaceFirst(format(".*%s", LINE_SEPARATOR),
|
||||||
"");
|
"");
|
||||||
exec.submit(runnableThrowsRTE()).get();
|
exec.submit(runnableThrowsRTE()).get();
|
||||||
} catch (ExecutionException e) {
|
} catch (ExecutionException e) {
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
package org.jclouds.concurrent.config;
|
package org.jclouds.concurrent.config;
|
||||||
import static com.google.common.base.Throwables.getStackTraceAsString;
|
import static com.google.common.base.Throwables.getStackTraceAsString;
|
||||||
import static com.google.inject.name.Names.named;
|
import static com.google.inject.name.Names.named;
|
||||||
|
import static java.lang.String.format;
|
||||||
import static org.easymock.EasyMock.createMock;
|
import static org.easymock.EasyMock.createMock;
|
||||||
import static org.easymock.EasyMock.expect;
|
import static org.easymock.EasyMock.expect;
|
||||||
import static org.easymock.EasyMock.replay;
|
import static org.easymock.EasyMock.replay;
|
||||||
|
@ -50,6 +51,7 @@ import com.google.inject.Key;
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public class ScheduledExecutorServiceModuleTest {
|
public class ScheduledExecutorServiceModuleTest {
|
||||||
|
private static final String LINE_SEPARATOR = System.getProperty("line.separator");
|
||||||
|
|
||||||
private Injector injector;
|
private Injector injector;
|
||||||
|
|
||||||
|
@ -99,7 +101,7 @@ public class ScheduledExecutorServiceModuleTest {
|
||||||
// this is sensitive to formatting as we are looking for the stack traces to match. if you wrap the below
|
// this is sensitive to formatting as we are looking for the stack traces to match. if you wrap the below
|
||||||
// line again, you'll need to change incrementInitialElement to 3 line numbers instead of 2.
|
// line again, you'll need to change incrementInitialElement to 3 line numbers instead of 2.
|
||||||
submission = getStackTraceAsString(incrementInitialElement(new RuntimeException(), 2))
|
submission = getStackTraceAsString(incrementInitialElement(new RuntimeException(), 2))
|
||||||
.replaceFirst(".*\n", "");
|
.replaceFirst(format(".*%s", LINE_SEPARATOR), "");
|
||||||
sched.submit(runnableThrowsRTE()).get();
|
sched.submit(runnableThrowsRTE()).get();
|
||||||
} catch (ExecutionException e) {
|
} catch (ExecutionException e) {
|
||||||
assertTraceHasSubmission(getStackTraceAsString(e), submission);
|
assertTraceHasSubmission(getStackTraceAsString(e), submission);
|
||||||
|
@ -116,7 +118,7 @@ public class ScheduledExecutorServiceModuleTest {
|
||||||
// this is sensitive to formatting as we are looking for the stack traces to match. if you wrap the below
|
// this is sensitive to formatting as we are looking for the stack traces to match. if you wrap the below
|
||||||
// line again, you'll need to change incrementInitialElement to 3 line numbers instead of 2.
|
// line again, you'll need to change incrementInitialElement to 3 line numbers instead of 2.
|
||||||
submission = getStackTraceAsString(incrementInitialElement(new RuntimeException(), 2))
|
submission = getStackTraceAsString(incrementInitialElement(new RuntimeException(), 2))
|
||||||
.replaceFirst(".*\n", "");
|
.replaceFirst(format(".*%s", LINE_SEPARATOR), "");
|
||||||
sched.scheduleWithFixedDelay(runnableThrowsRTE(), 0, 1, TimeUnit.MICROSECONDS).get();
|
sched.scheduleWithFixedDelay(runnableThrowsRTE(), 0, 1, TimeUnit.MICROSECONDS).get();
|
||||||
} catch (ExecutionException e) {
|
} catch (ExecutionException e) {
|
||||||
assertTraceHasSubmission(getStackTraceAsString(e), submission);
|
assertTraceHasSubmission(getStackTraceAsString(e), submission);
|
||||||
|
|
Loading…
Reference in New Issue