add test case and set supportsCascadeUpdateAction=false

This commit is contained in:
Enrico Olivelli 2020-10-27 17:10:33 +01:00
parent 02e91440e5
commit bb35ca7129
2 changed files with 73 additions and 0 deletions

View File

@ -32,6 +32,8 @@ public class HerdDBDictionary
schemaCase = SCHEMA_CASE_LOWER;
delimitedCase = SCHEMA_CASE_LOWER;
supportsCascadeUpdateAction = false;
// make OpenJPA escape everything, because Apache Calcite has a lot of reserved words, like 'User', 'Value'...
setDelimitIdentifiers(true);
setSupportsDelimitedIdentifiers(true);

View File

@ -0,0 +1,71 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.jdbc.sql;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.sql.DataSource;
import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
import org.apache.openjpa.kernel.StoreContext;
import org.jmock.Expectations;
import org.jmock.integration.junit4.JUnitRuleMockery;
import org.junit.Rule;
import org.junit.Test;
public class TestHerdDBDictionary {
@Rule
public JUnitRuleMockery context = new JUnitRuleMockery();
final JDBCConfiguration mockConfiguration = context.mock(JDBCConfiguration.class);
final Statement mockStatement = context.mock(Statement.class);
final Connection mockConnection = context.mock(Connection.class);
final ResultSet mockRS = context.mock(ResultSet.class);
final DataSource mockDS = context.mock(DataSource.class);
final DatabaseMetaData mockMetaData = context.mock(DatabaseMetaData.class);
final StoreContext sc = null;
@Test
public void testBootDBDictionary() throws Exception {
// Expected method calls on the mock objects above. If any of these are
// do not occur, or if any other methods are invoked on the mock objects
// an exception will be thrown and the test will fail.
context.checking(new Expectations()
{
{
allowing(mockConfiguration);
}
});
DBDictionary dict = new HerdDBDictionary();
dict.setConfiguration(mockConfiguration);
assertNull(dict.getDefaultSchemaName());
assertTrue(dict.supportsForeignKeys);
assertTrue(dict.supportsUniqueConstraints);
assertTrue(dict.supportsCascadeDeleteAction);
assertFalse(dict.supportsCascadeUpdateAction);
}
}