aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Vojtek2014-07-26 09:05:12 (EDT)
committerLukas Jungmann2014-07-30 12:00:58 (EDT)
commitb310154b92518c0fa88768bbeb7e8fad5f7c8691 (patch)
tree223d3300e4f0e97a6f5dfa7f87de65f1230e5f02
parent631fafcfa10b70563742dd939e2832cd9c44ea8d (diff)
downloadeclipselink.runtime-b310154b92518c0fa88768bbeb7e8fad5f7c8691.zip
eclipselink.runtime-b310154b92518c0fa88768bbeb7e8fad5f7c8691.tar.gz
eclipselink.runtime-b310154b92518c0fa88768bbeb7e8fad5f7c8691.tar.bz2
Fixed MOXy and SDO tests on JDK7.
Signed-off-by: Martin Vojtek <martin.vojtek@oracle.com>
-rw-r--r--moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmlschematype/EmployeeDate.java4
-rw-r--r--moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmlschematype/EmployeeTwoDates.java4
-rw-r--r--moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directtofield/typeattribute/Employee.java7
-rw-r--r--sdo/eclipselink.sdo.test/src/org/eclipse/persistence/testing/sdo/helper/datahelper/DataHelperConvertFromStringTest.java6
-rw-r--r--sdo/eclipselink.sdo.test/src/org/eclipse/persistence/testing/sdo/helper/datahelper/DataHelperToCalendarTest.java18
-rw-r--r--sdo/eclipselink.sdo.test/src/org/eclipse/persistence/testing/sdo/helper/datahelper/DataHelperToCalendarWithLocale.java4
-rw-r--r--sdo/eclipselink.sdo.test/src/org/eclipse/persistence/testing/sdo/helper/datahelper/DataHelperToDateTest.java22
-rw-r--r--sdo/eclipselink.sdo.test/src/org/eclipse/persistence/testing/sdo/util/CompileUtil.java43
8 files changed, 75 insertions, 33 deletions
diff --git a/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmlschematype/EmployeeDate.java b/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmlschematype/EmployeeDate.java
index cf866f6..9e385c9 100644
--- a/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmlschematype/EmployeeDate.java
+++ b/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmlschematype/EmployeeDate.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 1998, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
@@ -28,7 +28,7 @@ public class EmployeeDate {
if(startDate == null){
return ((EmployeeDate)o).startDate == null;
}else{
- return ((EmployeeDate)o).startDate.equals(this.startDate);
+ return ((EmployeeDate)o).startDate.getTimeInMillis() == this.startDate.getTimeInMillis();
}
}
}
diff --git a/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmlschematype/EmployeeTwoDates.java b/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmlschematype/EmployeeTwoDates.java
index 9914bf6..a106518 100644
--- a/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmlschematype/EmployeeTwoDates.java
+++ b/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/jaxb/xmlschematype/EmployeeTwoDates.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 1998, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
@@ -32,7 +32,7 @@ public class EmployeeTwoDates {
if(!(o instanceof EmployeeTwoDates) || o == null) {
return false;
} else {
- return ((EmployeeTwoDates)o).startDate.equals(this.startDate) && ((EmployeeTwoDates)o).startTime.equals(startTime);
+ return ((EmployeeTwoDates)o).startDate.getTimeInMillis() == this.startDate.getTimeInMillis() && ((EmployeeTwoDates)o).startTime.getTimeInMillis() == startTime.getTimeInMillis();
}
}
diff --git a/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directtofield/typeattribute/Employee.java b/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directtofield/typeattribute/Employee.java
index 0f6a636..13f4dfd 100644
--- a/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directtofield/typeattribute/Employee.java
+++ b/moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directtofield/typeattribute/Employee.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 1998, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
@@ -49,6 +49,11 @@ public class Employee {
public boolean equals(Object object) {
try {
Employee employee = (Employee) object;
+ if (null != this.getIdentifier() && null != employee.getIdentifier() && this.getIdentifier() instanceof java.util.Calendar && employee.getIdentifier() instanceof java.util.Calendar) {
+ if (((java.util.Calendar)this.getIdentifier()).getTimeInMillis() != ((java.util.Calendar)employee.getIdentifier()).getTimeInMillis()) {
+ return false;
+ }
+ } else
if(!this.getIdentifier().equals(employee.getIdentifier())) {return false;}
if(!this.getFirstName().equals(employee.getFirstName())) {return false;}
if(!this.getLastName().equals(employee.getLastName())) {return false;}
diff --git a/sdo/eclipselink.sdo.test/src/org/eclipse/persistence/testing/sdo/helper/datahelper/DataHelperConvertFromStringTest.java b/sdo/eclipselink.sdo.test/src/org/eclipse/persistence/testing/sdo/helper/datahelper/DataHelperConvertFromStringTest.java
index 5b36d61..54ff6b0 100644
--- a/sdo/eclipselink.sdo.test/src/org/eclipse/persistence/testing/sdo/helper/datahelper/DataHelperConvertFromStringTest.java
+++ b/sdo/eclipselink.sdo.test/src/org/eclipse/persistence/testing/sdo/helper/datahelper/DataHelperConvertFromStringTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 1998, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
@@ -51,7 +51,7 @@ public class DataHelperConvertFromStringTest extends DataHelperTestCases {
Calendar aCalendar = (Calendar)dataHelper.convertFromStringValue(b, Calendar.class, null);
assertTrue("Expected YEAR: " + controlCalendar.get(Calendar.YEAR) + ", but was: " + aCalendar.get(Calendar.YEAR), controlCalendar.get(Calendar.YEAR) == aCalendar.get(Calendar.YEAR));
assertTrue("Expected TimeZone: " + controlCalendar.getTimeZone() + ", but was: " + aCalendar.getTimeZone(), controlCalendar.getTimeZone().equals(aCalendar.getTimeZone()));
- assertTrue("Expected toString: " + controlCalendar.toString() + ", but was: " + aCalendar.toString(), controlCalendar.toString().equals(aCalendar.toString()));
+ assertTrue("Expected same time in millis", controlCalendar.getTimeInMillis() == aCalendar.getTimeInMillis());
}
public void testConverFromString_NoQname() {
@@ -75,7 +75,7 @@ public class DataHelperConvertFromStringTest extends DataHelperTestCases {
Calendar aCalendar = (Calendar)dataHelper.convertFromStringValue(b, Calendar.class, null);
assertTrue("Expected YEAR: " + controlCalendar.get(Calendar.YEAR) + ", but was: " + aCalendar.get(Calendar.YEAR), controlCalendar.get(Calendar.YEAR) == aCalendar.get(Calendar.YEAR));
assertTrue("Expected TimeZone: " + controlCalendar.getTimeZone() + ", but was: " + aCalendar.getTimeZone(), controlCalendar.getTimeZone().equals(aCalendar.getTimeZone()));
- assertTrue("Expected toString: " + controlCalendar.toString() + ", but was: " + aCalendar.toString(), controlCalendar.toString().equals(aCalendar.toString()));
+ assertTrue("Expected same time in millis", controlCalendar.getTimeInMillis() == aCalendar.getTimeInMillis());
}
public void testConverFromString_Type() {
diff --git a/sdo/eclipselink.sdo.test/src/org/eclipse/persistence/testing/sdo/helper/datahelper/DataHelperToCalendarTest.java b/sdo/eclipselink.sdo.test/src/org/eclipse/persistence/testing/sdo/helper/datahelper/DataHelperToCalendarTest.java
index cd3e3c5..fd054f2 100644
--- a/sdo/eclipselink.sdo.test/src/org/eclipse/persistence/testing/sdo/helper/datahelper/DataHelperToCalendarTest.java
+++ b/sdo/eclipselink.sdo.test/src/org/eclipse/persistence/testing/sdo/helper/datahelper/DataHelperToCalendarTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 1998, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
@@ -30,7 +30,7 @@ public class DataHelperToCalendarTest extends DataHelperTestCases {
assertTrue("Expected YEAR: " + controlCalendar.get(Calendar.YEAR) + ", but was: " + aCalendar.get(Calendar.YEAR), controlCalendar.get(Calendar.YEAR) == aCalendar.get(Calendar.YEAR));
assertTrue("Expected MONTH: " + controlCalendar.get(Calendar.MONTH) + ", but was: " + aCalendar.get(Calendar.MONTH), controlCalendar.get(Calendar.MONTH) == aCalendar.get(Calendar.MONTH));
assertTrue("Expected TimeZone: " + controlCalendar.getTimeZone() + ", but was: " + aCalendar.getTimeZone(), controlCalendar.getTimeZone().equals(aCalendar.getTimeZone()));
- assertTrue("Expected toString: " + controlCalendar.toString() + ", but was: " + aCalendar.toString(), controlCalendar.toString().equals(aCalendar.toString()));
+ assertTrue("Expected same time in millis", controlCalendar.getTimeInMillis() == aCalendar.getTimeInMillis());
}
public void testToCalendarWithGYear() {
@@ -41,7 +41,7 @@ public class DataHelperToCalendarTest extends DataHelperTestCases {
Calendar aCalendar = dataHelper.toCalendar("2001");
assertTrue("Expected YEAR: " + controlCalendar.get(Calendar.YEAR) + ", but was: " + aCalendar.get(Calendar.YEAR), controlCalendar.get(Calendar.YEAR) == aCalendar.get(Calendar.YEAR));
assertTrue("Expected TimeZone: " + controlCalendar.getTimeZone() + ", but was: " + aCalendar.getTimeZone(), controlCalendar.getTimeZone().equals(aCalendar.getTimeZone()));
- assertTrue("Expected toString: " + controlCalendar.toString() + ", but was: " + aCalendar.toString(), controlCalendar.toString().equals(aCalendar.toString()));
+ assertTrue("Expected same time in millis", controlCalendar.getTimeInMillis() == aCalendar.getTimeInMillis());
}
public void testToCalendarWithGMonthDay() {
@@ -54,7 +54,7 @@ public class DataHelperToCalendarTest extends DataHelperTestCases {
assertTrue("Expected MONTH: " + controlCalendar.get(Calendar.MONTH) + ", but was: " + aCalendar.get(Calendar.MONTH), controlCalendar.get(Calendar.MONTH) == aCalendar.get(Calendar.MONTH));
assertTrue("Expected DATE: " + controlCalendar.get(Calendar.DATE) + ", but was: " + aCalendar.get(Calendar.DATE), controlCalendar.get(Calendar.DATE) == aCalendar.get(Calendar.DATE));
assertTrue("Expected TimeZone: " + controlCalendar.getTimeZone() + ", but was: " + aCalendar.getTimeZone(), controlCalendar.getTimeZone().equals(aCalendar.getTimeZone()));
- assertTrue("Expected toString: " + controlCalendar.toString() + ", but was: " + aCalendar.toString(), controlCalendar.toString().equals(aCalendar.toString()));
+ assertTrue("Expected same time in millis", controlCalendar.getTimeInMillis() == aCalendar.getTimeInMillis());
}
public void testToCalendarWithGMonth() {
@@ -65,7 +65,7 @@ public class DataHelperToCalendarTest extends DataHelperTestCases {
Calendar aCalendar = dataHelper.toCalendar("--10");
assertTrue("Expected MONTH: " + controlCalendar.get(Calendar.MONTH) + ", but was: " + aCalendar.get(Calendar.MONTH), controlCalendar.get(Calendar.MONTH) == aCalendar.get(Calendar.MONTH));
assertTrue("Expected TimeZone: " + controlCalendar.getTimeZone() + ", but was: " + aCalendar.getTimeZone(), controlCalendar.getTimeZone().equals(aCalendar.getTimeZone()));
- assertTrue("Expected toString: " + controlCalendar.toString() + ", but was: " + aCalendar.toString(), controlCalendar.toString().equals(aCalendar.toString()));
+ assertTrue("Expected same time in millis", controlCalendar.getTimeInMillis() == aCalendar.getTimeInMillis());
}
public void testToCalendarWithGDay() {
@@ -76,7 +76,7 @@ public class DataHelperToCalendarTest extends DataHelperTestCases {
Calendar aCalendar = dataHelper.toCalendar("---31");
assertTrue("Expected DATE: " + controlCalendar.get(Calendar.DATE) + ", but was: " + aCalendar.get(Calendar.DATE), controlCalendar.get(Calendar.DATE) == aCalendar.get(Calendar.DATE));
assertTrue("Expected TimeZone: " + controlCalendar.getTimeZone() + ", but was: " + aCalendar.getTimeZone(), controlCalendar.getTimeZone().equals(aCalendar.getTimeZone()));
- assertTrue("Expected toString: " + controlCalendar.toString() + ", but was: " + aCalendar.toString(), controlCalendar.toString().equals(aCalendar.toString()));
+ assertTrue("Expected same time in millis", controlCalendar.getTimeInMillis() == aCalendar.getTimeInMillis());
}
public void testToCalendarWithTime() {
@@ -93,7 +93,7 @@ public class DataHelperToCalendarTest extends DataHelperTestCases {
assertTrue("Expected SECOND: " + controlCalendar.get(Calendar.SECOND) + ", but was: " + aCalendar.get(Calendar.SECOND), controlCalendar.get(Calendar.SECOND) == aCalendar.get(Calendar.SECOND));
assertTrue("Expected MILLISECOND: " + controlCalendar.get(Calendar.MILLISECOND) + ", but was: " + aCalendar.get(Calendar.MILLISECOND), controlCalendar.get(Calendar.MILLISECOND) == aCalendar.get(Calendar.MILLISECOND));
assertTrue("Expected TimeZone: " + controlCalendar.getTimeZone() + ", but was: " + aCalendar.getTimeZone(), controlCalendar.getTimeZone().equals(aCalendar.getTimeZone()));
- assertTrue("Expected toString: " + controlCalendar.toString() + ", but was: " + aCalendar.toString(), controlCalendar.toString().equals(aCalendar.toString()));
+ assertTrue("Expected same time in millis", controlCalendar.getTimeInMillis() == aCalendar.getTimeInMillis());
}
public void testToCalendarWithDate() {
@@ -108,7 +108,7 @@ public class DataHelperToCalendarTest extends DataHelperTestCases {
assertTrue("Expected MONTH: " + controlCalendar.get(Calendar.MONTH) + ", but was: " + aCalendar.get(Calendar.MONTH), controlCalendar.get(Calendar.MONTH) == aCalendar.get(Calendar.MONTH));
assertTrue("Expected DATE: " + controlCalendar.get(Calendar.DATE) + ", but was: " + aCalendar.get(Calendar.DATE), controlCalendar.get(Calendar.DATE) == aCalendar.get(Calendar.DATE));
assertTrue("Expected TimeZone: " + controlCalendar.getTimeZone() + ", but was: " + aCalendar.getTimeZone(), controlCalendar.getTimeZone().equals(aCalendar.getTimeZone()));
- assertTrue("Expected toString: " + controlCalendar.toString() + ", but was: " + aCalendar.toString(), controlCalendar.toString().equals(aCalendar.toString()));
+ assertTrue("Expected same time in millis", controlCalendar.getTimeInMillis() == aCalendar.getTimeInMillis());
}
public void testToCalendarWithDateTime() {
@@ -131,7 +131,7 @@ public class DataHelperToCalendarTest extends DataHelperTestCases {
assertTrue("Expected SECOND: " + controlCalendar.get(Calendar.SECOND) + ", but was: " + aCalendar.get(Calendar.SECOND), controlCalendar.get(Calendar.SECOND) == aCalendar.get(Calendar.SECOND));
assertTrue("Expected MILLISECOND: " + controlCalendar.get(Calendar.MILLISECOND) + ", but was: " + aCalendar.get(Calendar.MILLISECOND), controlCalendar.get(Calendar.MILLISECOND) == aCalendar.get(Calendar.MILLISECOND));
assertTrue("Expected TimeZone: " + controlCalendar.getTimeZone() + ", but was: " + aCalendar.getTimeZone(), controlCalendar.getTimeZone().equals(aCalendar.getTimeZone()));
- assertTrue("Expected toString: " + controlCalendar.toString() + ", but was: " + aCalendar.toString(), controlCalendar.toString().equals(aCalendar.toString()));
+ assertTrue("Expected same time in millis", controlCalendar.getTimeInMillis() == aCalendar.getTimeInMillis());
}
public void testToCalendarWithDuration() {
diff --git a/sdo/eclipselink.sdo.test/src/org/eclipse/persistence/testing/sdo/helper/datahelper/DataHelperToCalendarWithLocale.java b/sdo/eclipselink.sdo.test/src/org/eclipse/persistence/testing/sdo/helper/datahelper/DataHelperToCalendarWithLocale.java
index 75b54b8..3e21e3e 100644
--- a/sdo/eclipselink.sdo.test/src/org/eclipse/persistence/testing/sdo/helper/datahelper/DataHelperToCalendarWithLocale.java
+++ b/sdo/eclipselink.sdo.test/src/org/eclipse/persistence/testing/sdo/helper/datahelper/DataHelperToCalendarWithLocale.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 1998, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
@@ -194,7 +194,7 @@ public class DataHelperToCalendarWithLocale extends DataHelperTestCases {
assertTrue("Expected MONTH: " + controlCalendar.get(Calendar.MONTH) + ", but was: " + aCalendar.get(Calendar.MONTH), controlCalendar.get(Calendar.MONTH) == aCalendar.get(Calendar.MONTH));
assertTrue("Expected DATE: " + controlCalendar.get(Calendar.DATE) + ", but was: " + aCalendar.get(Calendar.DATE), controlCalendar.get(Calendar.DATE) == aCalendar.get(Calendar.DATE));
assertTrue("Expected TimeZone: " + controlCalendar.getTimeZone() + ", but was: " + aCalendar.getTimeZone(), controlCalendar.getTimeZone().equals(aCalendar.getTimeZone()));
- assertTrue("Expected toString: " + controlCalendar.toString() + ", but was: " + aCalendar.toString(), controlCalendar.toString().equals(aCalendar.toString()));
+ assertTrue("Expected same time in millis", controlCalendar.getTimeInMillis() == aCalendar.getTimeInMillis());
}
public void testToCalendarWithNullString() {
diff --git a/sdo/eclipselink.sdo.test/src/org/eclipse/persistence/testing/sdo/helper/datahelper/DataHelperToDateTest.java b/sdo/eclipselink.sdo.test/src/org/eclipse/persistence/testing/sdo/helper/datahelper/DataHelperToDateTest.java
index 0d83e60..55cff01 100644
--- a/sdo/eclipselink.sdo.test/src/org/eclipse/persistence/testing/sdo/helper/datahelper/DataHelperToDateTest.java
+++ b/sdo/eclipselink.sdo.test/src/org/eclipse/persistence/testing/sdo/helper/datahelper/DataHelperToDateTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 1998, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
@@ -15,6 +15,8 @@ package org.eclipse.persistence.testing.sdo.helper.datahelper;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.Locale;
import java.util.TimeZone;
import org.eclipse.persistence.internal.oxm.XMLConversionManager;
@@ -139,10 +141,13 @@ public class DataHelperToDateTest extends DataHelperTestCases {
Date dateObj = dataHelper.toDate("0001-01-01-05:00");
SimpleDateFormat sdf = new SimpleDateFormat();
- sdf.applyPattern("MM/dd/yyyy G");
+ sdf.applyPattern("MM/dd/yyyy");
- String controlString = "01/01/0001 AD";
+ String controlString = "01/01/0001";
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(dateObj);
+ assertTrue(cal.get(Calendar.ERA) == GregorianCalendar.AD);
assertEquals(controlString, sdf.format(dateObj));
}
@@ -152,10 +157,13 @@ public class DataHelperToDateTest extends DataHelperTestCases {
Date dateObj = dataHelper.toDate("-2006-03-31T03:30:45.001-05:00");
SimpleDateFormat sdf = new SimpleDateFormat();
- sdf.applyPattern("MM/dd/yyyy G");
-
- String controlString = "03/31/2006 BC";
+ sdf.applyPattern("MM/dd/yyyy");
+ String controlString = "03/31/2006";
+
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(dateObj);
+ assertTrue(cal.get(Calendar.ERA) == GregorianCalendar.BC);
assertEquals(controlString, sdf.format(dateObj));
}
@@ -173,4 +181,4 @@ public class DataHelperToDateTest extends DataHelperTestCases {
}
}
-} \ No newline at end of file
+}
diff --git a/sdo/eclipselink.sdo.test/src/org/eclipse/persistence/testing/sdo/util/CompileUtil.java b/sdo/eclipselink.sdo.test/src/org/eclipse/persistence/testing/sdo/util/CompileUtil.java
index d6ea516..d00f049 100644
--- a/sdo/eclipselink.sdo.test/src/org/eclipse/persistence/testing/sdo/util/CompileUtil.java
+++ b/sdo/eclipselink.sdo.test/src/org/eclipse/persistence/testing/sdo/util/CompileUtil.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 1998, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
@@ -13,10 +13,10 @@
package org.eclipse.persistence.testing.sdo.util;
-//import com.sun.tools.javac.Main;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
+import java.io.File;
public class CompileUtil {
@@ -34,13 +34,18 @@ public class CompileUtil {
public int compile(String classpath, Object[] javaFiles) {
String[] args = new String[javaFiles.length + 7];
- args[0] = "javac";
+
+ String javac = getJavaC();
+
+ String javaVersion = getJavaVersion();
+
+ args[0] = javac;
args[1] = "-cp";
args[2] = classpath;
args[3] = "-source";
- args[4] = "1.6";
+ args[4] = javaVersion;
args[5] = "-target";
- args[6] = "1.6";
+ args[6] = javaVersion;
System.arraycopy(javaFiles, 0, args, 7, javaFiles.length);
int exitVal = -1;
@@ -69,14 +74,38 @@ public class CompileUtil {
return exitVal;
}
+ private String getJavaVersion() {
+ String javaVersion = "java.version";
+ if (System.getProperty(javaVersion).contains("1.7")) {
+ return "1.7";
+ } else if (System.getProperty(javaVersion).contains("1.8")) {
+ return "1.8";
+ }
+ return "1.6";
+ }
+
+ private String getJavaC() {
+ String javaHome = System.getenv("JAVA_HOME");
+ if (null != javaHome) {
+ StringBuilder javacBuilder = new StringBuilder(35);
+ javacBuilder.append(javaHome);
+ if (!javaHome.endsWith(File.separator)) {
+ javacBuilder.append(File.separator);
+ }
+ javacBuilder.append("bin");
+ javacBuilder.append(File.separator);
+ javacBuilder.append("javac");
+ return javacBuilder.toString();
+ }
+ return "javac";
+ }
+
public int compileOld(String classpath, Object[] javaFiles) {
String[] args = new String[javaFiles.length + 2];
args[0] = "-cp";
args[1] = classpath;
System.arraycopy(javaFiles, 0, args, 2, javaFiles.length);
- //int returnVal = Main.compile(args);
- //return returnVal;
return -1;
}