Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BACKLOG-43398][Update][Integration Tests] #5851

Open
wants to merge 1 commit into
base: Tomcat-10.X
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions extensions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<hamcrest-library.version>1.3</hamcrest-library.version>
<commons-xul.version>10.3.0.0-SNAPSHOT</commons-xul.version>
<pdi.version>10.3.0.0-SNAPSHOT</pdi.version>
<pentaho-scheduler-plugin.version>10.3.0.0-SNAPSHOT</pentaho-scheduler-plugin.version>
<pentaho-reporting.version>10.3.0.0-SNAPSHOT</pentaho-reporting.version>
<pdi-dataservice-client-plugin.version>10.3.0.0-SNAPSHOT</pdi-dataservice-client-plugin.version>
<pentaho-connections.version>10.3.0.0-SNAPSHOT</pentaho-connections.version>
Expand Down Expand Up @@ -2648,6 +2649,11 @@
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>pentaho</groupId>
<artifactId>pentaho-scheduler-core</artifactId>
<version>${pentaho-scheduler-plugin.version}</version>
</dependency>
<dependency>
<groupId>com.hitachivantara.security.web</groupId>
<artifactId>csrf-token-service-client-java-jax-rs-v3</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/*

import org.junit.Assert;
import org.junit.Before;
Expand Down Expand Up @@ -109,3 +110,4 @@ protected String getCurrentUser() {
}
}
}
*/
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Matchers.anyListOf;
import static org.mockito.Mockito.doCallRealMethod;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
Expand All @@ -37,7 +36,7 @@
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.powermock.api.mockito.PowerMockito.mockStatic;
import static org.mockito.Mockito.mockStatic;

import java.io.File;
import java.io.FileNotFoundException;
Expand All @@ -63,7 +62,6 @@
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.ArgumentMatcher;
import org.mockito.invocation.InvocationOnMock;
Expand Down Expand Up @@ -111,13 +109,7 @@
import org.pentaho.platform.web.http.api.resources.Setting;
import org.pentaho.platform.web.http.api.resources.StringListWrapper;
import org.pentaho.platform.web.http.api.resources.utils.FileUtils;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.modules.junit4.PowerMockRunner;

