Revert "REPO-4002: Upgrade mariadb driver (#292)"

This reverts commit 93b0ca4c76.
This commit is contained in:
Erik Knizat
2018-12-21 11:32:29 +00:00
parent 64fe8498d4
commit babf0836e0
9 changed files with 5557 additions and 1 deletions

View File

@@ -54,7 +54,7 @@
<dependency.activiti.version>5.22.0</dependency.activiti.version> <dependency.activiti.version>5.22.0</dependency.activiti.version>
<dependency.postgresql.version>42.2.5</dependency.postgresql.version> <dependency.postgresql.version>42.2.5</dependency.postgresql.version>
<dependency.mysql.version>5.1.47</dependency.mysql.version> <dependency.mysql.version>5.1.47</dependency.mysql.version>
<dependency.mariadb.version>2.3.0</dependency.mariadb.version> <dependency.mariadb.version>2.0.1</dependency.mariadb.version>
<dependency.antlr.version>3.5.2</dependency.antlr.version> <dependency.antlr.version>3.5.2</dependency.antlr.version>
<dependency.keycloak.version>4.5.0.Final</dependency.keycloak.version> <dependency.keycloak.version>4.5.0.Final</dependency.keycloak.version>
<dependency.jboss.logging.version>3.3.2.Final</dependency.jboss.logging.version> <dependency.jboss.logging.version>3.3.2.Final</dependency.jboss.logging.version>

View File

@@ -158,5 +158,8 @@ public class DialectFactory
MAPPERS.put( "Microsoft SQL Server Database", new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.SQLServerDialect" ) ); MAPPERS.put( "Microsoft SQL Server Database", new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.SQLServerDialect" ) );
MAPPERS.put( "Microsoft SQL Server", new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.SQLServerDialect" ) ); MAPPERS.put( "Microsoft SQL Server", new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.SQLServerDialect" ) );
MAPPERS.put( "Oracle", new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.Oracle9Dialect" ) ); MAPPERS.put( "Oracle", new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.Oracle9Dialect" ) );
// MariaDB is distinguished by driver name
MAPPERS.put( "MariaDB connector/J", new VersionInsensitiveMapper("org.alfresco.repo.domain.dialect.MariaDBDialect"));
} }
} }

View File

@@ -0,0 +1,38 @@
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.repo.domain.dialect;
/**
* @author eknizat
* @since 6.0
*/
public class MariaDBDialect extends MySQLInnoDBDialect
{
public MariaDBDialect()
{
super();
}
}

View File

@@ -195,6 +195,7 @@ import org.junit.runners.Suite;
org.alfresco.heartbeat.ModelUsageDataCollectorTest.class, org.alfresco.heartbeat.ModelUsageDataCollectorTest.class,
org.alfresco.heartbeat.SystemUsageDataCollectorTest.class, org.alfresco.heartbeat.SystemUsageDataCollectorTest.class,
org.alfresco.repo.domain.DialectFactoryBeanTest.class,
org.alfresco.util.BeanExtenderUnitTest.class, org.alfresco.util.BeanExtenderUnitTest.class,
org.alfresco.util.bean.HierarchicalBeanLoaderTest.class, org.alfresco.util.bean.HierarchicalBeanLoaderTest.class,
org.alfresco.util.resource.HierarchicalResourceLoaderTest.class, org.alfresco.util.resource.HierarchicalResourceLoaderTest.class,

View File

