Write/Read tests for Faces 1.2 model changes.
diff --git a/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/AllWriteTests.java b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/AllWriteTests.java
index 54a695e..1bd1b22 100644
--- a/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/AllWriteTests.java
+++ b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/AllWriteTests.java
@@ -11,11 +11,13 @@
package org.eclipse.jst.jsf.facesconfig.tests.write;
-import org.eclipse.jst.jsf.facesconfig.tests.util.CommonStructuresUtil;
-
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.eclipse.jst.jsf.facesconfig.tests.util.CommonStructuresUtil;
+import org.eclipse.jst.jsf.test.util.ConfigurableTestSuite;
+import org.eclipse.jst.jsf.test.util.ConfigurableTestCase.TestConfiguration;
+
/**
* Wrapper suite for all the tests against the .util package.
*
@@ -24,43 +26,103 @@
*/
public class AllWriteTests {
- public static Test suite() {
- TestSuite suite = new TestSuite("Test FacesConfig - writing");
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("FacesConfig Model Write/Read Translation");
+ suite.addTest(Faces_1_1_suite());
+ suite.addTest(Faces_1_2_suite());
+ return suite;
+ }
+
+ private static Test Faces_1_2_suite()
+ {
+ TestConfiguration testConfiguration = new TestConfiguration();
+ testConfiguration.put(BaseWriteTestCase.CONFIG_FILE_KEY, "WEB-INF/faces-config2.xml");
+ testConfiguration.put(BaseWriteTestCase.FACES_VERSION_KEY, "1.2");
- suite.addTest(new TestSuite(
- CommonStructuresUtil.class,
- "Sanity Test"));
- suite.addTest(new TestSuite(
+ TestSuite suite =
+ new ConfigurableTestSuite(testConfiguration, "Faces 1.2 Model Tests");
+ suite.addTest(new ConfigurableTestSuite(
+ WriteApplicationTestCase_1_2.class,
+ "Write application"));
+ suite.addTest(new ConfigurableTestSuite(
+ WriteConverterTestCase_1_2.class,
+ "Write converter Test"));
+ suite.addTest(new ConfigurableTestSuite(
+ WriteFactoryTestCase_1_2.class,
+ "Write factory "));
+ suite.addTest(new ConfigurableTestSuite(
+ WriteLifecycleTestCase_1_2.class,
+ "Write Lifecycle Test"));
+ suite.addTest(new ConfigurableTestSuite(
+ WriteManagedBeanTestCase_1_2.class,
+ "Write Managed-bean Test"));
+ suite.addTest(new ConfigurableTestSuite(
+ WriteNavigationRuleTestCase_1_2.class,
+ "Write navigation rule"));
+ suite.addTest(new ConfigurableTestSuite(
+ WriteRenderKitTestCase_1_2.class,
+ "Write Render-kit Test"));
+ suite.addTest(new ConfigurableTestSuite(
+ WriteValidatorTestCase_1_2.class,
+ "Write Validator Test"));
+ Faces_common_suite(suite, testConfiguration);
+
+ suite.addTest(new ConfigurableTestSuite(
+ FacesConfigExtensionTestCase.class,
+ "Write Facesconfig Extension Test"));
+
+ return suite;
+ }
+
+ private static Test Faces_1_1_suite()
+ {
+ TestConfiguration testConfiguration = new TestConfiguration();
+ testConfiguration.put(BaseWriteTestCase.CONFIG_FILE_KEY, "WEB-INF/faces-config1.xml");
+ testConfiguration.put(BaseWriteTestCase.FACES_VERSION_KEY, "1.1");
+
+ TestSuite suite =
+ new ConfigurableTestSuite(testConfiguration, "Faces 1.1 Model Tests");
+
+ suite.addTest(new ConfigurableTestSuite(
WriteApplicationTestCase.class,
"Write application"));
- suite.addTest(new TestSuite(
- WriteComponentTestCase.class,
- "Write Component Test"));
- suite.addTest(new TestSuite(
+ suite.addTest(new ConfigurableTestSuite(
WriteConverterTestCase.class,
"Write converter Test"));
- suite.addTest(new TestSuite(
+ suite.addTest(new ConfigurableTestSuite(
WriteFactoryTestCase.class,
"Write factory "));
- suite.addTest(new TestSuite(
+ suite.addTest(new ConfigurableTestSuite(
WriteLifecycleTestCase.class,
- "Write Lifecycle Test"));
- suite.addTest(new TestSuite(
+ "Write Lifecycle Test"));
+ suite.addTest(new ConfigurableTestSuite(
WriteManagedBeanTestCase.class,
"Write Managed-bean Test"));
- suite.addTest(new TestSuite(
- WriteNavigationRuleTestCase.class,
- "Write navigation rule "));
- suite.addTest(new TestSuite(
+ suite.addTest(new ConfigurableTestSuite(
+ WriteNavigationRuleTestCase.class,
+ "Write navigation rule "));
+ suite.addTest(new ConfigurableTestSuite(
WriteRenderKitTestCase.class,
"Write Render-kit Test"));
- suite.addTest(new TestSuite(
+ suite.addTest(new ConfigurableTestSuite(
+ WriteValidatorTestCase.class,
+ "Write Validator Test"));
+ Faces_common_suite(suite, testConfiguration);
+
+ return suite;
+ }
+
+ private static void Faces_common_suite(TestSuite suite, TestConfiguration configuration)
+ {
+ suite.addTest(new ConfigurableTestSuite(
+ CommonStructuresUtil.class,
+ "Sanity Test"));
+ suite.addTest(new ConfigurableTestSuite(
+ WriteComponentTestCase.class,
+ "Write Component Test"));
+ suite.addTest(new ConfigurableTestSuite(
WriteReferencedBeanTestCase.class,
"Write ReferencedBean Test"));
- suite.addTest(new TestSuite(
- WriteValidatorTestCase.class,
- "Write Validator Test"));
-
- return suite;
}
}
diff --git a/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/BaseWriteTestCase.java b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/BaseWriteTestCase.java
new file mode 100644
index 0000000..3fd7758
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/BaseWriteTestCase.java
@@ -0,0 +1,71 @@
+package org.eclipse.jst.jsf.facesconfig.tests.write;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jst.jsf.facesconfig.emf.DynamicElement;
+import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory;
+import org.eclipse.jst.jsf.facesconfig.tests.util.WizardUtil;
+import org.eclipse.jst.jsf.facesconfig.util.FacesConfigArtifactEdit;
+import org.eclipse.jst.jsf.test.util.ConfigurableTestCase;
+import org.eclipse.jst.jsf.test.util.JSFTestUtil;
+
+public class BaseWriteTestCase extends ConfigurableTestCase
+{
+ final static String CONFIG_FILE_KEY = "config-file-key";
+ final static String FACES_VERSION_KEY = "faces-version-key";
+
+ protected IProject project;
+ protected String _facesConfigFile;
+ protected String _facesVersion;
+
+ public BaseWriteTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ initialize(_testConfiguration);
+
+ JSFTestUtil.setValidationEnabled(false);
+ JSFTestUtil.setInternetProxyPreferences(true, "www-proxy.uk.oracle.com", "80");
+
+ WizardUtil.createProject(getName());
+ project = WizardUtil.getTestProject(getName());
+ }
+
+ protected FacesConfigArtifactEdit getArtifactEditForRead()
+ {
+ FacesConfigArtifactEdit edit = FacesConfigArtifactEdit
+ .getFacesConfigArtifactEditForRead(project, _facesConfigFile);
+ assertNotNull(edit);
+ return edit;
+ }
+
+ protected FacesConfigArtifactEdit getArtifactEditForWrite()
+ {
+ FacesConfigArtifactEdit edit = FacesConfigArtifactEdit
+ .getFacesConfigArtifactEditForWrite(project, _facesConfigFile);
+ assertNotNull(edit);
+ return edit;
+ }
+
+ protected void initialize(TestConfiguration testConfiguration)
+ {
+ if (_testConfiguration != null)
+ {
+ _facesConfigFile = (String) _testConfiguration.get(CONFIG_FILE_KEY);
+ assertNotNull(_facesConfigFile);
+ _facesVersion = (String) _testConfiguration.get(FACES_VERSION_KEY);
+ assertNotNull(_facesVersion);
+ }
+ }
+
+ protected DynamicElement createDynamicElement(String name)
+ {
+ DynamicElement element =
+ FacesConfigFactory.eINSTANCE.createDynamicElement();
+ element.setName(name);
+ return element;
+ }
+}
diff --git a/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/FacesConfigExtensionTestCase.java b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/FacesConfigExtensionTestCase.java
new file mode 100644
index 0000000..2a319dc
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/FacesConfigExtensionTestCase.java
@@ -0,0 +1,88 @@
+package org.eclipse.jst.jsf.facesconfig.tests.write;
+
+import org.eclipse.jst.jsf.facesconfig.emf.DynamicElement;
+import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigExtensionType;
+import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory;
+import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage;
+import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigType;
+import org.eclipse.jst.jsf.facesconfig.tests.util.CommonStructuresUtil;
+import org.eclipse.jst.jsf.facesconfig.tests.util.FacesConfigModelUtil;
+import org.eclipse.jst.jsf.facesconfig.util.FacesConfigArtifactEdit;
+
+public class FacesConfigExtensionTestCase extends BaseWriteTestCase {
+ private final static String EXTENDED_FACES_CONFIG_ID = "extended-faces-config-id";
+
+ private static final String FACES_CONFIG = "faces-config";
+
+ private final static String FACES_CONFIG_EXTENSION = CommonStructuresUtil
+ .createPreficedString(FACES_CONFIG, "extension");
+ private final static String FACES_CONFIG_EXTENSION_ID = CommonStructuresUtil
+ .createPreficedString(FACES_CONFIG_EXTENSION, "id");
+ private final static String FACES_CONFIG_EXTENSION_TAG = CommonStructuresUtil
+ .createPreficedString(FACES_CONFIG_EXTENSION, "tag");
+
+ public FacesConfigExtensionTestCase(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ // test should not be used with 1.1
+ assertEquals("1.2", _facesVersion);
+ }
+
+
+
+ public void testFacesConfigExtension() {
+ FacesConfigArtifactEdit edit = null;
+
+ try {
+ edit = getArtifactEditForWrite();
+ assertNotNull(edit.getFacesConfig());
+ FacesConfigPackage facesConfigPackage = FacesConfigPackage.eINSTANCE;
+ FacesConfigFactory facesConfigFactory = facesConfigPackage
+ .getFacesConfigFactory();
+
+ FacesConfigType facesConfigType = edit.getFacesConfig();
+
+ FacesConfigExtensionType extensionType = facesConfigFactory
+ .createFacesConfigExtensionType();
+ extensionType.setId(FACES_CONFIG_EXTENSION_ID);
+
+ extensionType.getChildNodes().add(
+ createDynamicElement(FACES_CONFIG_EXTENSION_TAG));
+
+ facesConfigType.getFacesConfigExtension().add(extensionType);
+
+ edit.save(null);
+ } finally {
+ if (edit != null) {
+ edit.dispose();
+ assertTrue(edit.isDisposed());
+ edit = null;
+ }
+ }
+
+ try {
+ edit = getArtifactEditForRead();
+ assertNotNull(edit.getFacesConfig());
+
+ FacesConfigType facesConfig = edit.getFacesConfig();
+
+ assertEquals(1, facesConfig.getFacesConfigExtension().size());
+ FacesConfigExtensionType extensionType = (FacesConfigExtensionType) facesConfig
+ .getFacesConfigExtension().get(0);
+ assertEquals(FACES_CONFIG_EXTENSION_ID, extensionType.getId());
+
+ assertEquals(1, extensionType.getChildNodes().size());
+ DynamicElement element = (DynamicElement) extensionType
+ .getChildNodes().get(0);
+ assertEquals(FACES_CONFIG_EXTENSION_TAG, element.getName());
+ } finally {
+ if (edit != null) {
+ edit.dispose();
+ }
+ }
+ }
+}
diff --git a/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteApplicationTestCase.java b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteApplicationTestCase.java
index 1570f6e..8f3c7e5 100644
--- a/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteApplicationTestCase.java
+++ b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteApplicationTestCase.java
@@ -10,9 +10,6 @@
**************************************************************************************************/
package org.eclipse.jst.jsf.facesconfig.tests.write;
-import junit.framework.TestCase;
-
-import org.eclipse.core.resources.IProject;
import org.eclipse.jst.jsf.facesconfig.emf.ActionListenerType;
import org.eclipse.jst.jsf.facesconfig.emf.ApplicationType;
import org.eclipse.jst.jsf.facesconfig.emf.DefaultLocaleType;
@@ -27,182 +24,177 @@
import org.eclipse.jst.jsf.facesconfig.emf.SupportedLocaleType;
import org.eclipse.jst.jsf.facesconfig.emf.VariableResolverType;
import org.eclipse.jst.jsf.facesconfig.emf.ViewHandlerType;
-import org.eclipse.jst.jsf.facesconfig.tests.util.WizardUtil;
+import org.eclipse.jst.jsf.facesconfig.tests.util.FacesConfigModelUtil;
import org.eclipse.jst.jsf.facesconfig.util.FacesConfigArtifactEdit;
+
/*
- * This class is used to test wether the writing into the faces-config.xml
- * file is being done propertly and the outputs are as expected
+ * This class is used to test wether the writing into the faces-config.xml file
+ * is being done propertly and the outputs are as expected
*
*/
-public class WriteApplicationTestCase extends TestCase {
- private static final String SUPPORTED_LOCALE_TYPE = "supported-locale-type";
+public class WriteApplicationTestCase extends BaseWriteTestCase {
+ private static final String SUPPORTED_LOCALE_TYPE = "supported-locale-type";
private static final String DEFAULT_LOCALE = "default-locale";
- private static final String WEB_INF_FACES_CONFIG2_XML = "WEB-INF/faces-config2.xml";
-
private final static String actionListener = "action-listener";
private final static String variableResolver = "variable-resolver";
private final static String defaultRenderKitId = "default-render-kit-id";
- private final static String messageBundle= "message-bundle";
+ private final static String messageBundle = "message-bundle";
private final static String navigationHandler = "navigation-handler";
private final static String viewHandler = "view-handler";
- private final static String stateManager="state-manager";
- private final static String propertyResolver="property-resolver";
+ private final static String stateManager = "state-manager";
+ private final static String propertyResolver = "property-resolver";
+
+ private final static String APPLICATION_ID = "application-id";
- IProject project = null;
+ public WriteApplicationTestCase(String name) {
+ super(name);
+ }
- public WriteApplicationTestCase(String name) {
- super(name);
- }
+ /*
+ * Do the writing here to all the attributes
+ *
+ */
+ public void testWriteApplication() {
+ FacesConfigArtifactEdit edit = null;
- protected void setUp() throws Exception {
- super.setUp();
- WizardUtil.createProject(getName());
- project = WizardUtil.getTestProject(getName());
- }
- /*
- * Do the writing here to all the attributes
- *
- */
-
- public void testWriteApplication() {
- FacesConfigArtifactEdit edit2 = null;
-
- try {
- edit2 = FacesConfigArtifactEdit.getFacesConfigArtifactEditForWrite(
- project, WEB_INF_FACES_CONFIG2_XML);
+ try {
+ edit = getArtifactEditForWrite();
+
+ assertNotNull(edit.getFacesConfig());
+
+ FacesConfigPackage facesConfigPackage = FacesConfigPackage.eINSTANCE;
+ FacesConfigFactory facesConfigFactory = facesConfigPackage
+ .getFacesConfigFactory();
+
+ ApplicationType newApplication = facesConfigFactory
+ .createApplicationType();
+ newApplication.setId(APPLICATION_ID);
- assertNotNull(edit2);
- assertNotNull(edit2.getFacesConfig());
-
- FacesConfigPackage facesConfigPackage = FacesConfigPackage.eINSTANCE;
- FacesConfigFactory facesConfigFactory = facesConfigPackage.getFacesConfigFactory();
-
-
- ApplicationType newApplication = facesConfigFactory.createApplicationType();
-
-
- ActionListenerType actionList= facesConfigFactory.createActionListenerType();
- actionList.setTextContent(actionListener);
- newApplication.getActionListener().add(actionList);
-
-
-
- VariableResolverType variableResolverType= facesConfigFactory.createVariableResolverType();
- variableResolverType.setTextContent(variableResolver);
- newApplication.getVariableResolver().add(variableResolverType);
-
-
- DefaultRenderKitIdType renderKitIdType= facesConfigFactory.createDefaultRenderKitIdType();
- renderKitIdType.setTextContent(defaultRenderKitId);
- newApplication.getDefaultRenderKitId().add(renderKitIdType);
-
-
- MessageBundleType messageBundleType= facesConfigFactory.createMessageBundleType();
- messageBundleType.setTextContent(messageBundle);
- newApplication.getMessageBundle().add(messageBundleType);
-
-
- NavigationHandlerType navigationHandlerType= facesConfigFactory.createNavigationHandlerType();
- navigationHandlerType.setTextContent(navigationHandler);
- newApplication.getNavigationHandler().add(navigationHandlerType);
-
-
- ViewHandlerType viewHandlerType= facesConfigFactory.createViewHandlerType();
- viewHandlerType.setTextContent(viewHandler);
- newApplication.getViewHandler().add(viewHandlerType);
-
- StateManagerType stateManagerType= facesConfigFactory.createStateManagerType();
- stateManagerType.setTextContent(stateManager);
- newApplication.getStateManager().add(stateManagerType);
-
-
- PropertyResolverType propertyResolverType= facesConfigFactory.createPropertyResolverType();
- propertyResolverType.setTextContent(propertyResolver);
- newApplication.getPropertyResolver().add(propertyResolverType);
-
-
- LocaleConfigType localConfigType = facesConfigFactory.createLocaleConfigType();
- DefaultLocaleType defaultLocaleType = facesConfigFactory.createDefaultLocaleType();
- defaultLocaleType.setTextContent(DEFAULT_LOCALE);
- localConfigType.setDefaultLocale(defaultLocaleType);
-
- SupportedLocaleType supportedLocalType = facesConfigFactory.createSupportedLocaleType();
- supportedLocalType.setTextContent(SUPPORTED_LOCALE_TYPE);
- localConfigType.getSupportedLocale().add(supportedLocalType);
+ ActionListenerType actionList = facesConfigFactory
+ .createActionListenerType();
+ actionList.setTextContent(actionListener);
+ newApplication.getActionListener().add(actionList);
- newApplication.getLocaleConfig().add(localConfigType);
-
- edit2.getFacesConfig().getApplication().add(newApplication);
- edit2.save(null);
- } finally {
- if (edit2 != null) {
- edit2.dispose();
+ VariableResolverType variableResolverType = facesConfigFactory
+ .createVariableResolverType();
+ variableResolverType.setTextContent(variableResolver);
+ newApplication.getVariableResolver().add(variableResolverType);
+
+ DefaultRenderKitIdType renderKitIdType = facesConfigFactory
+ .createDefaultRenderKitIdType();
+ renderKitIdType.setTextContent(defaultRenderKitId);
+ newApplication.getDefaultRenderKitId().add(renderKitIdType);
+
+ MessageBundleType messageBundleType = facesConfigFactory
+ .createMessageBundleType();
+ messageBundleType.setTextContent(messageBundle);
+ newApplication.getMessageBundle().add(messageBundleType);
+
+ NavigationHandlerType navigationHandlerType = facesConfigFactory
+ .createNavigationHandlerType();
+ navigationHandlerType.setTextContent(navigationHandler);
+ newApplication.getNavigationHandler().add(navigationHandlerType);
+
+ ViewHandlerType viewHandlerType = facesConfigFactory
+ .createViewHandlerType();
+ viewHandlerType.setTextContent(viewHandler);
+ newApplication.getViewHandler().add(viewHandlerType);
+
+ StateManagerType stateManagerType = facesConfigFactory
+ .createStateManagerType();
+ stateManagerType.setTextContent(stateManager);
+ newApplication.getStateManager().add(stateManagerType);
+
+ PropertyResolverType propertyResolverType = facesConfigFactory
+ .createPropertyResolverType();
+ propertyResolverType.setTextContent(propertyResolver);
+ newApplication.getPropertyResolver().add(propertyResolverType);
+
+ LocaleConfigType localConfigType = facesConfigFactory
+ .createLocaleConfigType();
+ DefaultLocaleType defaultLocaleType = facesConfigFactory
+ .createDefaultLocaleType();
+ defaultLocaleType.setTextContent(DEFAULT_LOCALE);
+ localConfigType.setDefaultLocale(defaultLocaleType);
+
+ SupportedLocaleType supportedLocalType = facesConfigFactory
+ .createSupportedLocaleType();
+ supportedLocalType.setTextContent(SUPPORTED_LOCALE_TYPE);
+ localConfigType.getSupportedLocale().add(supportedLocalType);
+
+ newApplication.getLocaleConfig().add(localConfigType);
+
+ edit.getFacesConfig().getApplication().add(newApplication);
+ edit.save(null);
+ } finally {
+ if (edit != null) {
+ edit.dispose();
// assert that the file has been disposed
- assertTrue(edit2.isDisposed());
- edit2 = null;
- }
- }
-
+ assertTrue(edit.isDisposed());
+ edit = null;
+ }
+ }
// now read back the file
- try {
- edit2 = FacesConfigArtifactEdit.getFacesConfigArtifactEditForRead(
- project, WEB_INF_FACES_CONFIG2_XML);
- assertNotNull(edit2);
- assertNotNull(edit2.getFacesConfig());
- assertEquals(1, edit2.getFacesConfig().getApplication().size());
+ try {
+ edit = getArtifactEditForRead();
+ assertNotNull(edit.getFacesConfig());
+
ApplicationType application =
- (ApplicationType) edit2.getFacesConfig().getApplication().get(0);
-
+ (ApplicationType) FacesConfigModelUtil
+ .findEObjectElementById(edit.getFacesConfig().getApplication(), APPLICATION_ID);
+
assertEquals(1, application.getActionListener().size());
- assertEquals(actionListener
- , ((ActionListenerType)application.getActionListener().get(0)).getTextContent());
+ assertEquals(actionListener, ((ActionListenerType) application
+ .getActionListener().get(0)).getTextContent());
assertEquals(1, application.getVariableResolver().size());
- assertEquals(variableResolver
- , ((VariableResolverType)application.getVariableResolver().get(0)).getTextContent());
+ assertEquals(variableResolver, ((VariableResolverType) application
+ .getVariableResolver().get(0)).getTextContent());
assertEquals(1, application.getDefaultRenderKitId().size());
- assertEquals(defaultRenderKitId
- , ((DefaultRenderKitIdType)application.getDefaultRenderKitId().get(0)).getTextContent());
-
+ assertEquals(defaultRenderKitId,
+ ((DefaultRenderKitIdType) application
+ .getDefaultRenderKitId().get(0)).getTextContent());
+
assertEquals(1, application.getMessageBundle().size());
- assertEquals(messageBundle
- , ((MessageBundleType)application.getMessageBundle().get(0)).getTextContent());
-
+ assertEquals(messageBundle, ((MessageBundleType) application
+ .getMessageBundle().get(0)).getTextContent());
+
assertEquals(1, application.getNavigationHandler().size());
- assertEquals(navigationHandler
- , ((NavigationHandlerType)application.getNavigationHandler().get(0)).getTextContent());
+ assertEquals(navigationHandler,
+ ((NavigationHandlerType) application.getNavigationHandler()
+ .get(0)).getTextContent());
assertEquals(1, application.getViewHandler().size());
- assertEquals(viewHandler
- , ((ViewHandlerType)application.getViewHandler().get(0)).getTextContent());
+ assertEquals(viewHandler, ((ViewHandlerType) application
+ .getViewHandler().get(0)).getTextContent());
assertEquals(1, application.getStateManager().size());
- assertEquals(stateManager
- , ((StateManagerType)application.getStateManager().get(0)).getTextContent());
+ assertEquals(stateManager, ((StateManagerType) application
+ .getStateManager().get(0)).getTextContent());
assertEquals(1, application.getPropertyResolver().size());
- assertEquals(propertyResolver
- , ((PropertyResolverType)application.getPropertyResolver().get(0)).getTextContent());
+ assertEquals(propertyResolver, ((PropertyResolverType) application
+ .getPropertyResolver().get(0)).getTextContent());
-
assertEquals(1, application.getLocaleConfig().size());
- LocaleConfigType localConfigType =
- (LocaleConfigType) application.getLocaleConfig().get(0);
+ LocaleConfigType localConfigType = (LocaleConfigType) application
+ .getLocaleConfig().get(0);
- assertEquals(DEFAULT_LOCALE, localConfigType.getDefaultLocale().getTextContent());
+ assertEquals(DEFAULT_LOCALE, localConfigType.getDefaultLocale()
+ .getTextContent());
assertEquals(1, localConfigType.getSupportedLocale().size());
-
- assertEquals(SUPPORTED_LOCALE_TYPE
- , ((SupportedLocaleType)localConfigType.getSupportedLocale().get(0)).getTextContent());
- } finally {
-
- if (edit2 != null) {
- edit2.dispose();
- }
- }
- }
+
+ assertEquals(SUPPORTED_LOCALE_TYPE,
+ ((SupportedLocaleType) localConfigType.getSupportedLocale()
+ .get(0)).getTextContent());
+ } finally {
+ if (edit != null) {
+ edit.dispose();
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteApplicationTestCase_1_2.java b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteApplicationTestCase_1_2.java
new file mode 100644
index 0000000..6ba3f4f
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteApplicationTestCase_1_2.java
@@ -0,0 +1,181 @@
+package org.eclipse.jst.jsf.facesconfig.tests.write;
+
+import org.eclipse.jst.jsf.facesconfig.emf.ApplicationExtensionType;
+import org.eclipse.jst.jsf.facesconfig.emf.ApplicationType;
+import org.eclipse.jst.jsf.facesconfig.emf.BaseNameType;
+import org.eclipse.jst.jsf.facesconfig.emf.DescriptionType;
+import org.eclipse.jst.jsf.facesconfig.emf.DisplayNameType;
+import org.eclipse.jst.jsf.facesconfig.emf.DynamicElement;
+import org.eclipse.jst.jsf.facesconfig.emf.ELResolverType;
+import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory;
+import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage;
+import org.eclipse.jst.jsf.facesconfig.emf.IconType;
+import org.eclipse.jst.jsf.facesconfig.emf.ResourceBundleType;
+import org.eclipse.jst.jsf.facesconfig.emf.VarType;
+import org.eclipse.jst.jsf.facesconfig.tests.util.CommonStructuresUtil;
+import org.eclipse.jst.jsf.facesconfig.tests.util.FacesConfigModelUtil;
+import org.eclipse.jst.jsf.facesconfig.util.FacesConfigArtifactEdit;
+
+public class WriteApplicationTestCase_1_2 extends WriteApplicationTestCase
+{
+ protected final static String APPLICATION_ID_1_2 = "application-id-1_2";
+ protected final static String EL_RESOLVER = "org.test.MyELResolver";
+ protected final static String RESOURCE_BUNDLE = "resourceBundle";
+ protected final static String BASE_NAME = "baseName";
+ protected final static String VAR = "varX";
+ protected final static String APPLICATION_EXTENSION = "application-extension";
+
+ public WriteApplicationTestCase_1_2(String name)
+ {
+ super(name);
+ }
+
+ public void test12Features()
+ {
+ FacesConfigArtifactEdit edit = null;
+
+ try
+ {
+ edit = getArtifactEditForWrite();
+
+ assertNotNull(edit.getFacesConfig());
+
+ FacesConfigPackage facesConfigPackage = FacesConfigPackage.eINSTANCE;
+ FacesConfigFactory facesConfigFactory = facesConfigPackage
+ .getFacesConfigFactory();
+
+ ApplicationType newApplication = facesConfigFactory
+ .createApplicationType();
+ newApplication.setId(APPLICATION_ID_1_2);
+
+ ELResolverType elResolver = facesConfigFactory.createELResolverType();
+ elResolver.setId(CommonStructuresUtil.createPreficedString(EL_RESOLVER, "id"));
+ elResolver.setTextContent(EL_RESOLVER);
+
+ newApplication.getELResolver().add(elResolver);
+
+ ResourceBundleType resourceBundle =
+ facesConfigFactory.createResourceBundleType();
+
+ resourceBundle.getDescription().add(
+ CommonStructuresUtil.createDescription(RESOURCE_BUNDLE));
+ resourceBundle.getDisplayName().add(
+ CommonStructuresUtil.createDisplayName(RESOURCE_BUNDLE));
+ resourceBundle.getIcon().add(
+ CommonStructuresUtil.createIcon(RESOURCE_BUNDLE));
+
+ {
+ BaseNameType baseNameType = facesConfigFactory.createBaseNameType();
+ baseNameType.setId(CommonStructuresUtil.createPreficedString(BASE_NAME, "id"));
+ baseNameType.setTextContent(BASE_NAME);
+ resourceBundle.setBaseName(baseNameType);
+ }
+
+ {
+ VarType varType = facesConfigFactory.createVarType();
+ varType.setId(CommonStructuresUtil.createPreficedString(VAR, "id"));
+ varType.setTextContent(VAR);
+ resourceBundle.setVar(varType);
+ }
+ resourceBundle.setId(CommonStructuresUtil.createPreficedString(RESOURCE_BUNDLE, "id"));
+ newApplication.getResourceBundle().add(resourceBundle);
+
+ ApplicationExtensionType appExt =
+ facesConfigFactory.createApplicationExtensionType();
+ appExt.setId(
+ CommonStructuresUtil.createPreficedString(APPLICATION_EXTENSION, "id"));
+
+ DynamicElement element = createDynamicElement(
+ CommonStructuresUtil.createPreficedString(APPLICATION_EXTENSION, "tag"));
+ appExt.getChildNodes().add(element);
+ newApplication.getApplicationExtension().add(appExt);
+
+ edit.getFacesConfig().getApplication().add(newApplication);
+ edit.save(null);
+ }
+ finally
+ {
+ if (edit != null) {
+ edit.dispose();
+ // assert that the file has been disposed
+ assertTrue(edit.isDisposed());
+ edit = null;
+ }
+ }
+
+ // now read back the file
+ try
+ {
+ edit = getArtifactEditForRead();
+ assertNotNull(edit.getFacesConfig());
+ assertEquals(1, edit.getFacesConfig().getApplication().size());
+ ApplicationType application =
+ (ApplicationType) FacesConfigModelUtil
+ .findEObjectElementById(edit.getFacesConfig().getApplication(), APPLICATION_ID_1_2);
+ assertNotNull(application);
+
+ assertEquals(1, application.getELResolver().size());
+ ELResolverType elResolver = (ELResolverType) application .getELResolver().get(0);
+ assertEquals(CommonStructuresUtil.createPreficedString(EL_RESOLVER, "id"),
+ elResolver.getId());
+ assertEquals(EL_RESOLVER, elResolver.getTextContent());
+
+ assertEquals(1, application.getResourceBundle().size());
+ ResourceBundleType resourceBundle =
+ (ResourceBundleType) application.getResourceBundle().get(0);
+
+ assertEquals(1, resourceBundle.getDescription().size());
+ CommonStructuresUtil.assertMatchesDescription
+ (RESOURCE_BUNDLE, (DescriptionType) resourceBundle.getDescription().get(0));
+
+ assertEquals(1, resourceBundle.getDisplayName().size());
+ CommonStructuresUtil.assertMatchesDisplayName
+ (RESOURCE_BUNDLE, (DisplayNameType) resourceBundle.getDisplayName().get(0));
+
+ assertEquals(1, resourceBundle.getIcon().size());
+ CommonStructuresUtil.assertMatchesIcon
+ (RESOURCE_BUNDLE, (IconType) resourceBundle.getIcon().get(0));
+
+ {
+ BaseNameType baseNameType = resourceBundle.getBaseName();
+ assertEquals(CommonStructuresUtil.createPreficedString(BASE_NAME, "id"),
+ baseNameType.getId());
+ assertEquals(BASE_NAME, baseNameType.getTextContent());
+ }
+
+ {
+ VarType varType = resourceBundle.getVar();
+ assertEquals(CommonStructuresUtil.createPreficedString(VAR, "id"),
+ varType.getId());
+ assertEquals(VAR, varType.getTextContent());
+
+ }
+ assertEquals(CommonStructuresUtil.createPreficedString(RESOURCE_BUNDLE, "id"),
+ resourceBundle.getId());
+
+ ApplicationExtensionType appExt =
+ (ApplicationExtensionType) FacesConfigModelUtil
+ .findEObjectElementById(application.getApplicationExtension()
+ , CommonStructuresUtil.createPreficedString(APPLICATION_EXTENSION, "id"));
+
+ assertEquals(1, appExt.getChildNodes().size());
+ DynamicElement element =
+ (DynamicElement) appExt.getChildNodes().get(0);
+ assertEquals(CommonStructuresUtil.createPreficedString(APPLICATION_EXTENSION, "tag")
+ ,element.getName());
+ }
+ finally
+ {
+ if (edit != null)
+ {
+ edit.dispose();
+ }
+ }
+ }
+
+// private ApplicationType getApplication(FacesConfigType facesConfig)
+// {
+// FacesConfigModelUtil
+// }
+}
+
diff --git a/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteComponentExtensionDataTestCase.java b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteComponentExtensionDataTestCase.java
index 8307c0f..81c45e5 100644
--- a/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteComponentExtensionDataTestCase.java
+++ b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteComponentExtensionDataTestCase.java
@@ -1,8 +1,5 @@
package org.eclipse.jst.jsf.facesconfig.tests.write;
-import junit.framework.TestCase;
-
-import org.eclipse.core.resources.IProject;
import org.eclipse.jst.jsf.facesconfig.emf.ComponentClassType;
import org.eclipse.jst.jsf.facesconfig.emf.ComponentExtensionType;
import org.eclipse.jst.jsf.facesconfig.emf.ComponentType;
@@ -12,42 +9,26 @@
import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory;
import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage;
import org.eclipse.jst.jsf.facesconfig.tests.util.CommonStructuresUtil;
-import org.eclipse.jst.jsf.facesconfig.tests.util.WizardUtil;
import org.eclipse.jst.jsf.facesconfig.util.FacesConfigArtifactEdit;
-import org.eclipse.jst.jsf.test.util.JSFTestUtil;
-public class WriteComponentExtensionDataTestCase extends TestCase {
+public class WriteComponentExtensionDataTestCase extends BaseWriteTestCase {
private static final String COMPONENT = "component";
private static final String COMPONENT_CLASS = "component-class";
private static final String COMPONENT_TYPE = "component-type";
- private static final String WEB_INF_FACES_CONFIG1_XML = "WEB-INF/faces-config1.xml";
-
- IProject project = null;
-
public WriteComponentExtensionDataTestCase(String name) {
super(name);
}
- protected void setUp() throws Exception {
- super.setUp();
- JSFTestUtil.setValidationEnabled(false);
-
- JSFTestUtil.setInternetProxyPreferences(true, "www-proxy.uk.oracle.com", "80");
-
- WizardUtil.createProject(getName());
- project = WizardUtil.getTestProject(getName());
- }
public void testWriteExtensionData()
{
FacesConfigArtifactEdit edit = null;
try
{
- edit = FacesConfigArtifactEdit.getFacesConfigArtifactEditForWrite(
- project, WEB_INF_FACES_CONFIG1_XML);
+ edit = getArtifactEditForWrite();
assertNotNull(edit.getFacesConfig());
FacesConfigPackage facesConfigPackage = FacesConfigPackage.eINSTANCE;
FacesConfigFactory facesConfigFactory = facesConfigPackage
diff --git a/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteComponentTestCase.java b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteComponentTestCase.java
index 58ecd2c..2cf30b8 100644
--- a/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteComponentTestCase.java
+++ b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteComponentTestCase.java
@@ -10,9 +10,6 @@
**************************************************************************************************/
package org.eclipse.jst.jsf.facesconfig.tests.write;
-import junit.framework.TestCase;
-
-import org.eclipse.core.resources.IProject;
import org.eclipse.jst.jsf.facesconfig.emf.AttributeType;
import org.eclipse.jst.jsf.facesconfig.emf.ComponentClassType;
import org.eclipse.jst.jsf.facesconfig.emf.ComponentExtensionType;
@@ -27,11 +24,10 @@
import org.eclipse.jst.jsf.facesconfig.emf.IconType;
import org.eclipse.jst.jsf.facesconfig.emf.PropertyType;
import org.eclipse.jst.jsf.facesconfig.tests.util.CommonStructuresUtil;
-import org.eclipse.jst.jsf.facesconfig.tests.util.WizardUtil;
import org.eclipse.jst.jsf.facesconfig.util.FacesConfigArtifactEdit;
-public class WriteComponentTestCase extends TestCase {
+public class WriteComponentTestCase extends BaseWriteTestCase {
private static final String COMPONENT = "component";
@@ -39,25 +35,14 @@
private static final String COMPONENT_TYPE = "component-type";
- private static final String WEB_INF_FACES_CONFIG1_XML = "WEB-INF/faces-config1.xml";
-
- IProject project = null;
-
public WriteComponentTestCase(String name) {
super(name);
}
- protected void setUp() throws Exception {
- super.setUp();
- WizardUtil.createProject(getName());
- project = WizardUtil.getTestProject(getName());
- }
-
public void testWriteComponent() {
FacesConfigArtifactEdit edit = null;
try {
- edit = FacesConfigArtifactEdit.getFacesConfigArtifactEditForWrite(
- project, WEB_INF_FACES_CONFIG1_XML);
+ edit = getArtifactEditForWrite();
assertNotNull(edit.getFacesConfig());
FacesConfigPackage facesConfigPackage = FacesConfigPackage.eINSTANCE;
FacesConfigFactory facesConfigFactory = facesConfigPackage
@@ -115,8 +100,7 @@
}
try {
- edit = FacesConfigArtifactEdit.getFacesConfigArtifactEditForRead(
- project, WEB_INF_FACES_CONFIG1_XML);
+ edit = getArtifactEditForRead();
assertNotNull(edit.getFacesConfig());
assertEquals(1, edit.getFacesConfig().getComponent().size());
diff --git a/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteConverterTestCase.java b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteConverterTestCase.java
index e623490..7009418 100644
--- a/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteConverterTestCase.java
+++ b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteConverterTestCase.java
@@ -10,9 +10,6 @@
**************************************************************************************************/
package org.eclipse.jst.jsf.facesconfig.tests.write;
-import junit.framework.TestCase;
-
-import org.eclipse.core.resources.IProject;
import org.eclipse.jst.jsf.facesconfig.emf.ConverterClassType;
import org.eclipse.jst.jsf.facesconfig.emf.ConverterForClassType;
import org.eclipse.jst.jsf.facesconfig.emf.ConverterIdType;
@@ -23,38 +20,28 @@
import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage;
import org.eclipse.jst.jsf.facesconfig.emf.IconType;
import org.eclipse.jst.jsf.facesconfig.tests.util.CommonStructuresUtil;
-import org.eclipse.jst.jsf.facesconfig.tests.util.WizardUtil;
+import org.eclipse.jst.jsf.facesconfig.tests.util.FacesConfigModelUtil;
import org.eclipse.jst.jsf.facesconfig.util.FacesConfigArtifactEdit;
-public class WriteConverterTestCase extends TestCase {
- private static final String WEB_INF_FACES_CONFIG2_XML = "WEB-INF/faces-config2.xml";
- IProject project = null;
-
- private static final String CONVERTER = "converter";
+public class WriteConverterTestCase extends BaseWriteTestCase {
+ protected static final String CONVERTER = "converter";
private static final String CONVERTER_CLASS =
CommonStructuresUtil.createPreficedString(CONVERTER, CommonStructuresUtil.CLASS);
private static final String CONVERTER_CLASS_FOR =
CommonStructuresUtil.createPreficedString(CONVERTER
, CommonStructuresUtil.createPreficedString(CommonStructuresUtil.CLASS, "for"));
- private static final String CONVERTER_ID =
+ protected static final String CONVERTER_ID =
CommonStructuresUtil.createPreficedString(CONVERTER, CommonStructuresUtil.ID);
public WriteConverterTestCase(String name) {
super(name);
}
- protected void setUp() throws Exception {
- super.setUp();
- WizardUtil.createProject(getName());
- project = WizardUtil.getTestProject(getName());
- }
-
public void testWriteConverter() {
FacesConfigArtifactEdit edit = null;
try {
- edit = FacesConfigArtifactEdit.getFacesConfigArtifactEditForWrite(
- project, WEB_INF_FACES_CONFIG2_XML);
+ edit = getArtifactEditForWrite();
assertNotNull(edit.getFacesConfig());
FacesConfigPackage facesConfigPackage = FacesConfigPackage.eINSTANCE;
FacesConfigFactory facesConfigFactory = facesConfigPackage.getFacesConfigFactory();
@@ -91,8 +78,7 @@
converter.getAttribute().add(CommonStructuresUtil.createAttribute(CONVERTER));
converter.getProperty().add(CommonStructuresUtil.createProperty(CONVERTER));
- converter.setId(CommonStructuresUtil.createPreficedString(CONVERTER
- , CommonStructuresUtil.ID));
+ converter.setId(CONVERTER_ID);
edit.getFacesConfig().getConverter().add(converter);
edit.save(null);
@@ -105,14 +91,14 @@
}
try {
- edit = FacesConfigArtifactEdit.getFacesConfigArtifactEditForRead(
- project, WEB_INF_FACES_CONFIG2_XML);
+ edit = getArtifactEditForRead();
assertNotNull(edit.getFacesConfig());
- assertEquals(1, edit.getFacesConfig().getConverter().size());
ConverterType converter =
- (ConverterType) edit.getFacesConfig().getConverter().get(0);
-
+ (ConverterType) FacesConfigModelUtil
+ .findEObjectElementById(edit.getFacesConfig().getConverter(), CONVERTER_ID);
+ assertNotNull(converter);
+
assertEquals(1, converter.getDescription().size());
CommonStructuresUtil.assertMatchesDescription
(CONVERTER, (DescriptionType) converter.getDescription().get(0));
diff --git a/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteConverterTestCase_1_2.java b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteConverterTestCase_1_2.java
new file mode 100644
index 0000000..b9225fe
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteConverterTestCase_1_2.java
@@ -0,0 +1,84 @@
+package org.eclipse.jst.jsf.facesconfig.tests.write;
+
+import org.eclipse.jst.jsf.facesconfig.emf.ConverterExtensionType;
+import org.eclipse.jst.jsf.facesconfig.emf.ConverterType;
+import org.eclipse.jst.jsf.facesconfig.emf.DynamicElement;
+import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory;
+import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage;
+import org.eclipse.jst.jsf.facesconfig.tests.util.CommonStructuresUtil;
+import org.eclipse.jst.jsf.facesconfig.tests.util.FacesConfigModelUtil;
+import org.eclipse.jst.jsf.facesconfig.util.FacesConfigArtifactEdit;
+
+public class WriteConverterTestCase_1_2 extends WriteConverterTestCase {
+
+ private final static String EXTENDED_CONVERTER_ID = "extended-converter-id";
+
+ private final static String CONVERTER_EXTENSION = CommonStructuresUtil
+ .createPreficedString(CONVERTER, "extension");
+ private final static String CONVERTER_EXTENSION_ID = CommonStructuresUtil
+ .createPreficedString(CONVERTER_EXTENSION, "id");
+ private final static String CONVERTER_EXTENSION_TAG = CommonStructuresUtil
+ .createPreficedString(CONVERTER_EXTENSION, "tag");
+
+ public WriteConverterTestCase_1_2(String name) {
+ super(name);
+ }
+
+ public void testConverterExtension() {
+ FacesConfigArtifactEdit edit = null;
+
+ try {
+ edit = getArtifactEditForWrite();
+ assertNotNull(edit.getFacesConfig());
+ FacesConfigPackage facesConfigPackage = FacesConfigPackage.eINSTANCE;
+ FacesConfigFactory facesConfigFactory = facesConfigPackage
+ .getFacesConfigFactory();
+
+ ConverterType converter = facesConfigFactory.createConverterType();
+ converter.setId(EXTENDED_CONVERTER_ID);
+
+ ConverterExtensionType extensionType =
+ facesConfigFactory.createConverterExtensionType();
+ extensionType.setId(CONVERTER_EXTENSION_ID);
+
+ extensionType.getChildNodes().add(createDynamicElement(CONVERTER_EXTENSION_TAG));
+
+ converter.getConverterExtension().add(extensionType);
+ edit.getFacesConfig().getConverter().add(converter);
+ edit.save(null);
+ } finally {
+ if (edit != null) {
+ edit.dispose();
+ assertTrue(edit.isDisposed());
+ edit = null;
+ }
+ }
+
+ try
+ {
+ edit = getArtifactEditForRead();
+ assertNotNull(edit.getFacesConfig());
+
+ ConverterType converter =
+ (ConverterType) FacesConfigModelUtil
+ .findEObjectElementById(edit.getFacesConfig().getConverter(), EXTENDED_CONVERTER_ID);
+ assertNotNull(converter);
+
+ assertEquals(1, converter.getConverterExtension().size());
+ ConverterExtensionType extensionType =
+ (ConverterExtensionType) converter.getConverterExtension().get(0);
+ assertEquals(CONVERTER_EXTENSION_ID, extensionType.getId());
+
+ assertEquals(1, extensionType.getChildNodes().size());
+ DynamicElement element = (DynamicElement) extensionType.getChildNodes().get(0);
+ assertEquals(CONVERTER_EXTENSION_TAG, element.getName());
+ }
+ finally
+ {
+
+ if (edit != null) {
+ edit.dispose();
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteFactoryTestCase.java b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteFactoryTestCase.java
index 8e9910b..15f2b4b 100644
--- a/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteFactoryTestCase.java
+++ b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteFactoryTestCase.java
@@ -10,9 +10,6 @@
**************************************************************************************************/
package org.eclipse.jst.jsf.facesconfig.tests.write;
-import junit.framework.TestCase;
-
-import org.eclipse.core.resources.IProject;
import org.eclipse.jst.jsf.facesconfig.emf.ApplicationFactoryType;
import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory;
import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage;
@@ -21,38 +18,30 @@
import org.eclipse.jst.jsf.facesconfig.emf.LifecycleFactoryType;
import org.eclipse.jst.jsf.facesconfig.emf.RenderKitFactoryType;
import org.eclipse.jst.jsf.facesconfig.tests.util.CommonStructuresUtil;
-import org.eclipse.jst.jsf.facesconfig.tests.util.WizardUtil;
+import org.eclipse.jst.jsf.facesconfig.tests.util.FacesConfigModelUtil;
import org.eclipse.jst.jsf.facesconfig.util.FacesConfigArtifactEdit;
/*
* This Junit class is used to test the FacesConfigFactoryImpl
* class.
*/
-public class WriteFactoryTestCase extends TestCase {
- private static final String WEB_INF_FACES_CONFIG2_XML = "WEB-INF/faces-config2.xml";
- IProject project = null;
-
- private final static String FACTORY = "factory";
+public class WriteFactoryTestCase extends BaseWriteTestCase {
+ protected final static String FACTORY = "factory";
private final static String APPLICATION_FACTORY = "application-factory";
private final static String FACESCONTEXT_FACTORY = "faces-context-factory";
private final static String LIFECYCLE_FACTORY = "lifecycle-factory";
private final static String RENDERKIT_FACTORY = "render-kit-factory";
+ private final static String FACTORY_ID = CommonStructuresUtil
+ .createPreficedString(FACTORY, CommonStructuresUtil.ID);
public WriteFactoryTestCase(String name) {
super(name);
}
- protected void setUp() throws Exception {
- super.setUp();
- WizardUtil.createProject(getName());
- project = WizardUtil.getTestProject(getName());
- }
-
- public void testWriteFacesconfigFile() {
+ public void testFactory() {
FacesConfigArtifactEdit edit = null;
try {
- edit = FacesConfigArtifactEdit.getFacesConfigArtifactEditForWrite(
- project, WEB_INF_FACES_CONFIG2_XML);
+ edit = getArtifactEditForWrite();
assertNotNull(edit.getFacesConfig());
FacesConfigPackage facesConfigPackage = FacesConfigPackage.eINSTANCE;
FacesConfigFactory facesConfigFactory = facesConfigPackage.getFacesConfigFactory();
@@ -90,13 +79,11 @@
.createPreficedString(RENDERKIT_FACTORY, CommonStructuresUtil.ID));
newfactory.getRenderKitFactory().add(renderKit);
}
-
- newfactory.setId(CommonStructuresUtil
- .createPreficedString(FACTORY, CommonStructuresUtil.ID));
-
+
+ newfactory.setId(FACTORY_ID);
+
edit.getFacesConfig().getFactory().add(newfactory);
edit.save(null);
-
} finally {
if (edit != null) {
edit.dispose();
@@ -106,14 +93,14 @@
}
try {
- edit = FacesConfigArtifactEdit.getFacesConfigArtifactEditForRead(
- project, WEB_INF_FACES_CONFIG2_XML);
+ edit = getArtifactEditForRead();
assertNotNull(edit.getFacesConfig());
- assertEquals(1, edit.getFacesConfig().getFactory().size());
-
FactoryType newFactory =
- (FactoryType) edit.getFacesConfig().getFactory().get(0);
+ (FactoryType) FacesConfigModelUtil
+ .findEObjectElementById(
+ edit.getFacesConfig().getFactory(), FACTORY_ID);
+ assertNotNull(newFactory);
{
assertEquals(1, newFactory.getApplicationFactory().size());
diff --git a/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteFactoryTestCase_1_2.java b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteFactoryTestCase_1_2.java
new file mode 100644
index 0000000..dc33f1e
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteFactoryTestCase_1_2.java
@@ -0,0 +1,83 @@
+package org.eclipse.jst.jsf.facesconfig.tests.write;
+
+import org.eclipse.jst.jsf.facesconfig.emf.DynamicElement;
+import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory;
+import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage;
+import org.eclipse.jst.jsf.facesconfig.emf.FactoryExtensionType;
+import org.eclipse.jst.jsf.facesconfig.emf.FactoryType;
+import org.eclipse.jst.jsf.facesconfig.tests.util.CommonStructuresUtil;
+import org.eclipse.jst.jsf.facesconfig.tests.util.FacesConfigModelUtil;
+import org.eclipse.jst.jsf.facesconfig.util.FacesConfigArtifactEdit;
+
+public class WriteFactoryTestCase_1_2 extends WriteFactoryTestCase {
+ private final static String EXTENDED_FACTORY_ID = "extended-factory-id";
+
+ private final static String FACTORY_EXTENSION = CommonStructuresUtil
+ .createPreficedString(FACTORY, "extension");
+ private final static String FACTORY_EXTENSION_ID = CommonStructuresUtil
+ .createPreficedString(FACTORY_EXTENSION, "id");
+ private final static String FACTORY_EXTENSION_TAG = CommonStructuresUtil
+ .createPreficedString(FACTORY_EXTENSION, "tag");
+
+ public WriteFactoryTestCase_1_2(String name) {
+ super(name);
+ }
+
+ public void testFactoryExtension() {
+ FacesConfigArtifactEdit edit = null;
+
+ try {
+ edit = getArtifactEditForWrite();
+ assertNotNull(edit.getFacesConfig());
+ FacesConfigPackage facesConfigPackage = FacesConfigPackage.eINSTANCE;
+ FacesConfigFactory facesConfigFactory = facesConfigPackage
+ .getFacesConfigFactory();
+
+ FactoryType factory = facesConfigFactory.createFactoryType();
+ factory.setId(EXTENDED_FACTORY_ID);
+
+ FactoryExtensionType extensionType =
+ facesConfigFactory.createFactoryExtensionType();
+ extensionType.setId(FACTORY_EXTENSION_ID);
+
+ extensionType.getChildNodes().add(createDynamicElement(FACTORY_EXTENSION_TAG));
+
+ factory.getFactoryExtension().add(extensionType);
+ edit.getFacesConfig().getFactory().add(factory);
+ edit.save(null);
+ } finally {
+ if (edit != null) {
+ edit.dispose();
+ assertTrue(edit.isDisposed());
+ edit = null;
+ }
+ }
+
+ try
+ {
+ edit = getArtifactEditForRead();
+ assertNotNull(edit.getFacesConfig());
+
+ FactoryType factory =
+ (FactoryType) FacesConfigModelUtil
+ .findEObjectElementById(edit.getFacesConfig().getFactory(), EXTENDED_FACTORY_ID);
+ assertNotNull(factory);
+
+ assertEquals(1, factory.getFactoryExtension().size());
+ FactoryExtensionType extensionType =
+ (FactoryExtensionType) factory.getFactoryExtension().get(0);
+ assertEquals(FACTORY_EXTENSION_ID, extensionType.getId());
+
+ assertEquals(1, extensionType.getChildNodes().size());
+ DynamicElement element = (DynamicElement) extensionType.getChildNodes().get(0);
+ assertEquals(FACTORY_EXTENSION_TAG, element.getName());
+ }
+ finally
+ {
+
+ if (edit != null) {
+ edit.dispose();
+ }
+ }
+ }
+}
diff --git a/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteLifecycleTestCase.java b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteLifecycleTestCase.java
index 072d025..0f2766b 100644
--- a/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteLifecycleTestCase.java
+++ b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteLifecycleTestCase.java
@@ -10,40 +10,30 @@
**************************************************************************************************/
package org.eclipse.jst.jsf.facesconfig.tests.write;
-import junit.framework.TestCase;
-
-import org.eclipse.core.resources.IProject;
import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory;
import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage;
import org.eclipse.jst.jsf.facesconfig.emf.LifecycleType;
import org.eclipse.jst.jsf.facesconfig.emf.PhaseListenerType;
import org.eclipse.jst.jsf.facesconfig.tests.util.CommonStructuresUtil;
-import org.eclipse.jst.jsf.facesconfig.tests.util.WizardUtil;
+import org.eclipse.jst.jsf.facesconfig.tests.util.FacesConfigModelUtil;
import org.eclipse.jst.jsf.facesconfig.util.FacesConfigArtifactEdit;
-public class WriteLifecycleTestCase extends TestCase {
- private static final String WEB_INF_FACES_CONFIG2_XML = "WEB-INF/faces-config2.xml";
- IProject project = null;
-
- private final static String LIFECYCLE = "lifecycle";
+public class WriteLifecycleTestCase extends BaseWriteTestCase
+{
+ protected final static String LIFECYCLE = "lifecycle";
private final static String PHASELISTENER = "phase-listener";
+ private final static String LIFECYCLE_ID =
+ CommonStructuresUtil.createPreficedString(LIFECYCLE, CommonStructuresUtil.ID);
public WriteLifecycleTestCase(String name) {
super(name);
}
- protected void setUp() throws Exception {
- super.setUp();
- WizardUtil.createProject(getName());
- project = WizardUtil.getTestProject(getName());
- }
-
public void testWriteLifecycle() {
FacesConfigArtifactEdit edit = null;
try {
- edit = FacesConfigArtifactEdit.getFacesConfigArtifactEditForWrite(
- project, WEB_INF_FACES_CONFIG2_XML);
+ edit = getArtifactEditForWrite();
assertNotNull(edit.getFacesConfig());
FacesConfigPackage facesConfigPackage = FacesConfigPackage.eINSTANCE;
FacesConfigFactory facesConfigFactory = facesConfigPackage
@@ -58,8 +48,7 @@
PHASELISTENER, CommonStructuresUtil.ID));
newLifecycle.getPhaseListener().add(newPhaseListener);
- newLifecycle.setId(CommonStructuresUtil.createPreficedString(
- LIFECYCLE, CommonStructuresUtil.ID));
+ newLifecycle.setId(LIFECYCLE_ID);
edit.getFacesConfig().getLifecycle().add(newLifecycle);
edit.save(null);
@@ -72,13 +61,14 @@
}
try {
- edit = FacesConfigArtifactEdit.getFacesConfigArtifactEditForRead(
- project, WEB_INF_FACES_CONFIG2_XML);
+ edit = getArtifactEditForRead();
assertNotNull(edit.getFacesConfig());
- assertEquals(1, edit.getFacesConfig().getLifecycle().size());
LifecycleType newLifecycle =
- (LifecycleType) edit.getFacesConfig().getLifecycle().get(0);
+ (LifecycleType) FacesConfigModelUtil
+ .findEObjectElementById(
+ edit.getFacesConfig().getLifecycle(), LIFECYCLE_ID);
+ assertNotNull(newLifecycle);
assertEquals(1, newLifecycle.getPhaseListener().size());
PhaseListenerType newPhaseListener =
diff --git a/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteLifecycleTestCase_1_2.java b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteLifecycleTestCase_1_2.java
new file mode 100644
index 0000000..a492fb6
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteLifecycleTestCase_1_2.java
@@ -0,0 +1,81 @@
+package org.eclipse.jst.jsf.facesconfig.tests.write;
+
+import org.eclipse.jst.jsf.facesconfig.emf.DynamicElement;
+import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory;
+import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage;
+import org.eclipse.jst.jsf.facesconfig.emf.LifecycleExtensionType;
+import org.eclipse.jst.jsf.facesconfig.emf.LifecycleType;
+import org.eclipse.jst.jsf.facesconfig.tests.util.CommonStructuresUtil;
+import org.eclipse.jst.jsf.facesconfig.tests.util.FacesConfigModelUtil;
+import org.eclipse.jst.jsf.facesconfig.util.FacesConfigArtifactEdit;
+
+public class WriteLifecycleTestCase_1_2 extends WriteLifecycleTestCase {
+ private final static String EXTENDED_LIFECYCLE_ID = "extended-lifecycle-id";
+
+ private final static String LIFECYCLE_EXTENSION = CommonStructuresUtil
+ .createPreficedString(LIFECYCLE, "extension");
+ private final static String LIFECYCLE_EXTENSION_ID = CommonStructuresUtil
+ .createPreficedString(LIFECYCLE_EXTENSION, "id");
+ private final static String LIFECYCLE_EXTENSION_TAG = CommonStructuresUtil
+ .createPreficedString(LIFECYCLE_EXTENSION, "tag");
+
+ public WriteLifecycleTestCase_1_2(String name) {
+ super(name);
+ }
+
+ public void testLifecycleExtension() {
+ FacesConfigArtifactEdit edit = null;
+
+ try {
+ edit = getArtifactEditForWrite();
+ assertNotNull(edit.getFacesConfig());
+ FacesConfigPackage facesConfigPackage = FacesConfigPackage.eINSTANCE;
+ FacesConfigFactory facesConfigFactory = facesConfigPackage
+ .getFacesConfigFactory();
+
+ LifecycleType lifecycle = facesConfigFactory.createLifecycleType();
+ lifecycle.setId(EXTENDED_LIFECYCLE_ID);
+
+ LifecycleExtensionType extensionType = facesConfigFactory
+ .createLifecycleExtensionType();
+ extensionType.setId(LIFECYCLE_EXTENSION_ID);
+
+ extensionType.getChildNodes().add(
+ createDynamicElement(LIFECYCLE_EXTENSION_TAG));
+
+ lifecycle.getLifecycleExtension().add(extensionType);
+ edit.getFacesConfig().getLifecycle().add(lifecycle);
+ edit.save(null);
+ } finally {
+ if (edit != null) {
+ edit.dispose();
+ assertTrue(edit.isDisposed());
+ edit = null;
+ }
+ }
+
+ try {
+ edit = getArtifactEditForRead();
+ assertNotNull(edit.getFacesConfig());
+
+ LifecycleType lifecycle = (LifecycleType) FacesConfigModelUtil
+ .findEObjectElementById(edit.getFacesConfig()
+ .getLifecycle(), EXTENDED_LIFECYCLE_ID);
+ assertNotNull(lifecycle);
+
+ assertEquals(1, lifecycle.getLifecycleExtension().size());
+ LifecycleExtensionType extensionType = (LifecycleExtensionType) lifecycle
+ .getLifecycleExtension().get(0);
+ assertEquals(LIFECYCLE_EXTENSION_ID, extensionType.getId());
+
+ assertEquals(1, extensionType.getChildNodes().size());
+ DynamicElement element = (DynamicElement) extensionType
+ .getChildNodes().get(0);
+ assertEquals(LIFECYCLE_EXTENSION_TAG, element.getName());
+ } finally {
+ if (edit != null) {
+ edit.dispose();
+ }
+ }
+ }
+}
diff --git a/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteManagedBeanTestCase.java b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteManagedBeanTestCase.java
index eefe202..0544933 100644
--- a/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteManagedBeanTestCase.java
+++ b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteManagedBeanTestCase.java
@@ -10,9 +10,6 @@
**************************************************************************************************/
package org.eclipse.jst.jsf.facesconfig.tests.write;
-import junit.framework.TestCase;
-
-import org.eclipse.core.resources.IProject;
import org.eclipse.jst.jsf.facesconfig.emf.DescriptionType;
import org.eclipse.jst.jsf.facesconfig.emf.DisplayNameType;
import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory;
@@ -28,15 +25,12 @@
import org.eclipse.jst.jsf.facesconfig.emf.NullValueType;
import org.eclipse.jst.jsf.facesconfig.emf.ValueType;
import org.eclipse.jst.jsf.facesconfig.tests.util.CommonStructuresUtil;
-import org.eclipse.jst.jsf.facesconfig.tests.util.WizardUtil;
import org.eclipse.jst.jsf.facesconfig.util.FacesConfigArtifactEdit;
-public class WriteManagedBeanTestCase extends TestCase {
- private static final String WEB_INF_FACES_CONFIG2_XML = "WEB-INF/faces-config2.xml";
- IProject project = null;
-
- private final static String MANAGED_BEAN = "managed-bean";
+public class WriteManagedBeanTestCase extends BaseWriteTestCase {
+
+ protected final static String MANAGED_BEAN = "managed-bean";
private final static String SCOPE = "scope";
private final static String MANAGED_BEAN_NAME =
CommonStructuresUtil.createPreficedString(MANAGED_BEAN, CommonStructuresUtil.NAME);
@@ -53,15 +47,11 @@
protected void setUp() throws Exception {
super.setUp();
- WizardUtil.createProject(getName());
- project = WizardUtil.getTestProject(getName());
-
FacesConfigArtifactEdit edit = null;
try
{
edit =
- FacesConfigArtifactEdit.getFacesConfigArtifactEditForWrite(
- project, WEB_INF_FACES_CONFIG2_XML);
+ getArtifactEditForWrite();
edit.getFacesConfig().getManagedBean().clear();
edit.save(null);
}
@@ -79,8 +69,7 @@
FacesConfigArtifactEdit edit = null;
try {
- edit = FacesConfigArtifactEdit.getFacesConfigArtifactEditForWrite(
- project, WEB_INF_FACES_CONFIG2_XML);
+ edit = getArtifactEditForWrite();
assertNotNull(edit.getFacesConfig());
FacesConfigPackage facesConfigPackage = FacesConfigPackage.eINSTANCE;
FacesConfigFactory facesConfigFactory = facesConfigPackage.getFacesConfigFactory();
@@ -149,8 +138,7 @@
}
try {
- edit = FacesConfigArtifactEdit.getFacesConfigArtifactEditForRead(
- project, WEB_INF_FACES_CONFIG2_XML);
+ edit = getArtifactEditForRead();
assertNotNull(edit.getFacesConfig());
assertEquals(1, edit.getFacesConfig().getManagedBean().size());
@@ -228,8 +216,7 @@
try
{
- edit = FacesConfigArtifactEdit.getFacesConfigArtifactEditForWrite(
- project, WEB_INF_FACES_CONFIG2_XML);
+ edit = getArtifactEditForWrite();
assertNotNull(edit.getFacesConfig());
ManagedBeanType managedBean = createManagedBeanBase();
@@ -250,8 +237,7 @@
try
{
- edit = FacesConfigArtifactEdit.getFacesConfigArtifactEditForRead(
- project, WEB_INF_FACES_CONFIG2_XML);
+ edit = getArtifactEditForRead();
assertNotNull(edit.getFacesConfig());
assertEquals(1, edit.getFacesConfig().getManagedBean().size());
@@ -277,8 +263,7 @@
try
{
- edit = FacesConfigArtifactEdit.getFacesConfigArtifactEditForWrite(
- project, WEB_INF_FACES_CONFIG2_XML);
+ edit = getArtifactEditForWrite();
assertNotNull(edit.getFacesConfig());
ManagedBeanType managedBean = createManagedBeanBase();
@@ -298,8 +283,7 @@
try
{
- edit = FacesConfigArtifactEdit.getFacesConfigArtifactEditForRead(
- project, WEB_INF_FACES_CONFIG2_XML);
+ edit = getArtifactEditForRead();
assertNotNull(edit.getFacesConfig());
assertEquals(1, edit.getFacesConfig().getManagedBean().size());
diff --git a/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteManagedBeanTestCase_1_2.java b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteManagedBeanTestCase_1_2.java
new file mode 100644
index 0000000..2e58e37
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteManagedBeanTestCase_1_2.java
@@ -0,0 +1,82 @@
+package org.eclipse.jst.jsf.facesconfig.tests.write;
+
+import org.eclipse.jst.jsf.facesconfig.emf.DynamicElement;
+import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory;
+import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage;
+import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanExtensionType;
+import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanType;
+import org.eclipse.jst.jsf.facesconfig.tests.util.CommonStructuresUtil;
+import org.eclipse.jst.jsf.facesconfig.tests.util.FacesConfigModelUtil;
+import org.eclipse.jst.jsf.facesconfig.util.FacesConfigArtifactEdit;
+
+public class WriteManagedBeanTestCase_1_2 extends WriteManagedBeanTestCase {
+ private final static String EXTENDED_MANAGED_BEAN_ID = "extended-managed-bean-id";
+
+ private final static String MANAGED_BEAN_EXTENSION = CommonStructuresUtil
+ .createPreficedString(MANAGED_BEAN, "extension");
+ private final static String MANAGED_BEAN_EXTENSION_ID = CommonStructuresUtil
+ .createPreficedString(MANAGED_BEAN_EXTENSION, "id");
+ private final static String MANAGED_BEAN_EXTENSION_TAG = CommonStructuresUtil
+ .createPreficedString(MANAGED_BEAN_EXTENSION, "tag");
+
+ public WriteManagedBeanTestCase_1_2(String name) {
+ super(name);
+ }
+
+ public void testManagedBeanExtension() {
+ FacesConfigArtifactEdit edit = null;
+
+ try {
+ edit = getArtifactEditForWrite();
+ assertNotNull(edit.getFacesConfig());
+ FacesConfigPackage facesConfigPackage = FacesConfigPackage.eINSTANCE;
+ FacesConfigFactory facesConfigFactory = facesConfigPackage
+ .getFacesConfigFactory();
+
+ ManagedBeanType managedBean = facesConfigFactory.createManagedBeanType();
+ managedBean.setId(EXTENDED_MANAGED_BEAN_ID);
+
+ ManagedBeanExtensionType extensionType = facesConfigFactory
+ .createManagedBeanExtensionType();
+ extensionType.setId(MANAGED_BEAN_EXTENSION_ID);
+
+ extensionType.getChildNodes().add(
+ createDynamicElement(MANAGED_BEAN_EXTENSION_TAG));
+
+ managedBean.getManagedBeanExtension().add(extensionType);
+ edit.getFacesConfig().getManagedBean().add(managedBean);
+ edit.save(null);
+ } finally {
+ if (edit != null) {
+ edit.dispose();
+ assertTrue(edit.isDisposed());
+ edit = null;
+ }
+ }
+
+ try {
+ edit = getArtifactEditForRead();
+ assertNotNull(edit.getFacesConfig());
+
+ ManagedBeanType managedBean = (ManagedBeanType) FacesConfigModelUtil
+ .findEObjectElementById(edit.getFacesConfig()
+ .getManagedBean(), EXTENDED_MANAGED_BEAN_ID);
+ assertNotNull(managedBean);
+
+ assertEquals(1, managedBean.getManagedBeanExtension().size());
+ ManagedBeanExtensionType extensionType = (ManagedBeanExtensionType) managedBean
+ .getManagedBeanExtension().get(0);
+ assertEquals(MANAGED_BEAN_EXTENSION_ID, extensionType.getId());
+
+ assertEquals(1, extensionType.getChildNodes().size());
+ DynamicElement element = (DynamicElement) extensionType
+ .getChildNodes().get(0);
+ assertEquals(MANAGED_BEAN_EXTENSION_TAG, element.getName());
+ } finally {
+ if (edit != null) {
+ edit.dispose();
+ }
+ }
+ }
+
+}
diff --git a/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteNavigationRuleTestCase.java b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteNavigationRuleTestCase.java
index f3bacd0..76c1159 100644
--- a/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteNavigationRuleTestCase.java
+++ b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteNavigationRuleTestCase.java
@@ -10,9 +10,6 @@
**************************************************************************************************/
package org.eclipse.jst.jsf.facesconfig.tests.write;
-import junit.framework.TestCase;
-
-import org.eclipse.core.resources.IProject;
import org.eclipse.jst.jsf.facesconfig.emf.DescriptionType;
import org.eclipse.jst.jsf.facesconfig.emf.DisplayNameType;
import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory;
@@ -25,15 +22,17 @@
import org.eclipse.jst.jsf.facesconfig.emf.NavigationRuleType;
import org.eclipse.jst.jsf.facesconfig.emf.ToViewIdType;
import org.eclipse.jst.jsf.facesconfig.tests.util.CommonStructuresUtil;
-import org.eclipse.jst.jsf.facesconfig.tests.util.WizardUtil;
+import org.eclipse.jst.jsf.facesconfig.tests.util.FacesConfigModelUtil;
import org.eclipse.jst.jsf.facesconfig.util.FacesConfigArtifactEdit;
-public class WriteNavigationRuleTestCase extends TestCase {
- private static final String NAVIGATION_RULE = "navigation-rule";
+public class WriteNavigationRuleTestCase extends BaseWriteTestCase {
+ protected static final String NAVIGATION_RULE = "navigation-rule";
private static final String FROM_VIEW_ID = "from-view-id";
private static final String FROM_VIEW_ID_ID =
CommonStructuresUtil.createPreficedString(FROM_VIEW_ID, CommonStructuresUtil.ID);
+ private static final String NAVIGATION_RULE_ID =
+ CommonStructuresUtil.createPreficedString(NAVIGATION_RULE, CommonStructuresUtil.ID);
private static final String NAVIGATION_CASE = "navigation-case";
private static final String FROM_ACTION = "from-action";
@@ -45,25 +44,16 @@
private static final String TO_VIEW_ID = "from-view-id";
private static final String NAVIGATION_CASE_TO_VIEW_ID =
CommonStructuresUtil.createPreficedString(NAVIGATION_CASE,TO_VIEW_ID);
-
-
- IProject project = null;
public WriteNavigationRuleTestCase(String name) {
super(name);
}
- protected void setUp() throws Exception {
- super.setUp();
- WizardUtil.createProject(getName());
- project = WizardUtil.getTestProject(getName());
- }
- public void testWriteNavigationCase() {
+ public void testWriteNavigationRule() {
FacesConfigArtifactEdit edit = null;
try {
- edit = FacesConfigArtifactEdit.getFacesConfigArtifactEditForWrite(
- project, "WEB-INF/faces-config2.xml");
+ edit = getArtifactEditForWrite();
assertNotNull(edit.getFacesConfig());
FacesConfigPackage facesConfigPackage = FacesConfigPackage.eINSTANCE;
@@ -75,7 +65,6 @@
navigationRule.getDisplayName().add(CommonStructuresUtil.createDisplayName(NAVIGATION_RULE));
navigationRule.getIcon().add(CommonStructuresUtil.createIcon(NAVIGATION_RULE));
-
FromViewIdType fromViewIdType = facesConfigFactory.createFromViewIdType();
fromViewIdType.setTextContent(FROM_VIEW_ID);
fromViewIdType.setId(FROM_VIEW_ID_ID);
@@ -115,7 +104,7 @@
}
navigationRule.getNavigationCase().add(navCaseType);
- navigationRule.setId(CommonStructuresUtil.createPreficedString(NAVIGATION_RULE, CommonStructuresUtil.ID));
+ navigationRule.setId(NAVIGATION_RULE_ID);
edit.getFacesConfig().getNavigationRule().add(navigationRule);
edit.save(null);
@@ -129,13 +118,15 @@
try
{
- edit = FacesConfigArtifactEdit.getFacesConfigArtifactEditForWrite(
- project, "WEB-INF/faces-config2.xml");
+ edit = getArtifactEditForRead();
assertNotNull(edit.getFacesConfig());
- assertEquals(1, edit.getFacesConfig().getNavigationRule().size());
- NavigationRuleType navigationRule = (NavigationRuleType)
- edit.getFacesConfig().getNavigationRule().get(0);
+ NavigationRuleType navigationRule =
+ (NavigationRuleType) FacesConfigModelUtil
+ .findEObjectElementById(
+ edit.getFacesConfig().getNavigationRule(), NAVIGATION_RULE_ID);
+ assertNotNull(navigationRule);
+
assertEquals(1, navigationRule.getDescription().size());
CommonStructuresUtil.assertMatchesDescription
diff --git a/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteNavigationRuleTestCase_1_2.java b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteNavigationRuleTestCase_1_2.java
new file mode 100644
index 0000000..776715b
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteNavigationRuleTestCase_1_2.java
@@ -0,0 +1,87 @@
+package org.eclipse.jst.jsf.facesconfig.tests.write;
+
+import org.eclipse.jst.jsf.facesconfig.emf.DynamicElement;
+import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory;
+import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage;
+import org.eclipse.jst.jsf.facesconfig.emf.NavigationRuleExtensionType;
+import org.eclipse.jst.jsf.facesconfig.emf.NavigationRuleType;
+import org.eclipse.jst.jsf.facesconfig.tests.util.CommonStructuresUtil;
+import org.eclipse.jst.jsf.facesconfig.tests.util.FacesConfigModelUtil;
+import org.eclipse.jst.jsf.facesconfig.util.FacesConfigArtifactEdit;
+
+/**
+ * @author cbateman
+ *
+ */
+public class WriteNavigationRuleTestCase_1_2 extends
+ WriteNavigationRuleTestCase {
+ private final static String EXTENDED_NAVIGATION_RULE_ID = "extended-navigation-rule-id";
+
+ private final static String NAVIGATION_RULE_EXTENSION = CommonStructuresUtil
+ .createPreficedString(NAVIGATION_RULE, "extension");
+ private final static String NAVIGATION_RULE_EXTENSION_ID = CommonStructuresUtil
+ .createPreficedString(NAVIGATION_RULE_EXTENSION, "id");
+ private final static String NAVIGATION_RULE_EXTENSION_TAG = CommonStructuresUtil
+ .createPreficedString(NAVIGATION_RULE_EXTENSION, "tag");
+
+ public WriteNavigationRuleTestCase_1_2(String name) {
+ super(name);
+ }
+
+ public void testNavigationRuleExtension() {
+ FacesConfigArtifactEdit edit = null;
+
+ try {
+ edit = getArtifactEditForWrite();
+ assertNotNull(edit.getFacesConfig());
+ FacesConfigPackage facesConfigPackage = FacesConfigPackage.eINSTANCE;
+ FacesConfigFactory facesConfigFactory = facesConfigPackage
+ .getFacesConfigFactory();
+
+ NavigationRuleType navigationRule = facesConfigFactory.createNavigationRuleType();
+ navigationRule.setId(EXTENDED_NAVIGATION_RULE_ID);
+
+ NavigationRuleExtensionType extensionType = facesConfigFactory
+ .createNavigationRuleExtensionType();
+ extensionType.setId(NAVIGATION_RULE_EXTENSION_ID);
+
+ extensionType.getChildNodes().add(
+ createDynamicElement(NAVIGATION_RULE_EXTENSION_TAG));
+
+ navigationRule.getNavigationRuleExtension().add(extensionType);
+ edit.getFacesConfig().getNavigationRule().add(navigationRule);
+ edit.save(null);
+ } finally {
+ if (edit != null) {
+ edit.dispose();
+ assertTrue(edit.isDisposed());
+ edit = null;
+ }
+ }
+
+ try {
+ edit = getArtifactEditForRead();
+ assertNotNull(edit.getFacesConfig());
+
+ NavigationRuleType navigationRule = (NavigationRuleType) FacesConfigModelUtil
+ .findEObjectElementById(edit.getFacesConfig()
+ .getNavigationRule(), EXTENDED_NAVIGATION_RULE_ID);
+ assertNotNull(navigationRule);
+
+ assertEquals(1, navigationRule.getNavigationRuleExtension().size());
+ NavigationRuleExtensionType extensionType = (NavigationRuleExtensionType) navigationRule
+ .getNavigationRuleExtension().get(0);
+ assertEquals(NAVIGATION_RULE_EXTENSION_ID, extensionType.getId());
+
+ assertEquals(1, extensionType.getChildNodes().size());
+ DynamicElement element = (DynamicElement) extensionType
+ .getChildNodes().get(0);
+ assertEquals(NAVIGATION_RULE_EXTENSION_TAG, element.getName());
+ } finally {
+ if (edit != null) {
+ edit.dispose();
+ }
+ }
+ }
+
+}
diff --git a/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteReferencedBeanTestCase.java b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteReferencedBeanTestCase.java
index fbed9ff..0ec475f 100644
--- a/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteReferencedBeanTestCase.java
+++ b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteReferencedBeanTestCase.java
@@ -10,9 +10,6 @@
**************************************************************************************************/
package org.eclipse.jst.jsf.facesconfig.tests.write;
-import junit.framework.TestCase;
-
-import org.eclipse.core.resources.IProject;
import org.eclipse.jst.jsf.facesconfig.emf.DescriptionType;
import org.eclipse.jst.jsf.facesconfig.emf.DisplayNameType;
import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory;
@@ -22,15 +19,10 @@
import org.eclipse.jst.jsf.facesconfig.emf.ReferencedBeanNameType;
import org.eclipse.jst.jsf.facesconfig.emf.ReferencedBeanType;
import org.eclipse.jst.jsf.facesconfig.tests.util.CommonStructuresUtil;
-import org.eclipse.jst.jsf.facesconfig.tests.util.WizardUtil;
import org.eclipse.jst.jsf.facesconfig.util.FacesConfigArtifactEdit;
-public class WriteReferencedBeanTestCase extends TestCase {
- private static final String WEB_INF_FACES_CONFIG2_XML = "WEB-INF/faces-config2.xml";
-
- IProject project = null;
-
+public class WriteReferencedBeanTestCase extends BaseWriteTestCase {
private final static String REFERENCED_BEAN = "referenced-bean";
private final static String REFERENCED_BEAN_NAME =
CommonStructuresUtil.createPreficedString(REFERENCED_BEAN, CommonStructuresUtil.NAME);
@@ -41,20 +33,13 @@
super(name);
}
- protected void setUp() throws Exception {
- super.setUp();
- WizardUtil.createProject(getName());
- project = WizardUtil.getTestProject(getName());
- }
-
public void testWriteReferencedBeanToFileTwo()
{
FacesConfigArtifactEdit edit = null;
try
{
- edit = FacesConfigArtifactEdit.getFacesConfigArtifactEditForWrite(
- project, WEB_INF_FACES_CONFIG2_XML);
+ edit = getArtifactEditForWrite();
assertNotNull(edit.getFacesConfig());
FacesConfigPackage facesConfigPackage = FacesConfigPackage.eINSTANCE;
@@ -101,8 +86,7 @@
try
{
- edit = FacesConfigArtifactEdit.getFacesConfigArtifactEditForRead(
- project, WEB_INF_FACES_CONFIG2_XML);
+ edit = getArtifactEditForRead();
assertNotNull(edit.getFacesConfig());
assertEquals(1, edit.getFacesConfig().getReferencedBean().size());
diff --git a/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteRenderKitTestCase.java b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteRenderKitTestCase.java
index 7ce1f22..4536838 100644
--- a/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteRenderKitTestCase.java
+++ b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteRenderKitTestCase.java
@@ -10,9 +10,6 @@
**************************************************************************************************/
package org.eclipse.jst.jsf.facesconfig.tests.write;
-import junit.framework.TestCase;
-
-import org.eclipse.core.resources.IProject;
import org.eclipse.jst.jsf.facesconfig.emf.AttributeType;
import org.eclipse.jst.jsf.facesconfig.emf.ComponentFamilyType;
import org.eclipse.jst.jsf.facesconfig.emf.DescriptionType;
@@ -28,15 +25,15 @@
import org.eclipse.jst.jsf.facesconfig.emf.RendererType;
import org.eclipse.jst.jsf.facesconfig.emf.RendererTypeType;
import org.eclipse.jst.jsf.facesconfig.tests.util.CommonStructuresUtil;
-import org.eclipse.jst.jsf.facesconfig.tests.util.WizardUtil;
+import org.eclipse.jst.jsf.facesconfig.tests.util.FacesConfigModelUtil;
import org.eclipse.jst.jsf.facesconfig.util.FacesConfigArtifactEdit;
-public class WriteRenderKitTestCase extends TestCase
+public class WriteRenderKitTestCase extends BaseWriteTestCase
{
- IProject project = null;
-
- private final static String RENDER_KIT = "render-kit";
+ protected final static String RENDER_KIT = "render-kit";
+ private final static String RENDER_KIT_ID =
+ CommonStructuresUtil.createPreficedString(RENDER_KIT, CommonStructuresUtil.ID);
private final static String RENDER_KIT_CLASS =
CommonStructuresUtil.createPreficedString(RENDER_KIT, CommonStructuresUtil.CLASS);
private final static String RENDERER = "renderer";
@@ -52,20 +49,13 @@
super(name);
}
- protected void setUp() throws Exception {
- super.setUp();
- WizardUtil.createProject(getName());
- project = WizardUtil.getTestProject(getName());
- }
-
public void testWriteRenderKit() {
//IProject project = WizardUtil.getTestProject();
FacesConfigArtifactEdit edit = null;
try
{
- edit = FacesConfigArtifactEdit.getFacesConfigArtifactEditForWrite(
- project, "WEB-INF/faces-config2.xml");
+ edit = getArtifactEditForWrite();
assertNotNull(edit.getFacesConfig());
FacesConfigPackage facesConfigPackage = FacesConfigPackage.eINSTANCE;
FacesConfigFactory facesConfigFactory = facesConfigPackage.getFacesConfigFactory();
@@ -128,7 +118,7 @@
renderer.setId(CommonStructuresUtil.createPreficedString(RENDERER, CommonStructuresUtil.ID));
renderKit.getRenderer().add(renderer);
- renderKit.setId(CommonStructuresUtil.createPreficedString(RENDER_KIT, CommonStructuresUtil.ID));
+ renderKit.setId(RENDER_KIT_ID);
edit.getFacesConfig().getRenderKit().add(renderKit);
edit.save(null);
@@ -141,13 +131,13 @@
}
try {
- edit = FacesConfigArtifactEdit.getFacesConfigArtifactEditForRead(
- project, "WEB-INF/faces-config2.xml");
+ edit = getArtifactEditForRead();
assertNotNull(edit.getFacesConfig());
- assertEquals(1, edit.getFacesConfig().getRenderKit().size());
- RenderKitType renderKit =
- (RenderKitType) edit.getFacesConfig().getRenderKit().get(0);
+ RenderKitType renderKit = (RenderKitType) FacesConfigModelUtil
+ .findEObjectElementById(edit.getFacesConfig()
+ .getRenderKit(), RENDER_KIT_ID);
+ assertNotNull(renderKit);
assertEquals(1, renderKit.getDescription().size());
CommonStructuresUtil.assertMatchesDescription(RENDER_KIT,
diff --git a/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteRenderKitTestCase_1_2.java b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteRenderKitTestCase_1_2.java
new file mode 100644
index 0000000..6ba5be5
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteRenderKitTestCase_1_2.java
@@ -0,0 +1,83 @@
+package org.eclipse.jst.jsf.facesconfig.tests.write;
+
+import org.eclipse.jst.jsf.facesconfig.emf.DynamicElement;
+import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory;
+import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage;
+import org.eclipse.jst.jsf.facesconfig.emf.RenderKitExtensionType;
+import org.eclipse.jst.jsf.facesconfig.emf.RenderKitType;
+import org.eclipse.jst.jsf.facesconfig.tests.util.CommonStructuresUtil;
+import org.eclipse.jst.jsf.facesconfig.tests.util.FacesConfigModelUtil;
+import org.eclipse.jst.jsf.facesconfig.util.FacesConfigArtifactEdit;
+
+public class WriteRenderKitTestCase_1_2 extends WriteRenderKitTestCase
+{
+ private final static String EXTENDED_RENDERKIT_ID = "extended-renderkit-rule-id";
+
+ private final static String RENDERKIT_EXTENSION = CommonStructuresUtil
+ .createPreficedString(RENDER_KIT, "extension");
+ private final static String RENDERKIT_EXTENSION_ID = CommonStructuresUtil
+ .createPreficedString(RENDERKIT_EXTENSION, "id");
+ private final static String RENDERKIT_EXTENSION_TAG = CommonStructuresUtil
+ .createPreficedString(RENDERKIT_EXTENSION, "tag");
+
+ public WriteRenderKitTestCase_1_2(String name) {
+ super(name);
+ }
+
+ public void testRenderKitExtension() {
+ FacesConfigArtifactEdit edit = null;
+
+ try {
+ edit = getArtifactEditForWrite();
+ assertNotNull(edit.getFacesConfig());
+ FacesConfigPackage facesConfigPackage = FacesConfigPackage.eINSTANCE;
+ FacesConfigFactory facesConfigFactory = facesConfigPackage
+ .getFacesConfigFactory();
+
+ RenderKitType renderKit = facesConfigFactory.createRenderKitType();
+ renderKit.setId(EXTENDED_RENDERKIT_ID);
+
+ RenderKitExtensionType extensionType = facesConfigFactory
+ .createRenderKitExtensionType();
+ extensionType.setId(RENDERKIT_EXTENSION_ID);
+
+ extensionType.getChildNodes().add(
+ createDynamicElement(RENDERKIT_EXTENSION_TAG));
+
+ renderKit.getRenderKitExtension().add(extensionType);
+ edit.getFacesConfig().getRenderKit().add(renderKit);
+ edit.save(null);
+ } finally {
+ if (edit != null) {
+ edit.dispose();
+ assertTrue(edit.isDisposed());
+ edit = null;
+ }
+ }
+
+ try {
+ edit = getArtifactEditForRead();
+ assertNotNull(edit.getFacesConfig());
+
+ RenderKitType renderKit = (RenderKitType) FacesConfigModelUtil
+ .findEObjectElementById(edit.getFacesConfig()
+ .getRenderKit(), EXTENDED_RENDERKIT_ID);
+ assertNotNull(renderKit);
+
+ assertEquals(1, renderKit.getRenderKitExtension().size());
+ RenderKitExtensionType extensionType = (RenderKitExtensionType) renderKit
+ .getRenderKitExtension().get(0);
+ assertEquals(RENDERKIT_EXTENSION_ID, extensionType.getId());
+
+ assertEquals(1, extensionType.getChildNodes().size());
+ DynamicElement element = (DynamicElement) extensionType
+ .getChildNodes().get(0);
+ assertEquals(RENDERKIT_EXTENSION_TAG, element.getName());
+ } finally {
+ if (edit != null) {
+ edit.dispose();
+ }
+ }
+ }
+
+}
diff --git a/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteValidatorTestCase.java b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteValidatorTestCase.java
index ec1e4ec..17e4293 100644
--- a/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteValidatorTestCase.java
+++ b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteValidatorTestCase.java
@@ -10,8 +10,6 @@
**************************************************************************************************/
package org.eclipse.jst.jsf.facesconfig.tests.write;
-import junit.framework.TestCase;
-
import org.eclipse.core.resources.IProject;
import org.eclipse.jst.jsf.facesconfig.emf.AttributeType;
import org.eclipse.jst.jsf.facesconfig.emf.DescriptionType;
@@ -24,14 +22,14 @@
import org.eclipse.jst.jsf.facesconfig.emf.ValidatorIdType;
import org.eclipse.jst.jsf.facesconfig.emf.ValidatorType;
import org.eclipse.jst.jsf.facesconfig.tests.util.CommonStructuresUtil;
+import org.eclipse.jst.jsf.facesconfig.tests.util.FacesConfigModelUtil;
import org.eclipse.jst.jsf.facesconfig.tests.util.WizardUtil;
import org.eclipse.jst.jsf.facesconfig.util.FacesConfigArtifactEdit;
-public class WriteValidatorTestCase extends TestCase {
- private static final String WEB_INF_FACES_CONFIG2_XML = "WEB-INF/faces-config2.xml";
+public class WriteValidatorTestCase extends BaseWriteTestCase {
IProject project = null;
- private final static String VALIDATOR = "validator";
+ protected final static String VALIDATOR = "validator";
private final static String VALIDATOR_CLASS =
CommonStructuresUtil.createPreficedString(VALIDATOR, CommonStructuresUtil.CLASS);
private final static String VALIDATOR_ID =
@@ -52,8 +50,7 @@
try
{
- edit = FacesConfigArtifactEdit.getFacesConfigArtifactEditForWrite(
- project, WEB_INF_FACES_CONFIG2_XML);
+ edit = getArtifactEditForWrite();
assertNotNull(edit.getFacesConfig());
FacesConfigPackage facesConfigPackage = FacesConfigPackage.eINSTANCE;
@@ -89,7 +86,7 @@
validator.getProperty().add(
CommonStructuresUtil.createProperty(VALIDATOR));
- validator.setId(CommonStructuresUtil.createPreficedString(VALIDATOR, CommonStructuresUtil.ID));
+ validator.setId(VALIDATOR_ID);
edit.getFacesConfig().getValidator().add(validator);
edit.save(null);
@@ -103,13 +100,13 @@
try
{
- edit = FacesConfigArtifactEdit.getFacesConfigArtifactEditForRead(
- project, WEB_INF_FACES_CONFIG2_XML);
+ edit = getArtifactEditForRead();
assertNotNull(edit.getFacesConfig());
- assertEquals(1, edit.getFacesConfig().getValidator().size());
- ValidatorType validator =
- (ValidatorType) edit.getFacesConfig().getValidator().get(0);
+ ValidatorType validator = (ValidatorType) FacesConfigModelUtil
+ .findEObjectElementById(edit.getFacesConfig()
+ .getValidator(), VALIDATOR_ID);
+ assertNotNull(validator);
{
ValidatorIdType validatorIdType = validator.getValidatorId();
diff --git a/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteValidatorTestCase_1_2.java b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteValidatorTestCase_1_2.java
new file mode 100644
index 0000000..37534e9
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/src/org/eclipse/jst/jsf/facesconfig/tests/write/WriteValidatorTestCase_1_2.java
@@ -0,0 +1,81 @@
+package org.eclipse.jst.jsf.facesconfig.tests.write;
+
+import org.eclipse.jst.jsf.facesconfig.emf.DynamicElement;
+import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory;
+import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage;
+import org.eclipse.jst.jsf.facesconfig.emf.ValidatorExtensionType;
+import org.eclipse.jst.jsf.facesconfig.emf.ValidatorType;
+import org.eclipse.jst.jsf.facesconfig.tests.util.CommonStructuresUtil;
+import org.eclipse.jst.jsf.facesconfig.tests.util.FacesConfigModelUtil;
+import org.eclipse.jst.jsf.facesconfig.util.FacesConfigArtifactEdit;
+
+public class WriteValidatorTestCase_1_2 extends WriteValidatorTestCase {
+ private final static String EXTENDED_VALIDATOR_ID = "extended-validator-id";
+
+ private final static String VALIDATOR_EXTENSION = CommonStructuresUtil
+ .createPreficedString(VALIDATOR, "extension");
+ private final static String VALIDATOR_EXTENSION_ID = CommonStructuresUtil
+ .createPreficedString(VALIDATOR_EXTENSION, "id");
+ private final static String VALIDATOR_EXTENSION_TAG = CommonStructuresUtil
+ .createPreficedString(VALIDATOR_EXTENSION, "tag");
+
+ public WriteValidatorTestCase_1_2(String name) {
+ super(name);
+ }
+
+ public void testValidatorExtension() {
+ FacesConfigArtifactEdit edit = null;
+
+ try {
+ edit = getArtifactEditForWrite();
+ assertNotNull(edit.getFacesConfig());
+ FacesConfigPackage facesConfigPackage = FacesConfigPackage.eINSTANCE;
+ FacesConfigFactory facesConfigFactory = facesConfigPackage
+ .getFacesConfigFactory();
+
+ ValidatorType validator = facesConfigFactory.createValidatorType();
+ validator.setId(EXTENDED_VALIDATOR_ID);
+
+ ValidatorExtensionType extensionType = facesConfigFactory
+ .createValidatorExtensionType();
+ extensionType.setId(VALIDATOR_EXTENSION_ID);
+
+ extensionType.getChildNodes().add(
+ createDynamicElement(VALIDATOR_EXTENSION_TAG));
+
+ validator.getValidatorExtension().add(extensionType);
+ edit.getFacesConfig().getValidator().add(validator);
+ edit.save(null);
+ } finally {
+ if (edit != null) {
+ edit.dispose();
+ assertTrue(edit.isDisposed());
+ edit = null;
+ }
+ }
+
+ try {
+ edit = getArtifactEditForRead();
+ assertNotNull(edit.getFacesConfig());
+
+ ValidatorType validator = (ValidatorType) FacesConfigModelUtil
+ .findEObjectElementById(edit.getFacesConfig()
+ .getValidator(), EXTENDED_VALIDATOR_ID);
+ assertNotNull(validator);
+
+ assertEquals(1, validator.getValidatorExtension().size());
+ ValidatorExtensionType extensionType = (ValidatorExtensionType) validator
+ .getValidatorExtension().get(0);
+ assertEquals(VALIDATOR_EXTENSION_ID, extensionType.getId());
+
+ assertEquals(1, extensionType.getChildNodes().size());
+ DynamicElement element = (DynamicElement) extensionType
+ .getChildNodes().get(0);
+ assertEquals(VALIDATOR_EXTENSION_TAG, element.getName());
+ } finally {
+ if (edit != null) {
+ edit.dispose();
+ }
+ }
+ }
+}
diff --git a/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/template/faces-config1.xml b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/template/faces-config1.xml
index d369f6c..acd2ea6 100644
--- a/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/template/faces-config1.xml
+++ b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/template/faces-config1.xml
@@ -13,8 +13,5 @@
<faces-config>
- <lifecycle>
- <phase-listener>test1</phase-listener>
- </lifecycle>
-
+
</faces-config>
diff --git a/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/template/faces-config2.xml b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/template/faces-config2.xml
index 894a088..81e3131 100644
--- a/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/template/faces-config2.xml
+++ b/jsf/tests/org.eclipse.jst.jsf.facesconfig.tests/template/faces-config2.xml
@@ -1,16 +1,14 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright 2003 Sun Microsystems, Inc. All rights reserved.
- SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
--->
+<faces-config
+ xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-facesconfig_1_2.xsd"
+ version="1.2">
-<!DOCTYPE faces-config PUBLIC
- "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
- "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
<!-- =========== FULL CONFIGURATION FILE ================================== -->
-<faces-config>
+
</faces-config>