jaulib v1.3.0
Jau Support Library (C++, Java, ..)
TestVersionInfo.java
Go to the documentation of this file.
1/**
2 * Author: Sven Gothel <sgothel@jausoft.com>
3 * Copyright (c) 2021 Gothel Software e.K.
4 * Copyright (c) 2010 Gothel Software e.K.
5 * Copyright (c) 2010 JogAmp Community.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining
8 * a copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sublicense, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject to
13 * the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be
16 * included in all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 */
26
27package jau.test.util;
28
29import java.io.IOException;
30import java.net.URISyntaxException;
31import java.security.NoSuchAlgorithmException;
32
33import org.jau.base.JaulibVersion;
34import org.jau.pkg.JaulibJarSHASum;
35import org.jau.sec.SHASum;
36import org.jau.util.VersionUtil;
37import org.junit.Assert;
38import org.junit.FixMethodOrder;
39import org.junit.Test;
40import org.junit.runners.MethodSorters;
41
42import jau.test.junit.util.JunitTracer;
43
44@FixMethodOrder(MethodSorters.NAME_ASCENDING)
45public class TestVersionInfo extends JunitTracer {
46 static boolean VERBOSE = false;
47
48 @Test
49 public void test01Info() {
50 System.err.println(VersionUtil.getPlatformInfo());
51 System.err.println("Version Info:");
52 System.err.println(JaulibVersion.getInstance());
53 System.err.println("");
54 System.err.println("Full Manifest:");
55 System.err.println(JaulibVersion.getInstance().getFullManifestInfo(null));
56 }
57
58 // @Test // FIXME: Add SHA signature in build system!
59 public void test02ValidateSHA()
60 throws IllegalArgumentException, IOException, URISyntaxException, SecurityException, NoSuchAlgorithmException
61 {
63 final String shaClassesThis = info.getImplementationSHAClassesThis();
64 System.err.println("SHA CLASSES.this (build-time): "+shaClassesThis);
65
66 final JaulibJarSHASum shaSum = new JaulibJarSHASum();
67 final byte[] shasum = shaSum.compute(VERBOSE);
68 final String shaClasses = SHASum.toHexString(shasum, null).toString();
69 System.err.println("SHA CLASSES.this (now): "+shaClasses);
70 Assert.assertEquals("SHA not equal", shaClassesThis, shaClasses);
71 }
72
73 public static void main(final String args[]) throws IOException {
74 // VERBOSE = true;
75 final String tstname = TestVersionInfo.class.getName();
76 org.junit.runner.JUnitCore.main(tstname);
77 }
78
79}
static void main(final String args[])
static JaulibVersion getInstance()
Returns a transient new instance.
jaulib definition of TempJarSHASum's specialization of SHASum.
Utility class to produce secure hash (SHA) sums over diverse input sources.
Definition: SHASum.java:69
final byte[] compute(final boolean verbose)
Implementation gathers all files traversing through given paths via IOUtil#filesOf(List,...
Definition: SHASum.java:186
static StringBuilder toHexString(final byte[] shasum, StringBuilder sb)
Simple helper to print the given byte-array into a string, here appended to StringBuilder.
Definition: SHASum.java:125
final StringBuilder getFullManifestInfo(final StringBuilder sb)
final String getImplementationSHAClassesThis()
Returns the SHA of all concatenated class files of the local (jar) package subset.
static StringBuilder getPlatformInfo(StringBuilder sb)
Appends environment information like OS, JVM and CPU architecture properties to the StringBuilder.