Skip to content

Commit

Permalink
Merge branch 'upgrade/jdk-spring-dependencies' into commons4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
JiaLiangC authored Nov 8, 2024
2 parents e7b2320 + 39b6434 commit 4141391
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 21 deletions.
7 changes: 1 addition & 6 deletions ambari-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,7 @@
--add-opens java.base/java.text=ALL-UNNAMED
--add-opens java.xml/jdk.xml.internal=ALL-UNNAMED
--add-opens java.naming/com.sun.jndi.ldap=ALL-UNNAMED
--add-opens java.base/java.security=ALL-UNNAMED
</argLine>

<!-- Each profile in the top-level pom.xml defines which test group categories to run. -->
Expand Down Expand Up @@ -1311,12 +1312,6 @@
<version>3.5.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<version>3.5.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-security</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
*/
package org.apache.ambari.server.checks;

import static org.mockito.ArgumentMatchers.nullable;

import java.util.HashMap;
import java.util.Map;

import org.apache.ambari.server.api.services.AmbariMetaInfo;
import org.apache.ambari.server.orm.dao.HostVersionDAO;
import org.apache.ambari.server.orm.dao.RepositoryVersionDAO;
import org.apache.ambari.server.orm.entities.HostVersionEntity;
Expand All @@ -37,7 +38,6 @@
import org.apache.ambari.server.state.repository.ClusterVersionSummary;
import org.apache.ambari.server.state.repository.VersionDefinitionXml;
import org.apache.ambari.spi.ClusterInformation;
import org.apache.ambari.spi.RepositoryType;
import org.apache.ambari.spi.RepositoryVersion;
import org.apache.ambari.spi.upgrade.UpgradeCheckRequest;
import org.apache.ambari.spi.upgrade.UpgradeCheckResult;
Expand All @@ -53,7 +53,7 @@

import com.google.inject.Provider;

import static org.mockito.ArgumentMatchers.nullable;


/**
* Unit tests for HostsRepositoryVersionCheck
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
package org.apache.ambari.server.checks;

import static org.mockito.ArgumentMatchers.nullable;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
Expand Down Expand Up @@ -61,8 +63,6 @@

import com.google.inject.Provider;

import static org.mockito.ArgumentMatchers.nullable;


/**
* Unit tests for ServicesUpCheck
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.createNiceMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.expectLastCall;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
import static org.junit.Assert.assertFalse;
import static org.mockito.Mockito.mockStatic;
import static org.powermock.api.mockito.PowerMockito.whenNew;

import java.io.ByteArrayInputStream;
import java.io.File;
Expand Down Expand Up @@ -86,7 +83,6 @@
import org.junit.runner.RunWith;
import org.mockito.MockedStatic;
import org.powermock.api.easymock.PowerMock;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.springframework.security.core.Authentication;
Expand Down Expand Up @@ -603,7 +599,7 @@ private void testGetResourcesFromCommonServices(Authentication authentication) t
expect(cluster.getClusterName()).andReturn(clusterName);
expect(managementController.getHostComponents(EasyMock.anyObject())).andReturn(responses).anyTimes();

try (MockedStatic<StageUtils> mockedStageUtils = mockStatic(StageUtils.class)) {
PowerMock.mockStaticPartial(StageUtils.class, "getClusterHostInfo");


Map<String, Set<String>> clusterHostInfo = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,24 @@
*/
package org.apache.ambari.server.scheduler;

import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;


import java.util.Properties;

import org.apache.ambari.server.configuration.Configuration;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.quartz.Scheduler;

import junit.framework.Assert;
import static org.mockito.Mockito.*;

import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;

@RunWith(MockitoJUnitRunner.class)
public class ExecutionSchedulerTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,16 @@
import org.apache.ambari.spi.upgrade.OrchestrationOptions;
import org.apache.ambari.spi.upgrade.UpgradeType;
import org.apache.commons.io.FileUtils;
import org.easymock.*;
import org.easymock.Capture;
import org.easymock.EasyMock;
import org.easymock.EasyMockSupport;
import org.easymock.IAnswer;
import org.easymock.IArgumentMatcher;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.mockito.ArgumentMatcher;
import org.springframework.security.core.context.SecurityContextHolder;

import com.google.common.collect.ImmutableMap;
Expand Down Expand Up @@ -228,12 +231,21 @@ protected void configure() {
SecurityContextHolder.getContext().setAuthentication(TestAuthenticationFactory.createAdministrator("admin"));
}


@After
public void teardown() throws AmbariException, SQLException {
try{
H2DatabaseCleaner.clearDatabaseAndStopPersistenceService(injector);

// Clear the authenticated user
SecurityContextHolder.getContext().setAuthentication(null);

if (stackManagerMock != null) {
stackManagerMock.invalidateCurrentPaths();
}
}finally {
EasyMock.reset(m_configHelper, m_masterHostResolver);
}
}

@Test
Expand Down

0 comments on commit 4141391

Please sign in to comment.