Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@
<version>${guava.version}</version>
</dependency>

<!-- NOTE: Keeping Groovy DM for compatibility -->

<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright (c) 2022-present Sonatype, Inc. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
* and you may not use this file except in compliance with the Apache License Version 2.0.
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the Apache License Version 2.0 is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
*/
package org.sonatype.goodies.basicli.common;

import org.junit.jupiter.api.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.nullValue;

/**
* {@link MoreStrings} tests.
*/
public class MoreStringsTest
{
@Test
void blankToNull() {
assertThat(MoreStrings.blankToNull(null), nullValue());
assertThat(MoreStrings.blankToNull(""), nullValue());
assertThat(MoreStrings.blankToNull(" "), nullValue());
assertThat(MoreStrings.blankToNull("foo"), not(nullValue()));
assertThat(MoreStrings.blankToNull(" bar "), not(nullValue()));

// ensure that result is the same as given when its non-null or blank
String text = " bar ";
assertThat(MoreStrings.blankToNull(text), is(text));
}

@Test
void lower() {
String value = "FooBar";
assertThat(MoreStrings.lower(value), is("foobar"));
}

@Test
void upper() {
String value = "FooBar";
assertThat(MoreStrings.upper(value), is("FOOBAR"));
}

@Test
void dquote_string_value() {
assertThat(MoreStrings.dquote("foo"), is("\"foo\""));
}

@Test
void dquote_null_value() {
assertThat(MoreStrings.dquote(null), nullValue());
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* Copyright (c) 2022-present Sonatype, Inc. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
* and you may not use this file except in compliance with the Apache License Version 2.0.
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the Apache License Version 2.0 is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
*/
package org.sonatype.goodies.basicli.common;

import org.junit.jupiter.api.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.arrayWithSize;
import static org.hamcrest.Matchers.is;

// copied and adjusted from: https://raw.githubusercontent.com/sonatype/goodies/master/common/src/test/java/org/sonatype/goodies/common/Throwables2Test.java

/**
* {@link ThrowableHelper} tests.
*/
public class ThrowableHelperTest
{
private static void println(Object value) {
System.out.println(value);
}

@Test
public void explain_single_throwable() {
String msg = ThrowableHelper.explain(new RuntimeException("foo"));
println(msg);
assertThat(msg, is("java.lang.RuntimeException: foo"));
}

@Test
public void explain_nested_throwable() {
String msg = ThrowableHelper.explain(
new RuntimeException("foo",
new Exception("bar")
)
);
println(msg);
assertThat(msg, is("java.lang.RuntimeException: foo, caused by: java.lang.Exception: bar"));
}

@Test
public void explain_nested_3x_throwable() {
String msg = ThrowableHelper.explain(
new RuntimeException("foo",
new Exception(
new Exception("bar")
)
)
);
println(msg);
assertThat(msg, is("java.lang.RuntimeException: foo, caused by: java.lang.Exception, caused by: java.lang.Exception: bar"));
}

@Test
public void explain_nested_4x_throwable() {
String msg = ThrowableHelper.explain(
new RuntimeException("foo",
new Exception("bar",
new Exception("baz")
)
)
);
println(msg);
assertThat(msg, is("java.lang.RuntimeException: foo, caused by: java.lang.Exception: bar, caused by: java.lang.Exception: baz"));
}

@Test
public void composite_adds_suppressed_exceptions() {
Throwable foo = new Exception("foo");
Throwable bar = new Exception("bar");
try {
throw ThrowableHelper.composite(new Exception("test"), foo, bar);
}
catch (Exception e) {
assertThat(e.getSuppressed(), arrayWithSize(2));
assertThat(e.getSuppressed()[0], is(foo));
assertThat(e.getSuppressed()[1], is(bar));
}
}

@Test
public void explain_composite() {
try {
ThrowableHelper.composite(
new Exception("test"),
new Exception("foo"),
new Exception("bar")
);
}
catch (Exception e) {
String msg = ThrowableHelper.explain(e);
println(msg);
assertThat(msg, is("java.lang.Exception: test, suppressed: java.lang.Exception: foo, suppressed: java.lang.Exception: bar"));
}
}
}
21 changes: 0 additions & 21 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,27 +115,6 @@
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>3.7.0</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
<version>3.0.8-01</version>
</dependency>
</dependencies>
<configuration>
<!-- see: https://github.com/groovy/groovy-eclipse/wiki/Groovy-Eclipse-Maven-plugin -->
<compilerId>groovy-eclipse-compiler</compilerId>
</configuration>
</plugin>

<plugin>
<groupId>com.sonatype.clm</groupId>
<artifactId>clm-maven-plugin</artifactId>
Expand Down
2 changes: 2 additions & 0 deletions testbase/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@
<artifactId>logback-classic</artifactId>
</dependency>

<!-- NOTE: Keeping Groovy test-dependency for compatibility -->

<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
Expand Down