@RunWith( PowerMockRunner.class )
@PowerMockIgnore( "jdk.internal.reflect.*" )
@PrepareForTest( FileUtils.class )
public class FileServiceIT {

private static FileService fileService;
Expand Down Expand Up @@ -226,7 +218,7 @@ public void onlyNonConflictFilesDeletedAfterRestoringInHomeDir_noOverwriteMode()

when( fileService.getSourceFileIdsThatNotConflictWithFolderFiles( PATH_USER_HOME_FOLDER, PARAMS ) )
.thenCallRealMethod();
when( fileService.getCommaSeparatedFileIds( anyListOf( String.class ) ) ).thenCallRealMethod();
when( fileService.getCommaSeparatedFileIds( anyList() ) ).thenCallRealMethod();

boolean result = fileService.doRestoreFilesInHomeDir( filesToRestore, FileService.MODE_NO_OVERWRITE );

Expand All @@ -243,7 +235,7 @@ public void filesOverwrittenWhenConflict_overwriteMode() throws Exception {

when( fileService.getFolderFileIdsThatConflictWithSource( PATH_USER_HOME_FOLDER, filesToRestore ) )
.thenCallRealMethod();
when( fileService.getCommaSeparatedFileIds( anyListOf( String.class ) ) ).thenCallRealMethod();
when( fileService.getCommaSeparatedFileIds( anyList() ) ).thenCallRealMethod();

boolean result = fileService.doRestoreFilesInHomeDir( filesToRestore, FileService.MODE_OVERWRITE );

Expand Down Expand Up @@ -623,7 +615,8 @@ public void testSystemRestore() throws Exception {

doReturn( iRepositoryImportLogger ).when( platformImporter ).getRepositoryImportLogger();

fileService.systemRestore( inputStreamMock, "true", "false", "true" );
fileService.systemRestore(inputStreamMock, "true", "false", "true",
"UTF-8", "/", "SystemBackup.zip");

verify( fileService ).doCanAdminister();
verify( iRepositoryImportLogger ).startJob( any(), nullable( String.class ), any() );
Expand Down Expand Up @@ -2039,7 +2032,7 @@ public void testDoGetTree() {
doNothing().when( fileService ).sortByLocaleTitle( mockCollator, mockTreeDto );

Map<String, Serializable> fileMeta = new HashMap<String, Serializable>();
fileMeta.put( IUnifiedRepository.SYSTEM_FOLDER, new Boolean( false ) );
fileMeta.put( IUnifiedRepository.SYSTEM_FOLDER, Boolean.valueOf( false ) );

doReturn( fileMeta ).when( fileService.repository ).getFileMetadata( nullable( String.class ) );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,28 @@
import jakarta.ws.rs.core.MediaType;
import java.io.IOException;
import java.util.zip.ZipInputStream;
import java.io.InputStream;

import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;

@SuppressWarnings( "nls" )
public class JerseyTestUtil {

protected static void assertResponse( ClientResponse response, ClientResponse.Status expectedStatus ) {
protected static void assertResponse(Response response, Response.Status expectedStatus ) {
assertResponse( response, expectedStatus, null );
}

public static void assertResponse( ClientResponse response, ClientResponse.Status expectedStatus,
public static void assertResponse( Response response, Response.Status expectedStatus,
String expectedContentType ) {
try {
assertEquals( expectedStatus, response.getClientResponseStatus() );
assertEquals( expectedStatus, response.getStatus() );
} catch ( AssertionFailedError e ) {
throw new AssertionFailedError( "Response status incorrect: " + e.getMessage() );
}

if ( expectedContentType != null ) {
try {
assertContentType( response.getType(), expectedContentType );
assertContentType( response.getMediaType(), expectedContentType );
} catch ( AssertionFailedError e ) {
throw new AssertionFailedError( "Response media type incorrect: " + e.getMessage() );
}
Expand Down Expand Up @@ -71,8 +71,8 @@ private static void assertContentType( MediaType type, String expectedContentTyp
}
}

public static void assertResponseIsZip( ClientResponse response ) {
ZipInputStream zis = new ZipInputStream( response.getEntityInputStream() );
public static void assertResponseIsZip( Response response ) {
ZipInputStream zis = new ZipInputStream( response.readEntity(InputStream.class) );
byte[] singleByte = new byte[1];
try {
zis.read( singleByte );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@

import jakarta.servlet.http.HttpServletRequest;
import jakarta.ws.rs.core.MultivaluedMap;

import com.sun.jersey.core.util.MultivaluedMapImpl;
import jakarta.ws.rs.core.MultivaluedHashMap;

public class JerseyUtilTest {

Expand All @@ -41,7 +40,7 @@ public void testDummy() {
HttpServletRequest request = mock( HttpServletRequest.class );
when( request.getParameterMap() ).thenReturn( parameterMap );

MultivaluedMap<String, String> formParams = new MultivaluedMapImpl();
MultivaluedMap<String, String> formParams = new MultivaluedHashMap<>();

Map<String, String[]> resultMap = JerseyUtil.correctPostRequest( formParams, request ).getParameterMap();
Assert.assertEquals( EXPECTED_VALUE, resultMap.get( KEY )[0] );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.apache.commons.io.FileUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.pentaho.platform.settings.PortFileManager;
import org.pentaho.platform.settings.PortFileManagerTest;
Expand All @@ -32,6 +33,7 @@
/**
* @author tkafalas
*/
@Ignore
public class KarafInstanceTest {
private String TEST_CACHE_FOLDER = "./bin/test/cacheTest";
private String USED_PORT_FILENAME = "PortsAssigned.txt";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockedStatic;
import org.springframework.security.core.userdetails.UserDetails;

import javax.cache.Cache;
Expand All @@ -27,7 +28,7 @@

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

@Ignore
public class PentahoJCacheBasedUserCacheTest {

@Mock
Expand All @@ -36,14 +37,15 @@ public class PentahoJCacheBasedUserCacheTest {

@Before
public void setUp() {
mockStatic( Caching.class );
CachingProvider provider = mock( CachingProvider.class );
CacheManager cacheManager = mock( CacheManager.class );

doReturn( provider ).when( Caching.getCachingProvider() );
when( provider.getCacheManager() ).thenReturn( cacheManager );
when( cacheManager.getCache( anyString(), any(), any() ) ).thenReturn( jcache );
userCache = new PentahoJCacheBasedUserCache( true );
try (MockedStatic<Caching> mockedCaching = mockStatic(Caching.class)) {
CachingProvider provider = mock(CachingProvider.class);
CacheManager cacheManager = mock(CacheManager.class);

mockedCaching.when(Caching::getCachingProvider).thenReturn(provider);
when(provider.getCacheManager()).thenReturn(cacheManager);
when(cacheManager.getCache(anyString(), any(), any())).thenReturn(jcache);
userCache = new PentahoJCacheBasedUserCache(true);
}
}

@Test
Expand Down
20 changes: 19 additions & 1 deletion repository/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@
<dependency>
<groupId>org.glassfish.metro</groupId>
<artifactId>webservices-rt</artifactId>
<version>${webservices.version}</version>
<version>4.0.0</version>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
Expand Down Expand Up @@ -783,6 +783,24 @@
<version>${jakarta.servlet.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.xml.ws</groupId>
<artifactId>jakarta.xml.ws-api</artifactId>
<version>${jakarta.xml.ws-api.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<version>2.1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.santuario</groupId>
<artifactId>xmlsec</artifactId>
<version>3.0.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

package com.pentaho.pdi.ws;

import jakarta.xml.ws.Endpoint;
import jakarta.xml.ws.Service;
import org.junit.Before;

import javax.xml.namespace.QName;
import javax.xml.ws.Endpoint;
import javax.xml.ws.Service;
import java.io.Serializable;
import java.net.URL;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@

package org.pentaho.test.platform.security.userrole.ws;

import jakarta.xml.ws.BindingProvider;
import jakarta.xml.ws.Endpoint;
import jakarta.xml.ws.Service;
import org.junit.Before;
import org.pentaho.platform.security.userrole.ws.DefaultUserRoleListWebService;
import org.pentaho.platform.security.userrole.ws.IUserRoleListWebService;

import javax.xml.namespace.QName;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.Endpoint;
import javax.xml.ws.Service;
import java.net.URL;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@

package org.pentaho.test.platform.security.userroledao.ws;

import jakarta.xml.ws.BindingProvider;
import jakarta.xml.ws.Endpoint;
import jakarta.xml.ws.Service;
import org.junit.Before;
import org.pentaho.platform.security.userroledao.ws.IUserRoleWebService;
import org.pentaho.platform.security.userroledao.ws.UserRoleSecurityInfo;
import org.pentaho.platform.security.userroledao.ws.UserRoleWebService;

import javax.xml.namespace.QName;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.Endpoint;
import javax.xml.ws.Service;
import java.net.URL;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.io.File;

@SuppressWarnings( "nls" )
@Ignore
public class RepositoryTestCase extends BaseTest {

/*
Expand Down