Author: rob.stryker(a)jboss.com
Date: 2012-10-04 03:20:26 -0400 (Thu, 04 Oct 2012)
New Revision: 44278
Modified:
trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XMLBinding.java
trunk/archives/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/XBMarshallTest.java
Log:
JBIDE-12495 to trunk
Modified:
trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XMLBinding.java
===================================================================
---
trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XMLBinding.java 2012-10-04
03:02:14 UTC (rev 44277)
+++
trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XMLBinding.java 2012-10-04
07:20:26 UTC (rev 44278)
@@ -112,8 +112,8 @@
private static List nullSafe(List list) {
return list == null ? new ArrayList() : list;
}
- private static boolean isEmpty(String s) {
- return s != null && !"".equals(s); //$NON-NLS-1$
+ private static boolean isEmpty(String s) {
+ return (s == null || s.isEmpty());
}
private static void marshallAddPackages(XMLMemento memento, List packages) throws
XbException {
Iterator i = packages.iterator();
Modified:
trunk/archives/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/XBMarshallTest.java
===================================================================
---
trunk/archives/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/XBMarshallTest.java 2012-10-04
03:02:14 UTC (rev 44277)
+++
trunk/archives/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/XBMarshallTest.java 2012-10-04
07:20:26 UTC (rev 44278)
@@ -111,7 +111,22 @@
}
}
}
-
+ protected String writeToString(XbPackages packs, boolean shouldPass) {
+ XbException e = null;
+ try {
+ return XMLBinding.serializePackages(packs, new NullProgressMonitor());
+ } catch( XbException xbe ) {
+ e = xbe;
+ } finally {
+ if( e == null && !shouldPass) {
+ fail("Incomplete Model saved when it should not have been.");
+ }
+ if( e != null && shouldPass) {
+ fail("Model failed to save when it should have saved. " + e.getMessage());
+ }
+ }
+ return null;
+ }
protected void writePackage(String name, String toDir, boolean shouldPass) {
XbPackages packs = new XbPackages();
XbPackage pack = new XbPackage();
@@ -121,12 +136,28 @@
write(packs, shouldPass);
}
+ protected String writePackageToString(String name, String toDir, boolean shouldPass) {
+ XbPackages packs = new XbPackages();
+ XbPackage pack = new XbPackage();
+ pack.setName(name);
+ pack.setToDir(toDir);
+ packs.addChild(pack);
+ return writeToString(packs, true);
+ }
+
public void testWritePackageSuccess() {
writePackage("someName", "someFile.jar", true);
}
public void testWritePackageMissingName() {
writePackage(null, "someFile.jar", false);
}
+ public void test12495Defect() {
+ String result = writePackageToString("someName", "outs", true);
+ boolean b = result.contains("todir=\"outs\"");
+ if( !b ) {
+ fail();
+ }
+ }
// Currently the schema is written that this will pass
// public void testWritePackageMissingDir() {
Show replies by date