use of org.eclipse.persistence.platform.database.MySQLPlatform in project eclipselink by eclipse-ee4j.
the class KeyMappingsTestSuite method setUp.
@BeforeClass
public static void setUp() {
final String ddlCreateProp = System.getProperty(DATABASE_DDL_CREATE_KEY, DEFAULT_DATABASE_DDL_CREATE);
if ("true".equalsIgnoreCase(ddlCreateProp)) {
ddlCreate = true;
}
final String ddlDropProp = System.getProperty(DATABASE_DDL_DROP_KEY, DEFAULT_DATABASE_DDL_DROP);
if ("true".equalsIgnoreCase(ddlDropProp)) {
ddlDrop = true;
}
final String ddlDebugProp = System.getProperty(DATABASE_DDL_DEBUG_KEY, DEFAULT_DATABASE_DDL_DEBUG);
if ("true".equalsIgnoreCase(ddlDebugProp)) {
ddlDebug = true;
}
final String username = System.getProperty(DATABASE_USERNAME_KEY);
if (username == null) {
fail("error retrieving database username");
}
final String password = System.getProperty(DATABASE_PASSWORD_KEY);
if (password == null) {
fail("error retrieving database password");
}
final String url = System.getProperty(DATABASE_URL_KEY);
if (url == null) {
fail("error retrieving database url");
}
final String driver = System.getProperty(DATABASE_DRIVER_KEY);
if (driver == null) {
fail("error retrieving database driver");
}
XRServiceFactory factory = new XRServiceFactory() {
@Override
public XRServiceAdapter buildService(XRServiceModel xrServiceModel) {
parentClassLoader = this.getClass().getClassLoader();
xrSchemaStream = new ByteArrayInputStream(KEYMAPPINGS_SCHEMA.getBytes());
return super.buildService(xrServiceModel);
}
@Override
public void buildSessions() {
XRDynamicClassLoader xrdecl = new XRDynamicClassLoader(parentClassLoader);
XMLContext context = new XMLContext(new EclipseLinkObjectPersistenceRuntimeXMLProject(), xrdecl);
XMLUnmarshaller unmarshaller = context.createUnmarshaller();
Project orProject = (Project) unmarshaller.unmarshal(new StringReader(KEYMAPPINGS_OR_PROJECT));
DatasourceLogin login = new DatabaseLogin();
login.setUserName(username);
login.setPassword(password);
((DatabaseLogin) login).setConnectionString(url);
((DatabaseLogin) login).setDriverClassName(driver);
Platform platform = new MySQLPlatform();
ConversionManager conversionManager = platform.getConversionManager();
if (conversionManager != null) {
conversionManager.setLoader(xrdecl);
}
login.setDatasourcePlatform(platform);
((DatabaseLogin) login).bindAllParameters();
orProject.setDatasourceLogin(login);
Project oxProject = (Project) unmarshaller.unmarshal(new StringReader(KEYMAPPINGS_OX_PROJECT));
login = (DatasourceLogin) oxProject.getDatasourceLogin();
if (login != null) {
platform = login.getDatasourcePlatform();
if (platform != null) {
conversionManager = platform.getConversionManager();
if (conversionManager != null) {
conversionManager.setLoader(xrdecl);
}
}
}
ProjectHelper.fixOROXAccessors(orProject, oxProject);
xrService.setORSession(orProject.createDatabaseSession());
xrService.getORSession().dontLogMessages();
xrService.setXMLContext(new XMLContext(oxProject));
xrService.setOXSession(xrService.getXMLContext().getSession(0));
}
};
XMLContext context = new XMLContext(new DBWSModelProject());
XMLUnmarshaller unmarshaller = context.createUnmarshaller();
DBWSModel model = (DBWSModel) unmarshaller.unmarshal(new StringReader(KEYMAPPINGS_DBWS));
xrService = factory.buildService(model);
if (ddlCreate) {
try {
AllTests.runDdl(CREATE_DDL, ddlDebug);
} catch (Exception e) {
// e.printStackTrace();
}
}
}
use of org.eclipse.persistence.platform.database.MySQLPlatform in project eclipselink by eclipse-ee4j.
the class RelationshipsTestSuite method setUp.
@BeforeClass
public static void setUp() {
final String ddlCreateProp = System.getProperty(DATABASE_DDL_CREATE_KEY, DEFAULT_DATABASE_DDL_CREATE);
if ("true".equalsIgnoreCase(ddlCreateProp)) {
ddlCreate = true;
}
final String ddlDropProp = System.getProperty(DATABASE_DDL_DROP_KEY, DEFAULT_DATABASE_DDL_DROP);
if ("true".equalsIgnoreCase(ddlDropProp)) {
ddlDrop = true;
}
final String ddlDebugProp = System.getProperty(DATABASE_DDL_DEBUG_KEY, DEFAULT_DATABASE_DDL_DEBUG);
if ("true".equalsIgnoreCase(ddlDebugProp)) {
ddlDebug = true;
}
final String username = System.getProperty(DATABASE_USERNAME_KEY);
if (username == null) {
fail("error retrieving database username");
}
final String password = System.getProperty(DATABASE_PASSWORD_KEY);
if (password == null) {
fail("error retrieving database password");
}
final String url = System.getProperty(DATABASE_URL_KEY);
if (url == null) {
fail("error retrieving database url");
}
final String driver = System.getProperty(DATABASE_DRIVER_KEY);
if (driver == null) {
fail("error retrieving database driver");
}
XRServiceFactory factory = new XRServiceFactory() {
@Override
public XRServiceAdapter buildService(XRServiceModel xrServiceModel) {
parentClassLoader = this.getClass().getClassLoader();
xrSchemaStream = new ByteArrayInputStream(RELATIONSHIPS_SCHEMA.getBytes());
return super.buildService(xrServiceModel);
}
@Override
public void buildSessions() {
XMLContext context = new XMLContext(new EclipseLinkObjectPersistenceRuntimeXMLProject());
XMLUnmarshaller unmarshaller = context.createUnmarshaller();
Project orProject = (Project) unmarshaller.unmarshal(new StringReader(RELATIONSHIPS_OR_PROJECT));
DatabaseLogin login = new DatabaseLogin();
login.setUserName(username);
login.setPassword(password);
login.setConnectionString(url);
login.setDriverClassName(driver);
Platform platform = new MySQLPlatform();
login.setDatasourcePlatform(platform);
login.bindAllParameters();
orProject.setDatasourceLogin(login);
Project oxProject = (Project) unmarshaller.unmarshal(new StringReader(RELATIONSHIPS_OX_PROJECT));
ProjectHelper.fixOROXAccessors(orProject, oxProject);
xrService.setORSession(orProject.createDatabaseSession());
xrService.getORSession().dontLogMessages();
xrService.setXMLContext(new XMLContext(oxProject));
xrService.setOXSession(xrService.getXMLContext().getSession(0));
}
};
XMLContext context = new XMLContext(new DBWSModelProject());
XMLUnmarshaller unmarshaller = context.createUnmarshaller();
DBWSModel model = (DBWSModel) unmarshaller.unmarshal(new StringReader(RELATIONSHIPS_DBWS));
xrService = factory.buildService(model);
if (ddlCreate) {
try {
AllTests.runDdl(CREATE_DDL, ddlDebug);
} catch (Exception e) {
// e.printStackTrace();
}
}
}
use of org.eclipse.persistence.platform.database.MySQLPlatform in project eclipselink by eclipse-ee4j.
the class TestPropertiesUtils method testInvalidConfiguration.
@Test
public void testInvalidConfiguration() {
MySQLPlatform db = new MySQLPlatform();
try {
PropertiesUtils.set(db, "eclipselink.target-database", "ShouldForceFieldNamesToUpperCase");
Assert.fail();
} catch (ConversionException ce) {
// expected
}
try {
PropertiesUtils.set(db, "eclipselink.target-database", "==");
Assert.fail();
} catch (ConversionException ce) {
// expected
}
try {
PropertiesUtils.set(db, "eclipselink.target-database", "");
} catch (ConversionException ce) {
Assert.fail();
}
try {
PropertiesUtils.set(db, "eclipselink.target-database", ",,ShouldForceFieldNamesToUpperCase=true");
Assert.fail();
} catch (ConversionException ce) {
// expected
}
}
Aggregations