Skip to content

Commit

Permalink
Fixed ql-full and ql-web tests
Browse files Browse the repository at this point in the history
- mistakes in recent commits - ArchiveType can be null
- incorrect usage of toString() in a test

Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
  • Loading branch information
dmatej committed Sep 18, 2022
1 parent 9bdfb03 commit 90396f8
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.net.URI;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
import java.util.logging.Level;
Expand Down Expand Up @@ -57,7 +58,7 @@ public class ACCPersistenceArchivist extends PersistenceArchivist {

@Override
public boolean supportsModuleType(ArchiveType moduleType) {
return DOLUtils.carType().equals(moduleType) && env.getProcessType() == ProcessType.ACC ;
return Objects.equals(moduleType, DOLUtils.carType()) && env.getProcessType() == ProcessType.ACC;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class AppClientArchivist extends Archivist<ApplicationClientDescriptor> {
public static final Attributes.Name GLASSFISH_ANCHOR_DIR =
new Attributes.Name("GlassFish-Anchor");

private String mainClassNameToRun = null;
private String mainClassNameToRun;

/**
* Creates new ApplicationClientArchvisit
Expand Down Expand Up @@ -95,14 +95,13 @@ public void setDescriptor(Application application) {

// this is acceptable if the application actually represents
// a standalone module
java.util.Set appClientBundles = application.getBundleDescriptors(ApplicationClientDescriptor.class);
if (appClientBundles.size() > 0) {
this.descriptor = (ApplicationClientDescriptor) appClientBundles.iterator().next();
Set<ApplicationClientDescriptor> appClientBundles = application.getBundleDescriptors(ApplicationClientDescriptor.class);
if (!appClientBundles.isEmpty()) {
this.descriptor = appClientBundles.iterator().next();
if (this.descriptor.getModuleDescriptor().isStandalone()) {
return;
} else {
this.descriptor = null;
}
this.descriptor = null;
}
DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.descriptorFailure", new Object[]{this});
throw new RuntimeException("Error setting descriptor " + descriptor + " in " + this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

import jakarta.inject.Inject;

import java.util.Objects;

import org.glassfish.api.admin.ProcessEnvironment;
import org.glassfish.api.deployment.archive.ArchiveType;
import org.glassfish.api.deployment.archive.ReadableArchive;
Expand All @@ -40,8 +42,8 @@ public class ServerSidePersistenceArchivist extends PersistenceArchivist {
public boolean supportsModuleType(ArchiveType moduleType) {
// Reads persitence.xml for ejb jars
// Or App client modules if running inside server
return DOLUtils.ejbType().equals(moduleType)
|| (DOLUtils.carType().equals(moduleType) && env.getProcessType().isServer());
return Objects.equals(DOLUtils.ejbType(), moduleType)
|| (env.getProcessType().isServer() && Objects.equals(DOLUtils.carType(), moduleType));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,13 +323,10 @@ public static ArchiveType getModuleType(String moduleType) {
if (moduleType == null) {
return null;
}
final ServiceLocator services = Globals.getDefaultHabitat();
ArchiveType result = null;
// This method is called without HK2 being setup when dol unit tests are run, so protect against NPE.
if(services != null) {
result = services.getService(ArchiveType.class, moduleType);
}
return result;
final ServiceLocator services = Globals.getStaticBaseServiceLocator();
// This method is called without HK2 being setup when dol unit tests are run,
// so protect against NPE.
return services == null ? null : services.getService(ArchiveType.class, moduleType);
}

// returns true if GF DD should have higher precedence over
Expand Down Expand Up @@ -622,6 +619,9 @@ private static Collection<Sniffer> getSniffersForModule(ServiceLocator habitat,
return sniffers;
}

/**
* @return Sniffer/Container type for moduleType or null
*/
private static String getTypeFromModuleType(ArchiveType moduleType) {
if (moduleType.equals(DOLUtils.warType())) {
return "web";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
Principal userp = request.getUserPrincipal();
String method = request.getAuthType();
if (userp != null) {
user = userp.toString();
user = userp.getName();
}
%>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2008, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -16,10 +17,10 @@

package org.glassfish.api.admin;

import org.jvnet.hk2.annotations.Service;

import jakarta.inject.Singleton;

import org.jvnet.hk2.annotations.Service;

/**
* Process environment allow access to information related to the execution or process. This is a bit tricky to rely
* of @Contract/@Service service lookup for this API since different implementations (server, clients, etc..) can be
Expand All @@ -31,13 +32,33 @@
@Singleton
public class ProcessEnvironment {

private final ProcessType type;

/**
* Default initialization is unkown process environment
*/
public ProcessEnvironment() {
type = ProcessType.Other;
}

/**
* Creates a process environemnt for the inten
*
* @param type of the execution environemnt
*/
public ProcessEnvironment(ProcessType type) {
this.type = type;
}

/**
* Determine and return the modes in which the code is behaving, like application server or application client modes.
*
* @return the process type
*/
public ProcessType getProcessType() {
return type;
}

/**
* Enumeration of the supported process types Server is the application server ACC is the application client Other is a
* standalone java.
Expand All @@ -57,25 +78,4 @@ public boolean isEmbedded() {
return this == Embedded;
}
}

/**
* Determine and return the modes in which the code is behaving, like application server or application client modes.
*
* @return the process type
*/
public ProcessType getProcessType() {
return type;
}

/**
* Creates a process environemnt for the inten
*
* @param type of the execution environemnt
*/
public ProcessEnvironment(ProcessType type) {
this.type = type;
}

final private ProcessType type;

}

0 comments on commit 90396f8

Please sign in to comment.