2
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License as
6
* published by the Free Software Foundation; version 2 of the
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20
#include "tut_stdafx.h"
28
#include "grt_test_utility.h"
29
#include "grts/structs.db.mgmt.h"
30
#include "grts/structs.db.mysql.h"
31
#include "grts/structs.workbench.physical.h"
32
#include "wb_mysql_import.h"
33
#include "grt/grt_manager.h"
34
#include "wb_mysql_import.h"
35
#include "wb_helpers.h"
40
BEGIN_TEST_DATA_CLASS(wb_mysql_import_dbd4)
43
WbMysqlImportImpl *module;
44
db_mgmt_RdbmsRef rdbms;
47
workbench_physical_ModelRef test_import_dbd4(int test_no);
51
TEST_MODULE(wb_mysql_import_dbd4, "WB module: import from DBD4");
58
module= grt->get_native_module<WbMysqlImportImpl>();
59
ensure("WbMysqlImport module initialization", NULL != module);
61
options= DictRef(grt);
62
options.set("gen_fk_names_when_empty", IntegerRef(0));
67
workbench_physical_ModelRef Test_object_base<wb_mysql_import_dbd4>::test_import_dbd4(int test_no)
69
ensure("WbMysqlImport module initialization", NULL != module);
71
static const char* TEST_DATA_DIR= "data/modules_grt/wb_mysql_import/dbd4/";
73
/* set filenames & messages based on test no. */
76
string test_message= "Model (" + oss.str() + ")";
77
string test_model_filename= TEST_DATA_DIR + oss.str() + ".xml";
78
string test_model_state_filename= TEST_DATA_DIR + oss.str() + "_test.xml";
79
string model_state_filename= TEST_DATA_DIR + oss.str() + "_res.xml";
83
wbt.create_new_document();
86
ensure_equals("loaded phys model count",
87
wbt.wb->get_document()->physicalModels().count(), 1U);
89
workbench_physical_ModelRef res_model= wbt.wb->get_document()->physicalModels().get(0);
90
module->importDBD4Ex(res_model, test_model_filename, options);
92
db_ColumnRef column(res_model->catalog()->schemata().get(0)->tables().get(0)->columns().get(0));
95
grt->serialize(res_model, model_state_filename);
98
res_model= workbench_physical_ModelRef::cast_from(grt->unserialize(model_state_filename));
99
workbench_physical_ModelRef test_model= workbench_physical_ModelRef::cast_from(grt->unserialize(test_model_state_filename));
102
grt_ensure_equals(test_message.c_str(), res_model, test_model);
125
// this model contains a table with an accented column. should be in UTF8 after imported
126
workbench_physical_ModelRef model= test_import_dbd4(3);
128
ensure("model imported", model.is_valid());
130
db_ColumnRef column(model->catalog()->schemata().get(0)->tables().get(0)->columns().get(0));
132
ensure("imported column name", g_utf8_validate(column->name().c_str(), strlen(column->name().c_str()), NULL) != 0);
134
ensure_equals("imported column name", *column->name(), "reuni\xc3\xb3n");