blob: 807e2b6c572635f3b8b324a03dbd44a426338c2a [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.internal.operations.PersistenceFileCreationDataModelProperties;
import org.eclipse.jpt.core.internal.operations.PersistenceFileCreationDataModelProvider;
import org.eclipse.jpt.core.resource.xml.JpaXmlResource;
import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase;
import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
public class RootContextNodeTests extends ContextModelTestCase
{
public RootContextNodeTests(String name) {
super(name);
}
public void testUpdateAddPersistenceXml() throws Exception {
deleteResource(getPersistenceXmlResource());
JpaRootContextNode baseJpaContent = getJavaProject().getJpaProject().getRootContextNode();
assertFalse(getPersistenceXmlResource().fileExists());
assertNull(baseJpaContent.getPersistenceXml());
IDataModel config =
DataModelFactory.createDataModel(new PersistenceFileCreationDataModelProvider());
config.setProperty(PersistenceFileCreationDataModelProperties.PROJECT_NAME, getJpaProject().getProject().getName());
config.getDefaultOperation().execute(null, 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());
}
}