From fdec16b5d68f127eb8d99747872100834cc0790d Mon Sep 17 00:00:00 2001 From: Alex Herbert Date: Tue, 25 Jun 2024 14:55:53 +0100 Subject: [PATCH] RNG-186: Add integration test module This tests the sampling and simple modules using an OSGi container. --- .github/workflows/maven.yml | 4 +- commons-rng-integration/LICENSE | 275 ++++++++++++++++++ commons-rng-integration/NOTICE | 5 + commons-rng-integration/README.md | 89 ++++++ commons-rng-integration/pom.xml | 174 +++++++++++ .../src/site/resources/style/module.css | 19 ++ commons-rng-integration/src/site/site.xml | 32 ++ .../src/site/xdoc/index.xml | 44 +++ .../commons/rng/integration/SamplingTest.java | 72 +++++ .../commons/rng/integration/SimpleTest.java | 55 ++++ .../commons/rng/integration/tests.bndrun | 40 +++ commons-rng-sampling/pom.xml | 7 +- pom.xml | 7 + 13 files changed, 821 insertions(+), 2 deletions(-) create mode 100644 commons-rng-integration/LICENSE create mode 100644 commons-rng-integration/NOTICE create mode 100644 commons-rng-integration/README.md create mode 100644 commons-rng-integration/pom.xml create mode 100644 commons-rng-integration/src/site/resources/style/module.css create mode 100644 commons-rng-integration/src/site/site.xml create mode 100644 commons-rng-integration/src/site/xdoc/index.xml create mode 100644 commons-rng-integration/src/test/java/org/apache/commons/rng/integration/SamplingTest.java create mode 100644 commons-rng-integration/src/test/java/org/apache/commons/rng/integration/SimpleTest.java create mode 100644 commons-rng-integration/src/test/resources/org/apache/commons/rng/integration/tests.bndrun diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index a1af0f42d..de0e227a6 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -46,8 +46,10 @@ jobs: # Examples require Java 11+. # Building javadoc errors when run with the package phase with an error about # the module path and the unamed module (despite using an automatic module name). - # Here we run the build and javadoc generation separately (which requires install of sources) + # Here we run the build and javadoc generation separately (which requires install of sources). + # Run the OSGi integration test for the installed modules. if: matrix.java > 8 run: | mvn --show-version --batch-mode --no-transfer-progress -P commons-rng-examples clean install -Dmaven.javadoc.skip mvn --show-version --batch-mode --no-transfer-progress -P commons-rng-examples javadoc:javadoc + mvn --show-version --batch-mode --no-transfer-progress -P commons-rng-integration -pl commons-rng-integration clean package integration-test diff --git a/commons-rng-integration/LICENSE b/commons-rng-integration/LICENSE new file mode 100644 index 000000000..facfda6ad --- /dev/null +++ b/commons-rng-integration/LICENSE @@ -0,0 +1,275 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. + +================================================================================ + +Class "org.apache.commons.rng.core.source64.MersenneTwister64" contains +Java code partly ported from the reference implementation in C. +That source file contained the following notice: + + Copyright (C) 2004, Makoto Matsumoto and Takuji Nishimura, + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. The names of its contributors may not be used to endorse or promote + products derived from this software without specific prior written + permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +================================================================================ + +Class "org.apache.commons.rng.core.source32.MersenneTwister" contains +Java code partly ported from the reference implementation in C. +That source file contained the following notice: + + Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. The names of its contributors may not be used to endorse or promote + products derived from this software without specific prior written + permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +================================================================================ diff --git a/commons-rng-integration/NOTICE b/commons-rng-integration/NOTICE new file mode 100644 index 000000000..9a061b46d --- /dev/null +++ b/commons-rng-integration/NOTICE @@ -0,0 +1,5 @@ +Apache Commons RNG +Copyright 2016-2022 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). diff --git a/commons-rng-integration/README.md b/commons-rng-integration/README.md new file mode 100644 index 000000000..5a04fb0b3 --- /dev/null +++ b/commons-rng-integration/README.md @@ -0,0 +1,89 @@ + + +Apache Commons RNG Integration Tests +=================== + +Integration tests to validate an application referencing multiple Apache Commons RNG artifacts + +Documentation +------------- + +More information can be found on the [Apache Commons RNG homepage](https://commons.apache.org/proper/commons-rng). +Questions related to the usage of Apache Commons RNG Sampling should be posted to the [user mailing list][ml]. + +Where can I get the latest release? +----------------------------------- +You can download source and binaries from our [download page](https://commons.apache.org/proper/commons-rng/download_rng.cgi). + +Alternatively, you can pull it from the central Maven repositories and use +the Bill of Materials (BOM) for dependency management: + +```xml + + + + org.apache.commons + commons-rng-bom + 1.5 + pom + import + + + +``` + + +Contributing +------------ + +We accept Pull Requests via GitHub. The [developer mailing list][ml] is the main channel of communication for contributors. +There are some guidelines which will make applying PRs easier for us: ++ No tabs! Please use spaces for indentation. ++ Respect the code style. ++ Create minimal diffs - disable on save actions like reformat source code or organize imports. If you feel the source code should be reformatted create a separate PR for this change. ++ Provide JUnit tests for your changes and make sure your changes don't break any existing tests by running ```mvn```. + +If you plan to contribute on a regular basis, please consider filing a [contributor license agreement](https://www.apache.org/licenses/#clas). +You can learn more about contributing via GitHub in our [contribution guidelines](CONTRIBUTING.md). + +License +------- +This code is under the [Apache Licence v2](https://www.apache.org/licenses/LICENSE-2.0). + +See the `NOTICE` file for required notices and attributions. + +Donations +--------- +You like Apache Commons RNG? Then [donate back to the ASF](https://www.apache.org/foundation/contributing.html) to support the development. + +Additional Resources +-------------------- + ++ [Apache Commons Homepage](https://commons.apache.org/) ++ [Apache Issue Tracker (JIRA)](https://issues.apache.org/jira/browse/RNG) ++ [Apache Commons Twitter Account](https://twitter.com/ApacheCommons) ++ `#apache-commons` IRC channel on `irc.freenode.org` + +[ml]:https://commons.apache.org/mail-lists.html diff --git a/commons-rng-integration/pom.xml b/commons-rng-integration/pom.xml new file mode 100644 index 000000000..66a791317 --- /dev/null +++ b/commons-rng-integration/pom.xml @@ -0,0 +1,174 @@ + + + + 4.0.0 + + + org.apache.commons + commons-rng-parent + 1.6-SNAPSHOT + + + commons-rng-integration + 1.6-SNAPSHOT + Apache Commons RNG Integration Tests + jar + + Integration tests to validate an application referencing multiple Apache Commons RNG artifacts. + + + + ${basedir}/.. + + ${rng.build.outputTimestamp} + + + 11 + 11 + 11 + true + 11 + true + + true + + + 6.4.0 + 7.0.5 + + + + + + + org.apache.felix + org.apache.felix.framework + ${felix.version} + provided + + + + org.apache.commons + commons-rng-sampling + 1.6-SNAPSHOT + test + + + + org.apache.commons + commons-rng-simple + 1.6-SNAPSHOT + test + + + + + + + + org.spdx + spdx-maven-plugin + + + build-sbom-spdx + + createSPDX + + None + + + + + + biz.aQute.bnd + bnd-maven-plugin + ${bnd.version} + true + + + jar + + test-jar + + + + + + + + + + biz.aQute.bnd + bnd-resolver-maven-plugin + ${bnd.version} + + + src/test/resources/org/apache/commons/rng/integration/tests.bndrun + + false + true + false + + compile + runtime + test + provided + + + + + biz.aQute.bnd + bnd-testing-maven-plugin + ${bnd.version} + + + + testing + + testing + + + + + src/test/resources/org/apache/commons/rng/integration/tests.bndrun + + + + ${project.build.directory}/${project.build.finalName}-tests.jar + + false + true + false + + compile + runtime + test + provided + + + + + + + + + diff --git a/commons-rng-integration/src/site/resources/style/module.css b/commons-rng-integration/src/site/resources/style/module.css new file mode 100644 index 000000000..e27318bff --- /dev/null +++ b/commons-rng-integration/src/site/resources/style/module.css @@ -0,0 +1,19 @@ +/* + * 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. + */ + +/* Match colour used for class declaration in prettyprint */ +.prettyprint, .lang-xml, .tag { color: teal; } diff --git a/commons-rng-integration/src/site/site.xml b/commons-rng-integration/src/site/site.xml new file mode 100644 index 000000000..14cef712e --- /dev/null +++ b/commons-rng-integration/src/site/site.xml @@ -0,0 +1,32 @@ + + + + + Apache Commons RNG + + https://commons.apache.org/proper/commons-rng/images/commons_rng.small.png + https://commons.apache.org/proper/commons-rng/index.html + + + + + + + + + diff --git a/commons-rng-integration/src/site/xdoc/index.xml b/commons-rng-integration/src/site/xdoc/index.xml new file mode 100644 index 000000000..8ab9088bc --- /dev/null +++ b/commons-rng-integration/src/site/xdoc/index.xml @@ -0,0 +1,44 @@ + + + + + + + + Commons RNG Integration Tests + + + + +
+

