blob: 72fb62b06b6e6206d235b4bfecf23be2bc02a006 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2007, 2009 Oracle. 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:
* Oracle - initial API and implementation
******************************************************************************/
package org.eclipse.jpt.core.tests.internal.context.persistence;
import org.eclipse.jpt.core.context.JpaRootContextNode;
import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
import org.eclipse.jpt.core.resource.persistence.XmlPersistence;
import org.eclipse.jpt.core.resource.xml.JpaXmlResource;
import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
public class RootContextNodeTests extends ContextModelTestCase
{
public RootContextNodeTests(String name) {
super(name);
}
public void testUpdateAddPersistenceXml() throws Exception {
JpaXmlResource pr = getPersistenceXmlResource();
deleteResource(pr);
assertFalse(pr.fileExists());
JpaRootContextNode baseJpaContent = getJavaProject().getJpaProject().getRootContextNode();
assertNull(baseJpaContent.getPersistenceXml());
XmlPersistence xmlPersistence = PersistenceFactory.eINSTANCE.createXmlPersistence();
xmlPersistence.setVersion("1.0");
pr.getContents().add(xmlPersistence);
pr.save(null);
assertNotNull(baseJpaContent.getPersistenceXml());
}
public void testUpdateRemovePersistenceXml() throws Exception {
JpaXmlResource pr = getPersistenceXmlResource();
JpaRootContextNode baseJpaContent = getJavaProject().getJpaProject().getRootContextNode();
assertNotNull(baseJpaContent.getPersistenceXml());
deleteResource(pr);
assertNull(baseJpaContent.getPersistenceXml());
}
}