-
-
Notifications
You must be signed in to change notification settings - Fork 699
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The use of timestamps to replace SNAPSHOT is an old oddity of
bnd-maven-plugin. So we use `-snapshot: SNAPSHOT` to correct this. We also use `-noextraheaders: true` to remove headers which can break reproducible builds. This elides `Bnd-LastModified` so we can remove it from `-removeheaders`. See https://github.com/bndtools/bnd/blob/master/maven/bnd-maven-plugin/README.md#reproducible-builds Signed-off-by: BJ Hargrave <bj@bjhargrave.com> Handle soft proxies for custom assert classes in OSGi bundles (#1979) When using a composite class loader for defining soft proxies when the assert class is from a different class loader than the AssertJ classes, we now use the composite class loader as the ClassLoadingStrategy for ByteBuddy. This is necessary for Java 9+ to avoid the ClassLoadingStrategy.UsingLookup default strategy used by AssertJ for Java 9+. That strategy always defines the proxy classes in the class loader defining the assert class ignoring the specified class loader. This change is also beneficial for Java 8 as it avoids the need to reflectively call the composite class loader to define the proxy classes. We refactor the CompositeClassLoader into the ClassLoadingStrategyFactory class so that we can centralize the logic for class loader and class loading strategy determination. Assumptions is updated to use these changes which prepares it for a future where it could support defining custom assumptions. Finally, we update the class loader used for the ByteBuddy class caches to use the class loader of the assert class rather than AssertJ's class loader as the key. This is important in the OSGi case where multiple bundles could define custom assertions with the same class name and we must allow for unique proxy class generation for each bundle. Fixes #1979 Signed-off-by: BJ Hargrave <bj@bjhargrave.com>
- Loading branch information
1 parent
c9807b9
commit 7fb09d9
Showing
6 changed files
with
244 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Licensed 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. | ||
* | ||
* Copyright 2012-2020 the original author or authors. | ||
*/ | ||
package org.assertj.core.osgi; | ||
|
||
import static java.util.Arrays.asList; | ||
import static org.assertj.core.api.Assertions.assertThatNoException; | ||
import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
import static org.assertj.core.api.Assumptions.assumeThat; | ||
import static org.assertj.core.presentation.UnicodeRepresentation.UNICODE_REPRESENTATION; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.opentest4j.TestAbortedException; | ||
|
||
class AssumptionsTest { | ||
|
||
@Test | ||
void should_ignore_test_when_one_of_the_assumption_fails() { | ||
assumeThat("foo").isNotEmpty(); | ||
assertThatThrownBy(() -> assumeThat("bar").isEmpty()).isInstanceOf(TestAbortedException.class); | ||
} | ||
|
||
@Test | ||
void should_run_test_when_all_assumptions_are_met() { | ||
assertThatNoException().isThrownBy(() -> { | ||
assumeThat("foo").isNotNull() | ||
.isNotEmpty() | ||
.isEqualTo("foo"); | ||
assumeThat("bar").contains("ar") | ||
.isNotBlank(); | ||
assumeThat(asList("John", "Doe", "Jane", "Doe")).as("test description") | ||
.withFailMessage("error message") | ||
.withRepresentation(UNICODE_REPRESENTATION) | ||
.usingElementComparator(String.CASE_INSENSITIVE_ORDER) | ||
.filteredOn(string -> string.length() == 4) | ||
.containsExactly("JOHN", "JANE"); | ||
}); | ||
} | ||
|
||
} |
Oops, something went wrong.