Skip to content

Commit

Permalink
Merge pull request #24322 from dmatej/version-info-revisited
Browse files Browse the repository at this point in the history
  • Loading branch information
arjantijms authored Feb 28, 2023
2 parents ea94e54 + 0b71644 commit f05cd0a
Show file tree
Hide file tree
Showing 33 changed files with 697 additions and 462 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2023 Contributors to the Eclipse Foundation
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -14,24 +15,24 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

/*
* Status.java
*
* Created on March 27, 2004, 10:40 PM
*/

package com.sun.enterprise.backup;

import com.sun.appserv.server.util.Version;
import com.sun.enterprise.util.io.FileUtils;
import java.io.*;
import java.util.*;
import java.util.zip.*;

import com.sun.appserv.server.util.Version;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Date;
import java.util.Locale;
import java.util.Properties;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

/**
*
* @author Byron Nevins
* @author Byron Nevins 2004
*/
class Status {

Expand Down Expand Up @@ -95,8 +96,9 @@ public boolean loadProps(File file) {
props = null;
setPropsFromFile(file);

if (props == null)
if (props == null) {
return false;
}

return true;
}
Expand Down Expand Up @@ -127,30 +129,34 @@ void delete() {
}

String getDomainName() {
if(props == null)
if(props == null) {
return null;
}

return props.getProperty(Constants.PROPS_DOMAIN_NAME);
}

String getTimeStamp() {
if(props == null)
if(props == null) {
return null;
}

return props.getProperty(Constants.PROPS_TIMESTAMP_HUMAN);
}

String getUserName() {
if(props == null)
if(props == null) {
return null;
}

return props.getProperty(Constants.PROPS_USER_NAME);
}

// Return the full path to the backup file.
String getBackupPath() {
if(props == null)
if(props == null) {
return null;
}

try {
File f = new File(props.getProperty(Constants.PROPS_BACKUP_FILE));
Expand All @@ -163,8 +169,9 @@ String getBackupPath() {

// Return the filename portion of the path.
String getFileName() {
if(props == null)
if(props == null) {
return null;
}

try {
File f = new File(props.getProperty(Constants.PROPS_BACKUP_FILE));
Expand All @@ -176,15 +183,17 @@ String getFileName() {
}

String getBackupConfigName(){
if(props == null)
return "";
if(props == null) {
return "";
}

return props.getProperty(Constants.BACKUP_CONFIG, "");
}

String getBackupType(){
if(props == null)
return "";
if(props == null) {
return "";
}

return props.getProperty(Constants.PROPS_TYPE, "");
}
Expand Down Expand Up @@ -274,7 +283,7 @@ private void setProps(BackupRequest request) {
new Date(request.timestamp).toString());

props.setProperty(Constants.PROPS_VERSION,
Version.getFullVersion());
Version.getProductIdInfo());

String type = request.configOnly ? Constants.CONFIG_ONLY :
Constants.FULL;
Expand Down
5 changes: 0 additions & 5 deletions appserver/distributions/glassfish-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@

<name>GlassFish distribution Common module</name>

<properties>
<!-- properties are generated by the git-commit-id-plugin -->
<build.id>${git.branch}-b${git.closest.tag.commit.count}-g${git.commit.id.abbrev} ${git.build.time}</build.id>
</properties>

<dependencies>
<dependency>
<groupId>org.glassfish.main.distributions</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2022 Contributors to the Eclipse Foundation
# Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation
# Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
#
# This program and the accompanying materials are made available under the
Expand All @@ -15,13 +15,14 @@
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
#

product_name=${product.name}
abbrev_product_name=${abbrev_product_name}
major_version=${major_version}
minor_version=${minor_version}
update_version=${update_version}
build_id=${build.id}
version_prefix=${version_prefix}
version_suffix=${version_suffix}
default_domain_template=${default_domain_template}
admin_client_command_name=${admin_client_command_name}
product.name=${product.name}
product.name.abbreviation=${product.name.abbreviation}
product.version=${project.version}
product.build.git.branch=${git.branch}
product.build.git.commit=${git.commit.id.full}
product.build.timestamp=${git.build.time}

admin.command.name=${admin.command.name}

domain.admin.groups=asadmin
domain.template.defaultJarFileName=${domain.template.defaultJarFileName}
20 changes: 4 additions & 16 deletions appserver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,7 @@
<microprofile-jwt-auth-api.version>2.0</microprofile-jwt-auth-api.version>
<omnifaces-jwt-auth.version>2.0.1</omnifaces-jwt-auth.version>



<!-- Admin console components -->

<jsftemplating.version>4.0.0</jsftemplating.version>
<jsf-ext.version>0.2</jsf-ext.version>
<woodstock.version>6.0.0</woodstock.version>
Expand All @@ -169,27 +166,18 @@
<woodstock-json.version>2.0</woodstock-json.version>
<woodstock-prototype.version>1.7.3</woodstock-prototype.version>


<!-- Other -->

<dbschema.version>6.7</dbschema.version>
<schema2beans.version>6.7</schema2beans.version>
<derby.version>10.15.2.0</derby.version>
<wsdl4j.version>1.6.3</wsdl4j.version>
<maven-rar-plugin.version>2.4</maven-rar-plugin.version>


<!-- Settings -->

<product.name>Eclipse GlassFish</product.name>
<abbrev_product_name>GlassFish</abbrev_product_name>
<admin_client_command_name>asadmin</admin_client_command_name>
<default_domain_template>appserver-domain.jar</default_domain_template>
<version_prefix />
<version_suffix />
<major_version>7</major_version>
<minor_version>0</minor_version>
<update_version>2</update_version>
<product.name.abbreviation>GF</product.name.abbreviation>

<admin.command.name>asadmin</admin.command.name>
<domain.template.defaultJarFileName>appserver-domain.jar</domain.template.defaultJarFileName>
<install.dir.name>glassfish7</install.dir.name>

<test.logManager>org.glassfish.main.jul.GlassFishLogManager</test.logManager>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation
* Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -19,47 +19,22 @@

import org.glassfish.main.admin.test.tool.asadmin.Asadmin;
import org.glassfish.main.admin.test.tool.asadmin.GlassFishTestEnvironment;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;

import static org.glassfish.main.admin.test.tool.AsadminResultMatcher.asadminOK;

import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;

import static org.glassfish.main.admin.test.tool.AsadminResultMatcher.asadminOK;
import static org.hamcrest.MatcherAssert.assertThat;


/**
* @author Tom Mueller
*/
@TestMethodOrder(OrderAnnotation.class)
public class MiscCommandsITest {
public class AsadminUptimeITest {

private static final Asadmin ASADMIN = GlassFishTestEnvironment.getAsadmin();

@AfterAll
public static void startDomainAgain() {
assertThat(ASADMIN.exec("start-domain"), asadminOK());
}

@Test
@Order(1)
public void uptime() {
assertThat(ASADMIN.exec("uptime"), asadminOK());
}

@Test
@Order(1)
public void version1() {
assertThat(ASADMIN.exec("version"), asadminOK());
}

@Test
@Order(100)
public void version2() {
assertThat(ASADMIN.exec("stop-domain"), asadminOK());
assertThat(ASADMIN.exec("version", "--local"), asadminOK());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* Copyright (c) 2023 Eclipse Foundation and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

package org.glassfish.main.admin.test;

import java.time.Instant;

import org.apache.commons.lang3.StringUtils;
import org.glassfish.main.admin.test.tool.asadmin.Asadmin;
import org.glassfish.main.admin.test.tool.asadmin.AsadminResult;
import org.glassfish.main.admin.test.tool.asadmin.GlassFishTestEnvironment;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.opentest4j.MultipleFailuresError;

import static org.glassfish.main.admin.test.tool.AsadminResultMatcher.asadminOK;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.matchesPattern;
import static org.hamcrest.Matchers.stringContainsInOrder;
import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;

/**
* @author David Matejcek
*/
@TestMethodOrder(OrderAnnotation.class)
public class AsadminVersionITest {

private static final Asadmin ASADMIN = GlassFishTestEnvironment.getAsadmin();

@AfterAll
public static void startDomainAgain() {
assertThat(ASADMIN.exec("start-domain"), asadminOK());
}


@Test
@Order(1)
public void version() {
AsadminResult result = ASADMIN.exec("version");
assertThat(result, asadminOK());
String output = result.getStdOut();
checkOutput(output);
}


@Test
@Order(100)
public void versionAfterShutdown() {
assertThat(ASADMIN.exec("stop-domain"), asadminOK());
AsadminResult result = ASADMIN.exec("version", "--local");
assertThat(result, asadminOK());
checkOutput(result.getStdOut());
}


private void checkOutput(String output) throws MultipleFailuresError {
assertThat(output,
stringContainsInOrder("Version = Eclipse GlassFish ", " (branch: ", ", commit: ", ", timestamp: "));
String branch = StringUtils.substringBetween(output, "branch: ", ",");
String commit = StringUtils.substringBetween(output, "commit: ", ",");
String timestamp = StringUtils.substringBetween(output, ", timestamp: ", ")");
assertAll(
() -> assertThat(branch, matchesPattern("[^\\ ]+")),
() -> assertThat(commit, matchesPattern("[a-f0-9]+")),
() -> assertDoesNotThrow(() -> Instant.parse(timestamp))
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
public class DomainTest extends AdminBaseDevTest {

private final String NUCLEUS_DOMAIN_TEMPLATE_NAME = "nucleus-domain.jar";
private final String DEFAULT_DOMAIN_TEMPLATE_NAME = "default_domain_template";
private final String DEFAULT_DOMAIN_TEMPLATE_NAME = "domain.template.defaultJarFileName";
private final String BRANDING_FILE_RELATIVE_PATH = "config" + File.separator + "branding" + File.separator + "glassfish-version.properties";
private Properties _brandingProperties;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public class VersionPrinter {
public static void main(final String[] arg) {
try {
System.out.println("Full Version: " + Version.getFullVersion());
System.out.println("Abbreviated Version: " + Version.getAbbreviatedVersion());
System.out.println("Build Version: " + Version.getBuildVersion());
System.out.println("Major Version: " + Version.getMajorVersion());
System.out.println("Minor Version: " + Version.getMinorVersion());
Expand Down
Loading

0 comments on commit f05cd0a

Please sign in to comment.