Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 167602 Details for
Bug 308895
[DB] Saving a default value of a custom type throws NotSerializableException
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch-v2
clipboard.txt (text/plain), 8.73 KB, created by
Stefan Winkler
on 2010-05-08 10:36:18 EDT
(
hide
)
Description:
Patch-v2
Filename:
MIME Type:
Creator:
Stefan Winkler
Created:
2010-05-08 10:36:18 EDT
Size:
8.73 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.emf.cdo.server.db >Index: src/org/eclipse/emf/cdo/server/internal/db/mapping/TypeMapping.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf.cdo/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/TypeMapping.java,v >retrieving revision 1.17 >diff -u -r1.17 TypeMapping.java >--- src/org/eclipse/emf/cdo/server/internal/db/mapping/TypeMapping.java 29 Apr 2010 07:02:41 -0000 1.17 >+++ src/org/eclipse/emf/cdo/server/internal/db/mapping/TypeMapping.java 8 May 2010 14:34:28 -0000 >@@ -633,5 +633,11 @@ > > return val; > } >+ >+ @Override >+ public void setDefaultValue(PreparedStatement stmt, int index) throws SQLException >+ { >+ setValue(stmt, index, getFeature().getDefaultValueLiteral()); >+ } > } > } >#P org.eclipse.emf.cdo.tests >Index: src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf.cdo/tests/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java,v >retrieving revision 1.87 >diff -u -r1.87 AllTestsAllConfigs.java >--- src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java 7 May 2010 09:06:13 -0000 1.87 >+++ src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java 8 May 2010 14:34:30 -0000 >@@ -69,6 +69,7 @@ > import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_303466_Test; > import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_303807_Test; > import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_306710_Test; >+import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_308895_Test; > import org.eclipse.emf.cdo.tests.config.impl.ConfigTest; > import org.eclipse.emf.cdo.tests.config.impl.ConfigTestSuite; > >@@ -198,6 +199,7 @@ > testClasses.add(Bugzilla_303466_Test.class); > testClasses.add(Bugzilla_303807_Test.class); > testClasses.add(Bugzilla_306710_Test.class); >+ testClasses.add(Bugzilla_308895_Test.class); > > // TODO testClasses.add(NonCDOResourceTest.class); > // TODO testClasses.add(GeneratedEcoreTest.class); >Index: src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_308895_Test.java >=================================================================== >RCS file: src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_308895_Test.java >diff -N src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_308895_Test.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_308895_Test.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,240 @@ >+package org.eclipse.emf.cdo.tests.bugzilla; >+ >+import org.eclipse.emf.cdo.common.model.EMFUtil; >+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.transaction.CDOTransaction; >+import org.eclipse.emf.cdo.util.CDOUtil; >+import org.eclipse.emf.cdo.view.CDOView; >+ >+import org.eclipse.emf.ecore.EAttribute; >+import org.eclipse.emf.ecore.EClass; >+import org.eclipse.emf.ecore.EDataType; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.EPackage; >+import org.eclipse.emf.ecore.EcoreFactory; >+import org.eclipse.emf.ecore.util.EcoreUtil; >+ >+/** >+ * Copyright (c) 2004 - 2010 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: >+ * Stefan Winkler - initial API and implementation >+ */ >+ >+/** >+ * @author Stefan Winkler >+ */ >+public class Bugzilla_308895_Test extends AbstractCDOTest >+{ >+ private EPackage pkg; >+ >+ private EClass cls; >+ >+ private EAttribute att; >+ >+ @Override >+ public void setUp() throws Exception >+ { >+ super.setUp(); >+ >+ pkg = EMFUtil.createEPackage("customTest", "ct", "http://cdo.emf.eclipse.org/customTest.ecore"); >+ EDataType custom = EcoreFactory.eINSTANCE.createEDataType(); >+ custom.setInstanceClass(CustomType.class); >+ custom.setName("CustomType"); >+ >+ pkg.getEClassifiers().add(custom); >+ >+ cls = EMFUtil.createEClass(pkg, "Foobar", false, false); >+ att = EMFUtil.createEAttribute(cls, "att", custom); >+ >+ CDOUtil.prepareDynamicEPackage(pkg); >+ } >+ >+ public void testCustomRegular() >+ { >+ EObject obj = EcoreUtil.create(cls); >+ obj.eSet(att, new CustomType(23, 42)); >+ >+ { >+ CDOSession session = openSession(); >+ session.getPackageRegistry().putEPackage(pkg); >+ CDOTransaction tx = session.openTransaction(); >+ CDOResource res = tx.createResource("/test"); >+ res.getContents().add(obj); >+ tx.commit(); >+ tx.close(); >+ session.close(); >+ } >+ >+ clearCache(getRepository().getRevisionManager()); >+ >+ { >+ CDOSession session = openSession(); >+ session.getPackageRegistry().putEPackage(pkg); >+ CDOView v = session.openView(); >+ CDOResource res = v.getResource("/test"); >+ EObject persistent = res.getContents().get(0); >+ >+ CustomType pCustom = (CustomType)persistent.eGet(att); >+ assertEquals(23, pCustom.getA()); >+ assertEquals(42, pCustom.getB()); >+ >+ v.close(); >+ session.close(); >+ } >+ } >+ >+ public void testCustomDefaultLiteral() >+ { >+ // valid default literal >+ att.setDefaultValueLiteral("1;2"); >+ >+ EObject obj = EcoreUtil.create(cls); >+ obj.eUnset(att); >+ >+ { >+ CDOSession session = openSession(); >+ session.getPackageRegistry().putEPackage(pkg); >+ CDOTransaction tx = session.openTransaction(); >+ CDOResource res = tx.createResource("/test"); >+ res.getContents().add(obj); >+ tx.commit(); >+ tx.close(); >+ session.close(); >+ } >+ >+ clearCache(getRepository().getRevisionManager()); >+ >+ { >+ CDOSession session = openSession(); >+ session.getPackageRegistry().putEPackage(pkg); >+ CDOView v = session.openView(); >+ CDOResource res = v.getResource("/test"); >+ EObject persistent = res.getContents().get(0); >+ >+ CustomType pCustom = (CustomType)persistent.eGet(att); >+ assertEquals(1, pCustom.getA()); >+ assertEquals(2, pCustom.getB()); >+ >+ v.close(); >+ session.close(); >+ } >+ } >+ >+ public void testCustomDefaultDefault() >+ { >+ // no default literal is set >+ EObject obj = EcoreUtil.create(cls); >+ >+ { >+ CDOSession session = openSession(); >+ session.getPackageRegistry().putEPackage(pkg); >+ CDOTransaction tx = session.openTransaction(); >+ CDOResource res = tx.createResource("/test"); >+ res.getContents().add(obj); >+ tx.commit(); >+ tx.close(); >+ session.close(); >+ } >+ >+ clearCache(getRepository().getRevisionManager()); >+ >+ { >+ CDOSession session = openSession(); >+ session.getPackageRegistry().putEPackage(pkg); >+ CDOView v = session.openView(); >+ CDOResource res = v.getResource("/test"); >+ EObject persistent = res.getContents().get(0); >+ >+ CustomType pCustom = (CustomType)persistent.eGet(att); >+ assertNull(pCustom); >+ >+ v.close(); >+ session.close(); >+ } >+ } >+ >+ public void testCustomDefaultInvalidLiteral() >+ { >+ // invalid default literal >+ att.setDefaultValueLiteral("1;2;3"); >+ >+ EObject obj = EcoreUtil.create(cls); >+ >+ { >+ CDOSession session = openSession(); >+ session.getPackageRegistry().putEPackage(pkg); >+ CDOTransaction tx = session.openTransaction(); >+ CDOResource res = tx.createResource("/test"); >+ res.getContents().add(obj); >+ tx.commit(); >+ tx.close(); >+ session.close(); >+ } >+ >+ clearCache(getRepository().getRevisionManager()); >+ >+ { >+ CDOSession session = openSession(); >+ session.getPackageRegistry().putEPackage(pkg); >+ CDOView v = session.openView(); >+ CDOResource res = v.getResource("/test"); >+ EObject persistent = res.getContents().get(0); >+ >+ CustomType pCustom = (CustomType)persistent.eGet(att); >+ assertNull(pCustom); >+ >+ v.close(); >+ session.close(); >+ } >+ } >+ >+ public static class CustomType >+ { >+ private int a = 0; >+ >+ private int b = 0; >+ >+ public CustomType(int _a, int _b) >+ { >+ a = _a; >+ b = _b; >+ } >+ >+ public CustomType(String literal) >+ { >+ String[] values = literal.split(";"); >+ if (values.length != 2) >+ { >+ throw new RuntimeException("Error: only 2 values allowed"); >+ } >+ else >+ { >+ a = Integer.valueOf(values[0]); >+ b = Integer.valueOf(values[1]); >+ } >+ } >+ >+ @Override >+ public String toString() >+ { >+ return a + ";" + b; >+ } >+ >+ public int getA() >+ { >+ return a; >+ } >+ >+ public int getB() >+ { >+ return b; >+ } >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 308895
:
164590
|
164591
| 167602