@@ -0,0 +1,73 @@
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2018 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.repo.domain;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import org.alfresco.repo.domain.dialect.DialectFactoryBean;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
/**
* @author Erik Knizat
*/
public class DialectFactoryBeanTest
{
private static final String MARIADB_DIALECT_NAME = "org.alfresco.repo.domain.dialect.MariaDBDialect";
private static final String MARIA_DB_DRIVER_NAME = "MariaDB connector/J";
@Test
public void testMariaDBDialectGetsAdded()
{
// DialectFactoryBean dfb = new DialectFactoryBean();
// Map<String, String> driverDialectMap = new HashMap<>();
// driverDialectMap.put(MARIA_DB_DRIVER_NAME, MARIADB_DIALECT_NAME);
// dfb.setDriverDialectMap(driverDialectMap);
// Properties props = new Properties();
// dfb.overrideDialectPropertyForDriver(props, MARIA_DB_DRIVER_NAME);
//
// assertNotNull("The dialect property was not set for the driver.", props.getProperty((Environment.DIALECT)));
// assertEquals("Dialect name did not match.", MARIADB_DIALECT_NAME, props.getProperty((Environment.DIALECT)));
}
@Test
public void testDialectNotAddedIfNotSpecifiedForDriver()
{
// DialectFactoryBean dfb = new DialectFactoryBean();
// Map<String, String> driverDialectMap = new HashMap<>();
// dfb.setDriverDialectMap(driverDialectMap); // Add empty dialect driver map
// Properties props = new Properties();
// dfb.overrideDialectPropertyForDriver(props, MARIA_DB_DRIVER_NAME);
//
// assertNull("Dialect name property was set for unspecified driver name.", props.getProperty((Environment.DIALECT)));
}
}

View File

