use of org.eclipse.persistence.tools.dbws.DBWSBuilder in project eclipselink by eclipse-ee4j.
the class SimplePLSQLSPTestSuite method setUp.
@BeforeClass
public static void setUp() throws WSDLException {
if (conn == null) {
try {
conn = buildConnection();
} catch (Exception e) {
e.printStackTrace();
}
}
String ddlCreateProp = System.getProperty(DATABASE_DDL_CREATE_KEY, DEFAULT_DATABASE_DDL_CREATE);
if ("true".equalsIgnoreCase(ddlCreateProp)) {
ddlCreate = true;
}
String ddlDropProp = System.getProperty(DATABASE_DDL_DROP_KEY, DEFAULT_DATABASE_DDL_DROP);
if ("true".equalsIgnoreCase(ddlDropProp)) {
ddlDrop = true;
}
String ddlDebugProp = System.getProperty(DATABASE_DDL_DEBUG_KEY, DEFAULT_DATABASE_DDL_DEBUG);
if ("true".equalsIgnoreCase(ddlDebugProp)) {
ddlDebug = true;
}
if (ddlCreate) {
runDdl(conn, CREATE_OBJECT_TYPE, ddlDebug);
runDdl(conn, CREATE_SIMPLEPACKAGE1_PACKAGE, ddlDebug);
runDdl(conn, CREATE_SIMPLEPACKAGE1_BODY, ddlDebug);
}
username = System.getProperty(DATABASE_USERNAME_KEY, DEFAULT_DATABASE_USERNAME);
DBWS_BUILDER_XML_USERNAME = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<dbws-builder xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" + "<properties>" + "<property name=\"projectName\">simplePLSQLSP</property>" + "<property name=\"logLevel\">off</property>" + "<property name=\"username\">";
DBWS_BUILDER_XML_PASSWORD = "</property><property name=\"password\">";
DBWS_BUILDER_XML_URL = "</property><property name=\"url\">";
DBWS_BUILDER_XML_DRIVER = "</property><property name=\"driver\">";
DBWS_BUILDER_XML_PLATFORM = "</property><property name=\"platformClassname\">";
DBWS_BUILDER_XML_MAIN = "</property>" + "</properties>" + "<plsql-procedure " + "name=\"VarcharTest\" " + "catalogPattern=\"SIMPLEPACKAGE1\" " + "procedurePattern=\"VARCHARPLSQLSP\" " + "/>" + "<plsql-procedure " + "name=\"NoArgsTest\" " + "catalogPattern=\"SIMPLEPACKAGE1\" " + "procedurePattern=\"NOARGPLSQLSP\" " + "/>" + "<plsql-procedure " + "name=\"InOutArgsTest\" " + "catalogPattern=\"SIMPLEPACKAGE1\" " + "procedurePattern=\"INOUTARGSPLSQLSP\" " + "/>" + "<plsql-procedure " + "name=\"InOutArgTest\" " + "catalogPattern=\"SIMPLEPACKAGE1\" " + "schemaPattern=\"" + username.toUpperCase() + "\" " + "procedurePattern=\"INOUTARGPLSQLSP\" " + "/>" + "<plsql-procedure " + "name=\"XMLTypeTest\" " + "catalogPattern=\"SIMPLEPACKAGE1\" " + "procedurePattern=\"GET_XMLTYPE\" " + "isSimpleXMLFormat=\"true\" " + "/>" + "</dbws-builder>";
builder = new DBWSBuilder();
DBWSTestSuite.setUp(".");
}
use of org.eclipse.persistence.tools.dbws.DBWSBuilder in project eclipselink by eclipse-ee4j.
the class SimpleTableWithNestedSQLTestSuite method checkWSDL.
@Test
public void checkWSDL() throws WSDLException {
DBWS_BUILDER_XML_USERNAME = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<dbws-builder xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" + "<properties>" + "<property name=\"projectName\">simpletable2</property>" + "<property name=\"logLevel\">off</property>" + "<property name=\"username\">";
DBWS_BUILDER_XML_PASSWORD = "</property><property name=\"password\">";
DBWS_BUILDER_XML_URL = "</property><property name=\"url\">";
DBWS_BUILDER_XML_DRIVER = "</property><property name=\"driver\">";
DBWS_BUILDER_XML_PLATFORM = "</property><property name=\"platformClassname\">";
DBWS_BUILDER_XML_MAIN = "</property>" + "</properties>" + "<table " + "schemaPattern=\"%\" " + "tableNamePattern=\"simpletable2\" " + ">" + "<sql " + "name=\"findByName\" " + "isCollection=\"true\" " + "returnType=\"simpletable2Type\" " + ">" + "<text><![CDATA[select * from SIMPLETABLE2 where NAME like ?]]></text>" + "<binding name=\"NAME\" type=\"xsd:string\"/>" + "</sql>" + "</table>" + "</dbws-builder>";
String username = System.getProperty(DATABASE_USERNAME_KEY, DEFAULT_DATABASE_USERNAME);
String password = System.getProperty(DATABASE_PASSWORD_KEY, DEFAULT_DATABASE_PASSWORD);
String url = System.getProperty(DATABASE_URL_KEY, DEFAULT_DATABASE_URL);
String builderString = DBWS_BUILDER_XML_USERNAME + username + DBWS_BUILDER_XML_PASSWORD + password + DBWS_BUILDER_XML_URL + url + DBWS_BUILDER_XML_DRIVER + DATABASE_DRIVER + DBWS_BUILDER_XML_PLATFORM + DATABASE_PLATFORM + DBWS_BUILDER_XML_MAIN;
XMLContext context = new XMLContext(new DBWSBuilderModelProject());
XMLUnmarshaller unmarshaller = context.createUnmarshaller();
DBWSBuilderModel builderModel = (DBWSBuilderModel) unmarshaller.unmarshal(new StringReader(builderString));
DBWSBuilder builder = new DBWSBuilder();
builder.quiet = true;
// builder.setLogLevel(SessionLog.FINE_LABEL);
builder.setLogLevel(SessionLog.OFF_LABEL);
builder.setPlatformClassname(DATABASE_PLATFORM);
builder.properties = builderModel.properties;
builder.getProperties().put(SESSIONS_FILENAME_KEY, NO_SESSIONS_FILENAME);
builder.operations = builderModel.operations;
builder.setPackager(new JSR109WebServicePackager(null, "WebServiceTestPackager", noArchive) {
@Override
public void start() {
// do nothing - don't have to verify existence of 'stageDir' when
// all the streams are in-memory
}
});
ByteArrayOutputStream dbwsServiceStream = new ByteArrayOutputStream();
ByteArrayOutputStream wsdlStream = new ByteArrayOutputStream();
builder.build(__nullStream, __nullStream, dbwsServiceStream, __nullStream, __nullStream, __nullStream, __nullStream, wsdlStream, __nullStream, __nullStream, __nullStream, __nullStream, null);
// for the nested sql operation 'findByName'
try {
StringWriter sw = new StringWriter();
StreamSource wsdlStreamSource = new StreamSource(new StringReader(wsdlStream.toString()));
Transformer t = TransformerFactory.newInstance().newTransformer(new StreamSource(new StringReader(MATCH_SCHEMA)));
StreamResult streamResult = new StreamResult(sw);
t.transform(wsdlStreamSource, streamResult);
sw.toString();
SchemaModelProject schemaProject = new SchemaModelProject();
XMLContext xmlContext2 = new XMLContext(schemaProject);
unmarshaller = xmlContext2.createUnmarshaller();
Schema schema = (Schema) unmarshaller.unmarshal(new StringReader(sw.toString()));
ComplexType findByNameResponseType = schema.getTopLevelComplexTypes().get(FINDBYNAME_RESPONSETYPE);
Element result = findByNameResponseType.getSequence().getElements().get(0);
Element unnamed = result.getComplexType().getSequence().getElements().get(0);
assertTrue("wrong refType for " + FINDBYNAME_RESPONSETYPE, TABLE_ALIAS.equals(unnamed.getRef()));
} catch (Exception e) {
fail(e.getMessage());
}
}
use of org.eclipse.persistence.tools.dbws.DBWSBuilder in project eclipselink by eclipse-ee4j.
the class DBWSTestSuite method setUp.
/**
* This method should be used when sessions xml is to be generated and written out
* to DBWS_SESSION_STREAM.
*
* @param stageDir sessions xml will be generated and written out if non-null
*/
public static void setUp(String stageDir, boolean useLogger) throws WSDLException {
comparer.setIgnoreOrder(true);
if (builder == null) {
builder = new DBWSBuilder();
}
DBWS_SERVICE_STREAM = new ByteArrayOutputStream();
DBWS_SCHEMA_STREAM = new ByteArrayOutputStream();
DBWS_SESSION_STREAM = new ByteArrayOutputStream();
DBWS_OR_STREAM = new ByteArrayOutputStream();
DBWS_OX_STREAM = new ByteArrayOutputStream();
DBWS_WSDL_STREAM = new ByteArrayOutputStream();
final String username = System.getProperty(DATABASE_USERNAME_KEY, DEFAULT_DATABASE_USERNAME);
final String password = System.getProperty(DATABASE_PASSWORD_KEY, DEFAULT_DATABASE_PASSWORD);
final String url = System.getProperty(DATABASE_URL_KEY, DEFAULT_DATABASE_URL);
String builderString = DBWS_BUILDER_XML_USERNAME + username + DBWS_BUILDER_XML_PASSWORD + password + DBWS_BUILDER_XML_URL + url + DBWS_BUILDER_XML_DRIVER + DATABASE_DRIVER + DBWS_BUILDER_XML_PLATFORM + DATABASE_PLATFORM + DBWS_BUILDER_XML_MAIN;
XMLContext context = new XMLContext(new DBWSBuilderModelProject());
XMLUnmarshaller unmarshaller = context.createUnmarshaller();
DBWSBuilderModel builderModel = (DBWSBuilderModel) unmarshaller.unmarshal(new StringReader(builderString));
builder.quiet = true;
builder.setPlatformClassname(DATABASE_PLATFORM);
builder.properties = builderModel.properties;
builder.operations = builderModel.operations;
XRPackager xrPackager = new JSR109WebServicePackager(null, "WebServiceTestPackager", noArchive) {
@Override
public void start() {
// do nothing - don't have to verify existence of 'stageDir' when
// all the streams are in-memory
}
};
xrPackager.setDBWSBuilder(builder);
builder.setPackager(xrPackager);
builder.setPackager(xrPackager);
dbwsLogger = null;
if (useLogger) {
dbwsLogger = new DBWSLogger("DBWSTestLogger", null);
}
if (stageDir == null) {
builder.getProperties().put(SESSIONS_FILENAME_KEY, NO_SESSIONS_FILENAME);
builder.build(DBWS_SCHEMA_STREAM, __nullStream, DBWS_SERVICE_STREAM, DBWS_OR_STREAM, DBWS_OX_STREAM, __nullStream, __nullStream, __nullStream, __nullStream, __nullStream, __nullStream, __nullStream, dbwsLogger);
} else {
xrPackager.setStageDir(new File(stageDir));
builder.build(DBWS_SCHEMA_STREAM, DBWS_SESSION_STREAM, DBWS_SERVICE_STREAM, DBWS_OR_STREAM, DBWS_OX_STREAM, __nullStream, __nullStream, DBWS_WSDL_STREAM, __nullStream, __nullStream, __nullStream, __nullStream, dbwsLogger);
}
XRServiceFactory factory = new XRServiceFactory() {
@Override
public XRServiceAdapter buildService(XRServiceModel xrServiceModel) {
parentClassLoader = this.getClass().getClassLoader();
xrSchemaStream = new ByteArrayInputStream(DBWS_SCHEMA_STREAM.toByteArray());
return super.buildService(xrServiceModel);
}
@Override
public void buildSessions() {
XRDynamicClassLoader xrdecl = new XRDynamicClassLoader(parentClassLoader);
DatasourceLogin login = new DatabaseLogin();
login.setUserName(username);
login.setPassword(password);
((DatabaseLogin) login).setConnectionString(url);
((DatabaseLogin) login).setDriverClassName(DATABASE_PLATFORM);
Platform platform = builder.getDatabasePlatform();
ConversionManager conversionManager = platform.getConversionManager();
if (conversionManager != null) {
conversionManager.setLoader(xrdecl);
}
login.setDatasourcePlatform(platform);
((DatabaseLogin) login).bindAllParameters();
Project orProject = null;
if (DBWS_OR_STREAM.size() != 0) {
MetadataProcessor processor = new MetadataProcessor(new XRPersistenceUnitInfo(xrdecl), new DatabaseSessionImpl(login), xrdecl, false, true, false, false, false, null, null);
processor.setMetadataSource(new JPAMetadataSource(xrdecl, new StringReader(DBWS_OR_STREAM.toString())));
PersistenceUnitProcessor.processORMetadata(processor, true, PersistenceUnitProcessor.Mode.ALL);
processor.addNamedQueries();
orProject = processor.getProject().getProject();
} else {
orProject = new Project();
}
orProject.setName(builder.getProjectName().concat(OR_PRJ_SUFFIX));
orProject.setDatasourceLogin(login);
DatabaseSession databaseSession = orProject.createDatabaseSession();
if ("off".equalsIgnoreCase(builder.getLogLevel())) {
databaseSession.dontLogMessages();
} else {
databaseSession.setLogLevel(AbstractSessionLog.translateStringToLoggingLevel(builder.getLogLevel()));
}
xrService.setORSession(databaseSession);
orProject.convertClassNamesToClasses(xrdecl);
Project oxProject = null;
if (DBWS_OX_STREAM.size() != 0) {
Map<String, OXMMetadataSource> metadataMap = new HashMap<String, OXMMetadataSource>();
StreamSource xml = new StreamSource(new StringReader(DBWS_OX_STREAM.toString()));
try {
JAXBContext jc = JAXBContext.newInstance(XmlBindingsModel.class);
Unmarshaller unmarshaller = jc.createUnmarshaller();
JAXBElement<XmlBindingsModel> jaxbElt = unmarshaller.unmarshal(xml, XmlBindingsModel.class);
XmlBindingsModel model = jaxbElt.getValue();
for (XmlBindings xmlBindings : model.getBindingsList()) {
metadataMap.put(xmlBindings.getPackageName(), new OXMMetadataSource(xmlBindings));
}
} catch (JAXBException jaxbex) {
jaxbex.printStackTrace();
}
Map<String, Map<String, OXMMetadataSource>> properties = new HashMap<String, Map<String, OXMMetadataSource>>();
properties.put(JAXBContextProperties.OXM_METADATA_SOURCE, metadataMap);
try {
org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext jCtx = org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContextFactory.createContextFromOXM(xrdecl, properties);
oxProject = jCtx.getXMLContext().getSession(0).getProject();
} catch (JAXBException e) {
e.printStackTrace();
}
} else {
oxProject = new Project();
}
oxProject.setName(builder.getProjectName().concat(OX_PRJ_SUFFIX));
login = (DatasourceLogin) oxProject.getDatasourceLogin();
if (login != null) {
platform = login.getDatasourcePlatform();
if (platform != null) {
conversionManager = platform.getConversionManager();
if (conversionManager != null) {
conversionManager.setLoader(xrdecl);
}
}
}
prepareDescriptors(oxProject, orProject, xrdecl);
ProjectHelper.fixOROXAccessors(orProject, oxProject);
xrService.setORSession(orProject.createDatabaseSession());
xrService.getORSession().dontLogMessages();
xrService.setXMLContext(new XMLContext(oxProject));
xrService.setOXSession(xrService.getXMLContext().getSession(0));
}
};
context = new XMLContext(new DBWSModelProject());
unmarshaller = context.createUnmarshaller();
DBWSModel model = (DBWSModel) unmarshaller.unmarshal(new StringReader(DBWS_SERVICE_STREAM.toString()));
xrService = factory.buildService(model);
}
use of org.eclipse.persistence.tools.dbws.DBWSBuilder in project eclipselink by eclipse-ee4j.
the class DBWSTestSuite method build.
public static void build(String projectName, String builderFile, boolean useLogger) throws WSDLException {
String[] builderArgs = new String[] { "-builderFile", builderFile, "-stageDir", stageDir, "-packageAs", serverPlatform, projectName + ".war" };
builder = new DBWSBuilder();
builder.start(builderArgs);
}
use of org.eclipse.persistence.tools.dbws.DBWSBuilder in project eclipselink by eclipse-ee4j.
the class StrongRefCursorTestSuite method setUp.
@BeforeClass
public static void setUp() throws WSDLException {
if (conn == null) {
try {
conn = buildConnection();
} catch (Exception e) {
e.printStackTrace();
}
}
String ddlCreateProp = System.getProperty(DATABASE_DDL_CREATE_KEY, DEFAULT_DATABASE_DDL_CREATE);
if ("true".equalsIgnoreCase(ddlCreateProp)) {
ddlCreate = true;
}
String ddlDropProp = System.getProperty(DATABASE_DDL_DROP_KEY, DEFAULT_DATABASE_DDL_DROP);
if ("true".equalsIgnoreCase(ddlDropProp)) {
ddlDrop = true;
}
String ddlDebugProp = System.getProperty(DATABASE_DDL_DEBUG_KEY, DEFAULT_DATABASE_DDL_DEBUG);
if ("true".equalsIgnoreCase(ddlDebugProp)) {
ddlDebug = true;
}
if (ddlCreate) {
runDdl(conn, CREATE_STRONGLY_TYPED_REF_CURSOR_TABLE, ddlDebug);
try {
Statement stmt = conn.createStatement();
for (int i = 0; i < POPULATE_STRONGLY_TYPED_REF_CURSOR_TABLE.length; i++) {
stmt.addBatch(POPULATE_STRONGLY_TYPED_REF_CURSOR_TABLE[i]);
}
stmt.executeBatch();
} catch (SQLException e) {
// e.printStackTrace();
}
runDdl(conn, CREATE_TAB1_SHADOW_TYPE, ddlDebug);
runDdl(conn, CREATE_STRC_CURSOR_SHADOW_TYPE, ddlDebug);
runDdl(conn, CREATE_STRONGLY_TYPED_REF_CURSOR_TEST_PACKAGE, ddlDebug);
runDdl(conn, CREATE_STRONGLY_TYPED_REF_CURSOR_TEST_PACKAGE_BODY, ddlDebug);
}
username = System.getProperty(DATABASE_USERNAME_KEY, DEFAULT_DATABASE_USERNAME);
DBWS_BUILDER_XML_USERNAME = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<dbws-builder xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" + "<properties>" + "<property name=\"projectName\">strongRefCursor</property>" + "<property name=\"logLevel\">off</property>" + "<property name=\"username\">";
DBWS_BUILDER_XML_PASSWORD = "</property><property name=\"password\">";
DBWS_BUILDER_XML_URL = "</property><property name=\"url\">";
DBWS_BUILDER_XML_DRIVER = "</property><property name=\"driver\">";
DBWS_BUILDER_XML_PLATFORM = "</property><property name=\"platformClassname\">";
DBWS_BUILDER_XML_MAIN = "</property>" + "</properties>" + "<plsql-procedure " + "name=\"strongRefCursorTest\" " + "catalogPattern=\"" + STRONGLY_TYPED_REF_CURSOR_TEST_PACKAGE + "\" " + "procedurePattern=\"GET_EMS\" " + "isCollection=\"true\" " + "isSimpleXMLFormat=\"true\" " + "/>" + "<plsql-procedure " + "name=\"strongRefCursorTest2\" " + "catalogPattern=\"" + STRONGLY_TYPED_REF_CURSOR_TEST_PACKAGE + "\" " + "procedurePattern=\"GET_EMS2\" " + "isCollection=\"true\" " + "isSimpleXMLFormat=\"true\" " + "/>" + "<plsql-procedure " + "name=\"emprecRefCursorTest\" " + "catalogPattern=\"" + STRONGLY_TYPED_REF_CURSOR_TEST_PACKAGE + "\" " + "procedurePattern=\"GET_EMPREC\" " + "isCollection=\"true\" " + "isSimpleXMLFormat=\"true\" " + "/>" + "<plsql-procedure " + "name=\"emprecRefCursorTest2\" " + "catalogPattern=\"" + STRONGLY_TYPED_REF_CURSOR_TEST_PACKAGE + "\" " + "procedurePattern=\"GET_EMPREC2\" " + "isCollection=\"true\" " + "isSimpleXMLFormat=\"true\" " + "/>" + "<plsql-procedure " + "name=\"strongRefCursorTestFunc\" " + "catalogPattern=\"" + STRONGLY_TYPED_REF_CURSOR_TEST_PACKAGE + "\" " + "procedurePattern=\"GET_EMS_FUNC\" " + "isCollection=\"true\" " + "isSimpleXMLFormat=\"true\" " + "/>" + "<plsql-procedure " + "name=\"strongRefCursorTest2Func\" " + "catalogPattern=\"" + STRONGLY_TYPED_REF_CURSOR_TEST_PACKAGE + "\" " + "procedurePattern=\"GET_EMS2_FUNC\" " + "isCollection=\"true\" " + "isSimpleXMLFormat=\"true\" " + "/>" + "<plsql-procedure " + "name=\"emprecRefCursorTestFunc\" " + "catalogPattern=\"" + STRONGLY_TYPED_REF_CURSOR_TEST_PACKAGE + "\" " + "procedurePattern=\"GET_EMPREC_FUNC\" " + "isCollection=\"true\" " + "isSimpleXMLFormat=\"true\" " + "/>" + "<plsql-procedure " + "name=\"emprecRefCursorTest2Func\" " + "catalogPattern=\"" + STRONGLY_TYPED_REF_CURSOR_TEST_PACKAGE + "\" " + "procedurePattern=\"GET_EMPREC2_FUNC\" " + "isCollection=\"true\" " + "isSimpleXMLFormat=\"true\" " + "/>" + "</dbws-builder>";
builder = new DBWSBuilder();
DBWSTestSuite.setUp(".");
}
Aggregations