details: https://code.openbravo.com/erp/devel/pi/rev/c497a8e94c0e
changeset: 22762:c497a8e94c0e
user: Asier Lostalé <asier.lostale <at> openbravo.com>
date: Mon Mar 24 13:23:03 2014 +0100
summary: fixed issue 26069: run.webservice.tests has the openbravo url
hardcoded
URL is retrieved now from context.url property in Openbravo.properties
diffstat:
src-test/org/openbravo/test/webservice/BaseWSTest.java | 23 ++++++-
src-test/org/openbravo/test/webservice/PerformanceTest.java | 39 +------------
2 files changed, 21 insertions(+), 41 deletions(-)
diffs (129 lines):
diff -r 8780b0463263 -r c497a8e94c0e
src-test/org/openbravo/test/webservice/BaseWSTest.java
--- a/src-test/org/openbravo/test/webservice/BaseWSTest.java Mon Mar 24
16:33:35 2014 +0530
+++ b/src-test/org/openbravo/test/webservice/BaseWSTest.java Mon Mar 24
13:23:03 2014 +0100
@@ -30,6 +30,7 @@
import java.net.HttpURLConnection;
import java.net.PasswordAuthentication;
import java.net.URL;
+import java.util.Properties;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
@@ -38,10 +39,13 @@
import javax.xml.validation.SchemaFactory;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.dom4j.Document;
import org.dom4j.io.SAXReader;
import org.openbravo.base.exception.OBException;
+import org.openbravo.base.provider.OBConfigFileProvider;
+import org.openbravo.base.session.OBPropertiesProvider;
import org.openbravo.dal.xml.XMLUtil;
import org.openbravo.test.base.BaseTest;
import org.xml.sax.ErrorHandler;
@@ -59,10 +63,10 @@
public class BaseWSTest extends BaseTest {
private static final Logger log = Logger.getLogger(BaseWSTest.class);
-
- private static final String OB_URL = "http://localhost:8081/openbravo";
- private static final String LOGIN = "Openbravo";
- private static final String PWD = "openbravo";
+ private static final String CONTEXT_PROPERTY = "context.url";
+ private static String OB_URL = null;
+ protected static final String LOGIN = "Openbravo";
+ protected static final String PWD = "openbravo";
private String xmlSchema = null;
@@ -302,6 +306,17 @@
* @return the url of the Openbravo instance.
*/
protected String getOpenbravoURL() {
+ if (OB_URL != null) {
+ return OB_URL;
+ }
+ Properties props =
OBPropertiesProvider.getInstance().getOpenbravoProperties();
+ System.out.println(OBConfigFileProvider.getInstance().getFileLocation());
+ OB_URL = props.getProperty(CONTEXT_PROPERTY);
+ if (StringUtils.isEmpty(OB_URL)) {
+ throw new OBException(CONTEXT_PROPERTY + " is not set in
Openbravo.properties");
+ }
+ log.debug("got OB context: " + OB_URL);
+
return OB_URL;
}
diff -r 8780b0463263 -r c497a8e94c0e
src-test/org/openbravo/test/webservice/PerformanceTest.java
--- a/src-test/org/openbravo/test/webservice/PerformanceTest.java Mon Mar
24 16:33:35 2014 +0530
+++ b/src-test/org/openbravo/test/webservice/PerformanceTest.java Mon Mar
24 13:23:03 2014 +0100
@@ -11,7 +11,7 @@
* under the License.
* The Original Code is Openbravo ERP.
* The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2009-2010 Openbravo SLU
+ * All portions are Copyright (C) 2009-2014 Openbravo SLU
* All Rights Reserved.
* Contributor(s): ______________________________________.
************************************************************************
@@ -29,7 +29,6 @@
import org.apache.log4j.Logger;
import org.openbravo.base.exception.OBException;
-import org.openbravo.test.base.BaseTest;
/**
* Test class for reading large xml files from a webservice. Xml is streamed
directly to a file.
@@ -40,14 +39,9 @@
* @author mtaal
*/
-public class PerformanceTest extends BaseTest {
-
+public class PerformanceTest extends BaseWSTest {
private static final Logger log = Logger.getLogger(PerformanceTest.class);
- private static final String OB_URL = "http://localhost:8080/openbravo";
- private static final String LOGIN = "Openbravo";
- private static final String PWD = "openbravo";
-
public void testPerformance() {
try {
final HttpURLConnection hc = createConnection(
@@ -105,33 +99,4 @@
hc.setRequestProperty("Content-Type", "text/xml");
return hc;
}
-
- /**
- * Returns the url of the Openbravo instance. The default value is: {@link
#OB_URL}
- *
- * @return the url of the Openbravo instance.
- */
- protected String getOpenbravoURL() {
- return OB_URL;
- }
-
- /**
- * Returns the login used to login for the webservice. The default value is
{@link #LOGIN}.
- *
- * @return the login name used to login for the webservice
- */
- protected String getLogin() {
- return LOGIN;
- }
-
- /**
- * Returns the password used to login into the webservice server. The
default value is
- * {@link #PWD}.
- *
- * @return the password used to login into the webservice, the default is
{@link #PWD}
- */
- protected String getPassword() {
- return PWD;
- }
-
}
\ No newline at end of file
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits