blob: b0ea5cff4acb23479bcdd028ee596ed71cfdcbbd [file] [log] [blame]
/*
* Copyright (c) 2011, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0,
* or the Eclipse Distribution License v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
// Contributors:
// David McCann - September 06, 2011 - 2.4 - Initial implementation
package dbws.testing.verylongidentifier;
//javase imports
import java.io.StringReader;
import org.w3c.dom.Document;
//java eXtension imports
import javax.wsdl.WSDLException;
//JUnit4 imports
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
//EclipseLink imports
import org.eclipse.persistence.internal.xr.Invocation;
import org.eclipse.persistence.internal.xr.Operation;
import org.eclipse.persistence.oxm.XMLMarshaller;
import org.eclipse.persistence.tools.dbws.DBWSBuilder;
//test imports
import dbws.testing.DBWSTestSuite;
/**
* Tests PL/SQL procedures with simple arguments.
*
*/
public class VeryLongIdentifierTestSuite extends DBWSTestSuite {
static final String CREATE_LONGIDENTIFIER_PACKAGE =
"CREATE OR REPLACE PACKAGE LONGIDENTIFIERPACKAGE AS" +
"\nPROCEDURE PLONG(THIS_IS_A_LONG_PLSQL_IDENTIFIE IN BOOLEAN);" +
"\nEND LONGIDENTIFIERPACKAGE;";
static final String CREATE_LONGIDENTIFIERPACKAGE_BODY =
"CREATE OR REPLACE PACKAGE BODY LONGIDENTIFIERPACKAGE AS" +
"\nPROCEDURE PLONG(THIS_IS_A_LONG_PLSQL_IDENTIFIE IN BOOLEAN) AS" +
"\nBEGIN" +
"\nnull;" +
"\nEND PLONG;" +
"\nEND LONGIDENTIFIERPACKAGE;";
static final String DROP_LONGIDENTIFIERPACKAGE =
"DROP PACKAGE LONGIDENTIFIERPACKAGE";
static boolean ddlCreate = false;
static boolean ddlDrop = false;
static boolean ddlDebug = false;
@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_LONGIDENTIFIER_PACKAGE, ddlDebug);
runDdl(conn, CREATE_LONGIDENTIFIERPACKAGE_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\">longPLSQLIdentifier</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=\"longIdentifierTest\" " +
"catalogPattern=\"LONGIDENTIFIERPACKAGE\" " +
"procedurePattern=\"PLONG\" " +
"returnType=\"xsd:int\" " +
"/>" +
"</dbws-builder>";
builder = new DBWSBuilder();
DBWSTestSuite.setUp(".");
}
@AfterClass
public static void tearDown() {
if (ddlDrop) {
runDdl(conn, DROP_LONGIDENTIFIERPACKAGE, ddlDebug);
}
}
@Test
public void longIdentifierTest() {
Invocation invocation = new Invocation("longIdentifierTest");
invocation.setParameter("THIS_IS_A_LONG_PLSQL_IDENTIFIE", 1);
Operation op = xrService.getOperation(invocation.getName());
Object result = op.invoke(xrService, invocation);
assertNotNull("result is null", result);
Document doc = xmlPlatform.createDocument();
XMLMarshaller marshaller = xrService.getXMLContext().createMarshaller();
marshaller.marshal(result, doc);
Document controlDoc = xmlParser.parse(new StringReader(VALUE_1_XML));
assertTrue("Expected:\n" + documentToString(controlDoc) + "\nActual:\n" + documentToString(doc), comparer.isNodeEqual(controlDoc, doc));
}
public static final String VALUE_1_XML =
REGULAR_XML_HEADER +
"<value>1</value>";
}