@@ -29,12 +29,14 @@ package org.alfresco.util.schemacomp;
import javax.sql.DataSource; import javax.sql.DataSource;
import org.alfresco.repo.domain.dialect.Dialect; import org.alfresco.repo.domain.dialect.Dialect;
import org.alfresco.repo.domain.dialect.MariaDBDialect;
import org.alfresco.repo.domain.dialect.MySQLInnoDBDialect; import org.alfresco.repo.domain.dialect.MySQLInnoDBDialect;
import org.alfresco.repo.domain.dialect.PostgreSQLDialect; import org.alfresco.repo.domain.dialect.PostgreSQLDialect;
import org.alfresco.test_category.OwnJVMTestsCategory; import org.alfresco.test_category.OwnJVMTestsCategory;
import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.ApplicationContextHelper;
import org.alfresco.util.schemacomp.model.Schema; import org.alfresco.util.schemacomp.model.Schema;
import org.alfresco.util.schemacomp.test.exportdb.AbstractExportTester; import org.alfresco.util.schemacomp.test.exportdb.AbstractExportTester;
import org.alfresco.util.schemacomp.test.exportdb.AlfrescoMariaDBDialectExportTester;
import org.alfresco.util.schemacomp.test.exportdb.MySQLDialectExportTester; import org.alfresco.util.schemacomp.test.exportdb.MySQLDialectExportTester;
import org.alfresco.util.schemacomp.test.exportdb.PostgreSQLDialectExportTester; import org.alfresco.util.schemacomp.test.exportdb.PostgreSQLDialectExportTester;
import org.alfresco.util.testing.category.DBTests; import org.alfresco.util.testing.category.DBTests;
@@ -96,6 +98,10 @@ public class ExportDbTest
{ {
exportTester = new PostgreSQLDialectExportTester(exporter, tx, jdbcTemplate); exportTester = new PostgreSQLDialectExportTester(exporter, tx, jdbcTemplate);
} }
else if (MariaDBDialect.class.isAssignableFrom(dialectClass))
{
exportTester = new AlfrescoMariaDBDialectExportTester(exporter, tx, jdbcTemplate);
}
else if (MySQLInnoDBDialect.class.isAssignableFrom(dialectClass)) else if (MySQLInnoDBDialect.class.isAssignableFrom(dialectClass))
{ {
exportTester = new MySQLDialectExportTester(exporter, tx, jdbcTemplate); exportTester = new MySQLDialectExportTester(exporter, tx, jdbcTemplate);

View File

@@ -0,0 +1,311 @@
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.util.schemacomp.test.exportdb;
import java.util.Iterator;
import org.alfresco.util.schemacomp.ExportDb;
import org.alfresco.util.schemacomp.ExportDbTest;
import org.alfresco.util.schemacomp.model.Column;
import org.alfresco.util.schemacomp.model.DbObject;
import org.alfresco.util.schemacomp.model.ForeignKey;
import org.alfresco.util.schemacomp.model.Index;
import org.alfresco.util.schemacomp.model.PrimaryKey;
import org.alfresco.util.schemacomp.model.Schema;
import org.alfresco.util.schemacomp.model.Table;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.TransactionCallbackWithoutResult;
import org.springframework.transaction.support.TransactionTemplate;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
/**
* MySQL specific test for the ExportDb class.
*
* @see ExportDbTest
* @author eknizat
*/
public class AlfrescoMariaDBDialectExportTester extends AbstractExportTester
{
/**
* Constructor.
*
* @param exporter
* @param tx
* @param jdbcTemplate
*/
public AlfrescoMariaDBDialectExportTester(ExportDb exporter, PlatformTransactionManager tx,
JdbcTemplate jdbcTemplate)
{
super(exporter, tx, jdbcTemplate);
}
@Override
protected void doExportTest() throws Exception
{
Schema schema = getSchema();
Table exampleTable = null;
Table otherTable = null;
for (DbObject dbo : schema)
{
if (dbo.getName().equals("export_test_example"))
{
exampleTable = (Table) dbo;
}
if (dbo.getName().equals("export_test_other"))
{
otherTable = (Table) dbo;
}
}
checkExampleTable(schema, exampleTable);
checkOtherTable(schema, otherTable);
}
private void checkOtherTable(Schema schema, Table otherTable)
{
assertNotNull("Couldn't find table export_test_other", otherTable);
assertSame("Incorrect parent or no parent set", schema, otherTable.getParent());
Iterator<Column> colIt = otherTable.getColumns().iterator();
Column col = colIt.next();
assertSame("Incorrect parent or no parent set", otherTable, col.getParent());
assertEquals("id", col.getName());
assertEquals("bigint", col.getType());
assertEquals(false, col.isNullable());
assertEquals(1, col.getOrder());
assertEquals(false, col.isAutoIncrement());
col = colIt.next();
assertSame("Incorrect parent or no parent set", otherTable, col.getParent());
assertEquals("version", col.getName());
assertEquals("bigint", col.getType());
assertEquals(false, col.isNullable());
assertEquals(2, col.getOrder());
col = colIt.next();
assertSame("Incorrect parent or no parent set", otherTable, col.getParent());
assertEquals("ex_id", col.getName());
assertEquals("bigint", col.getType());
assertEquals(false, col.isNullable());
assertEquals(3, col.getOrder());
col = colIt.next();
assertSame("Incorrect parent or no parent set", otherTable, col.getParent());
assertSame("Incorrect parent or no parent set", otherTable, col.getParent());
assertEquals("local_name", col.getName());
assertEquals("varchar(200)", col.getType());
assertEquals(false, col.isNullable());
assertEquals(4, col.getOrder());
assertEquals(3, otherTable.getIndexes().size());
Iterator<Index> indexIt = otherTable.getIndexes().iterator();
Index index = indexIt.next();
assertSame("Incorrect parent or no parent set", otherTable, index.getParent());
assertEquals("export_test_idx_other_1", index.getName());
assertEquals(true, index.isUnique());
assertEquals(2, index.getColumnNames().size());
assertEquals("ex_id", index.getColumnNames().get(0));
assertEquals("local_name", index.getColumnNames().get(1));
index = indexIt.next();
assertSame("Incorrect parent or no parent set", otherTable, index.getParent());
assertEquals("PRIMARY", index.getName());
assertEquals(1, index.getColumnNames().size());
assertEquals("id", index.getColumnNames().get(0));
PrimaryKey pk = otherTable.getPrimaryKey();
assertSame("Incorrect parent or no parent set", otherTable, pk.getParent());
assertEquals("id", pk.getColumnNames().get(0));
assertEquals(1, pk.getColumnOrders().get(0).intValue());
assertEquals(1, otherTable.getForeignKeys().size());
ForeignKey fk = otherTable.getForeignKeys().get(0);
assertSame("Incorrect parent or no parent set", otherTable, fk.getParent());
assertEquals("export_test_fk_example", fk.getName());
assertEquals("ex_id", fk.getLocalColumn());
assertEquals("export_test_example", fk.getTargetTable());
assertEquals("id", fk.getTargetColumn());
}
private void checkExampleTable(Schema schema, Table exampleTable)
{
assertNotNull("Couldn't find export_test_example", exampleTable);
assertSame("Incorrect parent or no parent set", schema, exampleTable.getParent());
assertEquals("export_test_example", exampleTable.getName());
Iterator<Column> colIt = exampleTable.getColumns().iterator();
Column col = colIt.next();
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
assertEquals("id", col.getName());
assertEquals("bigint", col.getType());
assertEquals(false, col.isNullable());
assertEquals(1, col.getOrder());
assertEquals(true, col.isAutoIncrement());
col = colIt.next();
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
assertEquals("description", col.getName());
assertEquals("text", col.getType());
assertEquals(true, col.isNullable());
assertEquals(2, col.getOrder());
col = colIt.next();
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
assertEquals("fixes_from_schema", col.getName());
assertEquals("int", col.getType());
assertEquals(true, col.isNullable());
assertEquals(3, col.getOrder());
col = colIt.next();
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
assertEquals("fixes_to_schema", col.getName());
assertEquals("int", col.getType());
assertEquals(true, col.isNullable());
assertEquals(4, col.getOrder());
col = colIt.next();
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
assertEquals("applied_to_schema", col.getName());
assertEquals("int", col.getType());
assertEquals(true, col.isNullable());
assertEquals(5, col.getOrder());
col = colIt.next();
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
assertEquals("target_schema", col.getName());
assertEquals("int", col.getType());
assertEquals(true, col.isNullable());
assertEquals(6, col.getOrder());
col = colIt.next();
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
assertEquals("applied_on_date", col.getName());
assertEquals("datetime", col.getType());
assertEquals(true, col.isNullable());
assertEquals(7, col.getOrder());
col = colIt.next();
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
assertEquals("applied_to_server", col.getName());
assertEquals("varchar(64)", col.getType());
assertEquals(true, col.isNullable());
assertEquals(8, col.getOrder());
col = colIt.next();
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
assertEquals("was_executed", col.getName());
assertEquals("bit", col.getType());
assertEquals(true, col.isNullable());
assertEquals(9, col.getOrder());
col = colIt.next();
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
assertEquals("succeeded", col.getName());
assertEquals("bit", col.getType());
assertEquals(true, col.isNullable());
assertEquals(10, col.getOrder());
col = colIt.next();
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
assertEquals("report", col.getName());
assertEquals("text", col.getType());
assertEquals(true, col.isNullable());
assertEquals(11, col.getOrder());
PrimaryKey pk = exampleTable.getPrimaryKey();
assertSame("Incorrect parent or no parent set", exampleTable, pk.getParent());
assertEquals("id", pk.getColumnNames().get(0));
assertEquals(1, pk.getColumnOrders().get(0).intValue());
}
@Override
protected void doDatabaseSetup()
{
// Create database objects: this decouples test code from the actual schema which is
// free to change without breaking these tests.
final String[] createStatements = new String[]
{
"DROP TABLE IF EXISTS export_test_other CASCADE",
"DROP TABLE IF EXISTS export_test_example CASCADE",
"CREATE TABLE export_test_example" +
" (" +
" id BIGINT NOT NULL AUTO_INCREMENT," +
" description TEXT," +
" fixes_from_schema INTEGER," +
" fixes_to_schema INTEGER," +
" applied_to_schema INTEGER," +
" target_schema INTEGER," +
" applied_on_date DATETIME," +
" applied_to_server VARCHAR(64)," +
" was_executed BIT," +
" succeeded BIT," +
" report TEXT," +
" PRIMARY KEY (id)" +
" ) ENGINE=InnoDB",
"CREATE TABLE export_test_other" +
" (" +
" id BIGINT NOT NULL," +
" version BIGINT NOT NULL," +
" ex_id BIGINT NOT NULL," +
" local_name VARCHAR(200) NOT NULL," +
" CONSTRAINT export_test_fk_example FOREIGN KEY (ex_id) REFERENCES export_test_example (id)," +
" PRIMARY KEY (id)" +
" ) ENGINE=InnoDB",
"CREATE UNIQUE INDEX export_test_idx_other_1 ON export_test_other (ex_id, local_name)",
"CREATE INDEX export_test_idx_other_2 ON export_test_other (ex_id)"
};
TransactionTemplate tt = new TransactionTemplate(tx);
tt.execute(new TransactionCallbackWithoutResult()
{
@Override
protected void doInTransactionWithoutResult(TransactionStatus status)
{
for (String sql : createStatements)
{
jdbcTemplate.update(sql);
}
}
});
}
}