+ Commons RNG provides implementations of pseudo-random numbers generators that are + faster; of higher quality; and/or of a longer period than + java.util.Random and java.util.SplittableRandom. + Utilities are provided for sampling from distributions, collections and geometric shapes. +

+ +

+ The integrations tests validate the RNG modules function within an OSGi environment. +

+ +
+ + + +
diff --git a/commons-rng-integration/src/test/java/org/apache/commons/rng/integration/SamplingTest.java b/commons-rng-integration/src/test/java/org/apache/commons/rng/integration/SamplingTest.java new file mode 100644 index 000000000..733d48ac3 --- /dev/null +++ b/commons-rng-integration/src/test/java/org/apache/commons/rng/integration/SamplingTest.java @@ -0,0 +1,72 @@ +/* + * 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.commons.rng.integration; + +import java.util.BitSet; +import org.apache.commons.rng.UniformRandomProvider; +import org.apache.commons.rng.sampling.PermutationSampler; +import org.apache.commons.rng.sampling.distribution.DiscreteUniformSampler; +import org.apache.commons.rng.sampling.shape.BoxSampler; +import org.apache.commons.rng.simple.RandomSource; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +/** + * Tests for {@code o.a.c.rng.sampling}. + * Uses classes from all packages. + * + *

Note: Class is public for the OSGi bundle testing. + */ +public class SamplingTest { + @Test + void testSampling() { + final UniformRandomProvider rng = RandomSource.KISS.create(); + final int n = 10; + final int k = 3; + final int[] s = new PermutationSampler(rng, n, k).sample(); + + Assertions.assertEquals(k, s.length); + BitSet set = new BitSet(n); + for (final int x : s) { + Assertions.assertTrue(0 <= x && x < n); + set.set(x); + } + Assertions.assertEquals(k, set.cardinality()); + } + + @Test + void testSamplingDistribution() { + final UniformRandomProvider rng = RandomSource.KISS.create(); + final int lower = 3; + final int upper = 5; + final int s = DiscreteUniformSampler.of(rng, lower, upper).sample(); + Assertions.assertTrue(lower <= s && s <= upper); + } + + @Test + void testSamplingShape() { + final UniformRandomProvider rng = RandomSource.KISS.create(); + final double[] a = {3, 4, 5}; + final double[] b = {6, 7, 8}; + final double[] s = BoxSampler.of(rng, a, b).sample(); + + Assertions.assertEquals(a.length, s.length); + for (int i = 0; i < a.length; i++) { + Assertions.assertTrue(a[i] <= s[i] && s[i] <= b[i]); + } + } +} diff --git a/commons-rng-integration/src/test/java/org/apache/commons/rng/integration/SimpleTest.java b/commons-rng-integration/src/test/java/org/apache/commons/rng/integration/SimpleTest.java new file mode 100644 index 000000000..343742422 --- /dev/null +++ b/commons-rng-integration/src/test/java/org/apache/commons/rng/integration/SimpleTest.java @@ -0,0 +1,55 @@ +/* + * 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.commons.rng.integration; + +import org.apache.commons.rng.RandomProviderState; +import org.apache.commons.rng.RestorableUniformRandomProvider; +import org.apache.commons.rng.UniformRandomProvider; +import org.apache.commons.rng.simple.RandomSource; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +/** + * Tests for {@code o.a.c.rng.simple}. + * Uses classes from all packages. + * + *

Note: Class is public for the OSGi bundle testing. + */ +public class SimpleTest { + @Test + void testCreateSource32() { + // Tests: core.source32 + final UniformRandomProvider rng = RandomSource.KISS.create(); + final int origin = 3; + final int bound = 7; + // Tests: o.a.c.rng (client API) + final int s = rng.nextInt(origin, bound); + Assertions.assertTrue(origin <= s && s < bound); + } + + @Test + void testCreateSource64() { + // Tests: core.source64 + final RestorableUniformRandomProvider rng = RandomSource.SPLIT_MIX_64.create(); + // Tests: core; core.util + RandomProviderState state = rng.saveState(); + final double[] s1 = rng.doubles(10).toArray(); + rng.restoreState(state); + final double[] s2 = rng.doubles(10).toArray(); + Assertions.assertArrayEquals(s1, s2); + } +} diff --git a/commons-rng-integration/src/test/resources/org/apache/commons/rng/integration/tests.bndrun b/commons-rng-integration/src/test/resources/org/apache/commons/rng/integration/tests.bndrun new file mode 100644 index 000000000..e08af5bde --- /dev/null +++ b/commons-rng-integration/src/test/resources/org/apache/commons/rng/integration/tests.bndrun @@ -0,0 +1,40 @@ +# 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. + +Test-Cases: ${classes;CONCRETE;PUBLIC;NAMED;*Test*} + +-tester: biz.aQute.tester.junit-platform + +# Must be supplied on the run path using maven scope: provided +-runfw: org.apache.felix.framework + +-runrequires: \ + bnd.identity;id='${project.artifactId}-tests',\ + bnd.identity;id='junit-jupiter-engine',\ + bnd.identity;id='junit-platform-launcher' + +# Generated using: mvn package bnd-resolver:resolve +-runbundles: \ + junit-jupiter-api;version='[5.10.2,5.10.3)',\ + junit-jupiter-engine;version='[5.10.2,5.10.3)',\ + junit-platform-commons;version='[1.10.2,1.10.3)',\ + junit-platform-engine;version='[1.10.2,1.10.3)',\ + org.opentest4j;version='[1.3.0,1.3.1)',\ + commons-rng-integration-tests;version='[1.6.0,1.6.1)',\ + junit-platform-launcher;version='[1.10.2,1.10.3)',\ + org.apache.commons.rng;version='[1.6.0,1.6.1)',\ + org.apache.commons.rng.core;version='[1.6.0,1.6.1)',\ + org.apache.commons.rng.sampling;version='[1.6.0,1.6.1)',\ + org.apache.commons.rng.simple;version='[1.6.0,1.6.1)' diff --git a/commons-rng-sampling/pom.xml b/commons-rng-sampling/pom.xml index 0ca247157..38c75c9e7 100644 --- a/commons-rng-sampling/pom.xml +++ b/commons-rng-sampling/pom.xml @@ -38,7 +38,12 @@ ${rng.build.outputTimestamp} org.apache.commons.rng.sampling - org.apache.commons.rng.sampling + + + org.apache.commons.rng.sampling, + org.apache.commons.rng.sampling.distribution, + org.apache.commons.rng.sampling.shape + org.apache.commons.rng.sampling sampling diff --git a/pom.xml b/pom.xml index e1c41822b..b85dd97a5 100644 --- a/pom.xml +++ b/pom.xml @@ -708,6 +708,13 @@ This is avoided by creating an empty directory when svn is not available. + + commons-rng-integration + + commons-rng-integration + + + release