summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Monnier2013-04-08 13:32:31 (EDT)
committerChristian W. Damus2013-04-08 13:32:31 (EDT)
commitc1d0a66405208c386ebc046a8f9b979a78dc1bfa (patch)
tree63f2d1c71fdf3dac34884c0f6d041ff75d32bece
parentfb8e32504f22ccd37a26669b406acc17661b04a8 (diff)
downloadcdo-c1d0a66405208c386ebc046a8f9b979a78dc1bfa.zip
cdo-c1d0a66405208c386ebc046a8f9b979a78dc1bfa.tar.gz
cdo-c1d0a66405208c386ebc046a8f9b979a78dc1bfa.tar.bz2
[404152] [Legacy] A String feature with an empty String for default value can't be set as null
https://bugs.eclipse.org/bugs/show_bug.cgi?id=404152 Original test case. Signed-off-by: Christian W. Damus <give.a.damus@gmail.com>
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_404152_Test.java57
1 files changed, 57 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_404152_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_404152_Test.java
new file mode 100644
index 0000000..f560e1d
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_404152_Test.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2004 - 2013 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Steve Monnier - initial API and implementation
+ * Eike Stepper - adapted for more correct test model definition
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model6.EmptyStringDefault;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+/**
+ * Bug 404152.
+ *
+ * @author Steve Monnier
+ */
+public class Bugzilla_404152_Test extends AbstractCDOTest
+{
+ /**
+ * This scenario validates that null can be set on a String feature with an empty string has default value has.
+ */
+ public void testSetNonDefaultNullString() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+
+ // Create a company element and set is name has an empty string
+ EmptyStringDefault localObject = getModel6Factory().createEmptyStringDefault();
+ localObject.setAttribute("");
+ resource.getContents().add(localObject);
+ transaction.commit();
+
+ CDOTransaction remoteTransaction = openSession().openTransaction();
+ EmptyStringDefault remoteObject = remoteTransaction.getObject(localObject);
+
+ // Validate that for another user (another transaction) the name is an empty string
+ assertNotNull("Attribute should not be null", remoteObject.getAttribute());
+
+ // Change company name from empty string to null
+ assertNotNull("Attribute should be null", localObject.getAttribute());
+ localObject.setAttribute(null);
+ assertNull("Attribute should be null", localObject.getAttribute());
+
+ // Validate that for another user (another transaction) the name is null
+ commitAndSync(transaction, remoteTransaction);
+ assertNull(remoteObject.getAttribute());
+ }
+}