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-39555] JDK17 - Build issue for https://github.com/pentaho/pe… #183

Open
wants to merge 1 commit into
base: JDK17
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
12 changes: 3 additions & 9 deletions pentaho-aggdesigner-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,9 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jmock</groupId>
<artifactId>jmock-junit4</artifactId>
<version>${jmock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jmock</groupId>
<artifactId>jmock-legacy</artifactId>
<version>${jmock.version}</version>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito-core.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,141 +1,129 @@
/*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU General Public License, version 2 as published by the Free Software
* Foundation.
*
* You should have received a copy of the GNU General Public License along with this
* program; if not, you can obtain a copy at http://www.gnu.org/licenses/gpl-2.0.html
* or from the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
*
* Copyright 2006 - 2020 Hitachi Vantara. All rights reserved.
*/
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU General Public License, version 2 as published by the Free Software
* Foundation.
*
* You should have received a copy of the GNU General Public License along with this
* program; if not, you can obtain a copy at http://www.gnu.org/licenses/gpl-2.0.html
* or from the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
*
* Copyright 2006 - 2020 Hitachi Vantara. All rights reserved.
*/

package org.pentaho.aggdes.model.mondrian.validate;

import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import java.io.InputStream;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.List;

import mondrian.olap.MondrianDef.Cube;
import mondrian.olap.MondrianDef.Schema;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.eigenbase.xom.Parser;
import org.eigenbase.xom.XOMException;
import org.eigenbase.xom.XOMUtil;
import org.jmock.Mockery;
import org.jmock.integration.junit4.JUnit4Mockery;
import org.pentaho.aggdes.model.ValidationMessage;
import org.pentaho.aggdes.model.ValidationMessage.Type;
import org.pentaho.aggdes.model.mondrian.validate.MondrianSchemaValidator;
import org.junit.Before;
import org.junit.Test;

import mondrian.olap.MondrianDef.Cube;
import mondrian.olap.MondrianDef.Schema;

/*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU General Public License, version 2 as published by the Free Software
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU General Public License, version 2 as published by the Free Software
* Foundation.
*
* You should have received a copy of the GNU General Public License along with this
* program; if not, you can obtain a copy at http://www.gnu.org/licenses/gpl-2.0.html
* or from the Free Software Foundation, Inc.,
* You should have received a copy of the GNU General Public License along with this
* program; if not, you can obtain a copy at http://www.gnu.org/licenses/gpl-2.0.html
* or from the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
*
* Copyright 2008 - 2020 Hitachi Vantara. All rights reserved.
*/
* Copyright 2008 - 2024 Hitachi Vantara. All rights reserved.
*/
public abstract class AbstractMondrianSchemaValidatorTestBase {

protected static final Log logger = LogFactory.getLog( AbstractMondrianSchemaValidatorTestBase.class );
protected Schema schema;

protected Connection conn;

protected Mockery context;

protected DatabaseMetaData meta;

protected ResultSet rsSalesFact1997PrimaryKeys;

protected ResultSet rsSalesFact1997ForeignKey;

protected ResultSet rsStorePrimaryKeys;

protected ResultSet rsCount;

protected Statement stmt;

protected MondrianSchemaValidator v1;

protected MondrianSchemaValidator v2;

protected MondrianSchemaValidator v3;

protected MondrianSchemaValidator v4;

protected MondrianSchemaValidator v5;

protected static final Log logger = LogFactory.getLog(AbstractMondrianSchemaValidatorTestBase.class);

@Before
public void setUp() throws Exception {
context = new JUnit4Mockery();
schema = loadSchema("/FoodMart.xml");
if (null == schema) {
schema = loadSchema( "/FoodMart.xml" );
if ( null == schema ) {
// end the test
throw new RuntimeException("unable to load schema from file");
throw new RuntimeException( "unable to load schema from file" );
}
conn = context.mock(Connection.class);
meta = context.mock(DatabaseMetaData.class);
rsSalesFact1997PrimaryKeys = context.mock(ResultSet.class, "rsSalesFact1997PrimaryKeys"); //$NON-NLS-1$
rsStorePrimaryKeys = context.mock(ResultSet.class, "rsStorePrimaryKeys"); //$NON-NLS-1$
rsSalesFact1997ForeignKey = context.mock(ResultSet.class, "rsSalesFact1997ForeignKey"); //$NON-NLS-1$
stmt = context.mock(Statement.class, "stmt");
rsCount = context.mock(ResultSet.class, "rsCount");
v1 = context.mock(MondrianSchemaValidator.class, "v1");
v2 = context.mock(MondrianSchemaValidator.class, "v2");
v3 = context.mock(MondrianSchemaValidator.class, "v3");
v4 = context.mock(MondrianSchemaValidator.class, "v4");
v5 = context.mock(MondrianSchemaValidator.class, "v5");
conn = mock( Connection.class );
meta = mock( DatabaseMetaData.class );
rsSalesFact1997PrimaryKeys = mock( ResultSet.class );
rsStorePrimaryKeys = mock( ResultSet.class );
rsSalesFact1997ForeignKey = mock( ResultSet.class );
stmt = mock( Statement.class );
rsCount = mock( ResultSet.class );
v1 = mock( MondrianSchemaValidator.class );
v2 = mock( MondrianSchemaValidator.class );
v3 = mock( MondrianSchemaValidator.class );
v4 = mock( MondrianSchemaValidator.class );
v5 = mock( MondrianSchemaValidator.class );
}

protected Schema loadSchema(String classpathRelativePath) {
protected Schema loadSchema( String classpathRelativePath ) {
try {
Parser xmlParser = XOMUtil.createDefaultParser();
if (logger.isDebugEnabled()) {
logger.debug("creating InputStream from " + classpathRelativePath);
if ( logger.isDebugEnabled() ) {
logger.debug( "creating InputStream from " + classpathRelativePath );
}
InputStream is = getClass().getResourceAsStream(classpathRelativePath);
if (null == is) {
if (logger.isDebugEnabled()) {
logger.debug(classpathRelativePath + " not found");
InputStream is = getClass().getResourceAsStream( classpathRelativePath );
if ( null == is ) {
if ( logger.isDebugEnabled() ) {
logger.debug( classpathRelativePath + " not found" );
}
return null;
}
return new Schema(xmlParser.parse(is));
} catch (XOMException e) {
if (logger.isErrorEnabled()) {
logger.error("an exception occurred; returning null", e);
return new Schema( xmlParser.parse( is ) );
} catch ( XOMException e ) {
if ( logger.isErrorEnabled() ) {
logger.error( "an exception occurred; returning null", e );
}
}
return null;
}

protected boolean isMessagePresent(List<ValidationMessage> messages, Type type, String... substrings) {
for (ValidationMessage message : messages) {
if (message.getType() == type) {
for (String substring : substrings) {
if (!message.getMessage().contains(substring)) {
protected boolean isMessagePresent( List<ValidationMessage> messages, Type type, String... substrings ) {
for ( ValidationMessage message : messages ) {
if ( message.getType() == type ) {
for ( String substring : substrings ) {
if ( !message.getMessage().contains( substring ) ) {
return false;
}
}
Expand All @@ -145,12 +133,13 @@ protected boolean isMessagePresent(List<ValidationMessage> messages, Type type,
return false;
}

protected Cube getCubeByName(String name) {
for (Cube cube : schema.cubes) {
if (cube.name.equals(name)) {
protected Cube getCubeByName( String name ) {
for ( Cube cube : schema.cubes ) {
if ( cube.name.equals( name ) ) {
return cube;
}
}
return null;
}

}
Loading