org.apache.deltaspike.jsf.api.config.view.View Java Examples
The following examples show how to use
org.apache.deltaspike.jsf.api.config.view.View.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ViewConfigPathValidator.java From deltaspike with Apache License 2.0 | 6 votes |
@Override public void contextInitialized(ServletContextEvent sce) { if (ClassDeactivationUtils.isActivated(getClass())) { ViewConfigResolver viewConfigResolver; try { viewConfigResolver = BeanProvider.getContextualReference(ViewConfigResolver.class); } catch (Exception e) { LOGGER.log(Level.WARNING, "Container issue detected -> can't validate view-configs. " + "This exception is usually the effect (but not the reason) of a failed startup. " + "You can deactivate " + getClass().getName() + " via a custom " + ClassDeactivator.class.getName() + " to verify it.", e); return; } List<String> supportedExtensions = new ArrayList<String>(); supportedExtensions.add(View.Extension.XHTML); supportedExtensions.add(View.Extension.JSP); validateViewConfigPaths(sce, viewConfigResolver, supportedExtensions); } }
Example #2
Source File: ViewConfigTest.java From deltaspike with Apache License 2.0 | 6 votes |
@Test public void testMetaDataTreeCustomViewConfigPreProcessor() { this.viewConfigExtension.addPageDefinition(Pages.Public.Index.class); ViewConfigNode node = this.viewConfigExtension.findNode(Pages.Public.Index.class); Assert.assertNotNull(node); Assert.assertNotNull(node.getParent()); Assert.assertNotNull(node.getParent().getParent()); Assert.assertNotNull(node.getParent().getParent().getParent()); Assert.assertNull(node.getParent().getParent().getParent().getParent()); Assert.assertNotNull(node.getMetaData()); Assert.assertEquals(1, node.getMetaData().size()); Assert.assertEquals(View.class, node.getMetaData().iterator().next().annotationType()); Assert.assertEquals(View.ViewParameterMode.INCLUDE, ((View)node.getMetaData().iterator().next()).viewParams()); }
Example #3
Source File: ViewConfigBasePathValidationTest.java From deltaspike with Apache License 2.0 | 6 votes |
@Test public void testInvalidBasePathUsage() { this.viewConfigExtension.addPageDefinition(PagesViolation.Wizard1.Start.class); try { this.viewConfigResolverProducer.createViewConfigResolver(); } catch (IllegalStateException e) { if (!(e.getMessage().contains(View.class.getName()) && e.getMessage().contains(Folder.class.getName())&& e.getMessage().contains("#basePath"))) { Assert.fail("unexpected violation message found"); } return; } Assert.fail("violation not found"); }
Example #4
Source File: DefaultConfigNodeConverter.java From deltaspike with Apache License 2.0 | 6 votes |
protected void validateAnnotationChange(Annotation annotation) { Class<? extends Annotation> annotationType = annotation.annotationType(); if (Folder.class.equals(annotationType) || View.class.equals(annotationType)) { return; } ViewMetaData viewMetaData = annotationType.getAnnotation(ViewMetaData.class); if (viewMetaData == null) { return; } Aggregated aggregated = viewMetaData.annotationType().getAnnotation(Aggregated.class); if (aggregated != null && aggregated.value()) { throw new IllegalStateException("it isn't supported to change aggregated meta-data," + "because inheritance won't work correctly"); } }
Example #5
Source File: ViewConfigPathValidatorTest.java From deltaspike with Apache License 2.0 | 6 votes |
@Test public void testValidViewConfig() { this.viewConfigExtension.addPageDefinition(Pages.Index.class); ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver(); List<String> supportedExtensions = new ArrayList<String>(); supportedExtensions.add(View.Extension.XHTML); try { new MockedViewConfigPathValidator(true).validateViewConfigPaths(null, viewConfigResolver, supportedExtensions); } catch (Exception e) { Assert.fail("valid view-config was reported as invalid"); } }
Example #6
Source File: ViewConfigPathValidatorTest.java From deltaspike with Apache License 2.0 | 6 votes |
@Test public void testMissingPathButUnsupportedExtension() { this.viewConfigExtension.addPageDefinition(Pages.Index.class); ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver(); List<String> supportedExtensions = new ArrayList<String>(); supportedExtensions.add(View.Extension.JSF); try { new MockedViewConfigPathValidator(false).validateViewConfigPaths(null, viewConfigResolver, supportedExtensions); } catch (Exception e) { Assert.fail("unsupported extension wasn't ignored"); } }
Example #7
Source File: ViewConfigTest.java From deltaspike with Apache License 2.0 | 6 votes |
@Test public void testSimpleViewConfigWithOptionalPageMetaData() { this.viewConfigExtension.addPageDefinition(SimplePageConfig001.class); ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver(); ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(SimplePageConfig001.class); Assert.assertNotNull(viewConfigDescriptor); Assert.assertEquals("/simplePageConfig001.xhtml", viewConfigDescriptor.getViewId()); Assert.assertEquals(SimplePageConfig001.class, viewConfigDescriptor.getConfigClass()); Assert.assertNotNull(viewConfigDescriptor.getMetaData()); //@View gets added autom. if it isn't provided in-/directly Assert.assertEquals(1, viewConfigDescriptor.getMetaData().size()); Assert.assertEquals(1, viewConfigDescriptor.getMetaData(View.class).size()); }
Example #8
Source File: ViewConfigTest.java From deltaspike with Apache License 2.0 | 6 votes |
@Test public void testSimpleViewConfigWithExplicitPageMetaData() { this.viewConfigExtension.addPageDefinition(SimplePageConfig002.class); ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver(); ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(SimplePageConfig002.class); Assert.assertNotNull(viewConfigDescriptor); Assert.assertEquals("/simplePageConfig002.xhtml", viewConfigDescriptor.getViewId()); Assert.assertEquals(SimplePageConfig002.class, viewConfigDescriptor.getConfigClass()); Assert.assertNotNull(viewConfigDescriptor.getMetaData()); Assert.assertEquals(1, viewConfigDescriptor.getMetaData().size()); Assert.assertEquals(1, viewConfigDescriptor.getMetaData(View.class).size()); }
Example #9
Source File: ViewConfigTest.java From deltaspike with Apache License 2.0 | 5 votes |
@Test public void testSimpleViewConfigWithCustomMetaData() { this.viewConfigExtension.addPageDefinition(SimplePageConfig.class); ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver(); ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(SimplePageConfig.class); Assert.assertNotNull(viewConfigDescriptor); Assert.assertNotNull(viewConfigDescriptor.getMetaData()); Assert.assertEquals(2, viewConfigDescriptor.getMetaData().size()); Assert.assertEquals(1, viewConfigDescriptor.getMetaData(View.class).size()); Assert.assertEquals(1, viewConfigDescriptor.getMetaData(TestEntryPoint.class).size()); }
Example #10
Source File: ViewConfigTest.java From deltaspike with Apache License 2.0 | 5 votes |
@Test public void testViewConfigCustomViewConfigPreProcessor() { this.viewConfigExtension.addPageDefinition(Pages.Public.Index.class); ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver(); ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Public.Index.class); //changed by TestConfigPreProcessor Assert.assertEquals("/test/view.custom", viewConfigDescriptor.getViewId()); Assert.assertEquals(View.ViewParameterMode.DEFAULT, viewConfigDescriptor.getMetaData(View.class).iterator().next().viewParams()); }
Example #11
Source File: ViewConfigTest.java From deltaspike with Apache License 2.0 | 5 votes |
@Test public void testViewConfigWithRandomOrder() { this.viewConfigExtension.addPageDefinition(Pages.Index.class); this.viewConfigExtension.addPageDefinition(Pages.class); //simulates random processing-order ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver(); ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Index.class); Assert.assertEquals("/pages/index.xhtml", viewConfigDescriptor.getViewId()); Assert.assertEquals(View.ViewParameterMode.EXCLUDE, viewConfigDescriptor.getMetaData(View.class).iterator().next().viewParams()); }
Example #12
Source File: ViewConfigTest.java From deltaspike with Apache License 2.0 | 5 votes |
@Test public void testDuplicatedNavigationTargetsInMetaDataTree() { this.viewConfigExtension.addPageDefinition(PagesViolation.Index.class); this.viewConfigExtension.addPageDefinition(PagesViolation.Overview.class); ViewConfigNode node = this.viewConfigExtension.findNode(PagesViolation.Index.class); Assert.assertNotNull(node); Assert.assertNotNull(node.getParent()); Assert.assertNotNull(node.getParent().getParent()); Assert.assertNull(node.getParent().getParent().getParent()); Assert.assertNotNull(node.getChildren()); Assert.assertEquals(0, node.getChildren().size()); Assert.assertNotNull(node.getMetaData()); Assert.assertEquals(0, node.getMetaData().size()); Assert.assertNotNull(node.getInheritedMetaData()); Assert.assertEquals(0, node.getInheritedMetaData().size()); node = this.viewConfigExtension.findNode(PagesViolation.Overview.class); Assert.assertNotNull(node); Assert.assertNotNull(node.getParent()); Assert.assertNotNull(node.getParent().getParent()); Assert.assertNull(node.getParent().getParent().getParent()); Assert.assertNotNull(node.getChildren()); Assert.assertEquals(0, node.getChildren().size()); Assert.assertNotNull(node.getMetaData()); Assert.assertEquals(1, node.getMetaData().size()); Assert.assertEquals(View.class, node.getMetaData().iterator().next().annotationType()); Assert.assertNotNull(node.getInheritedMetaData()); Assert.assertEquals(0, node.getInheritedMetaData().size()); }
Example #13
Source File: ViewConfigTest.java From deltaspike with Apache License 2.0 | 5 votes |
@Test public void testViewConfigWithStereotypeMetaData() { this.viewConfigExtension.addPageDefinition(Pages.Home.class); this.viewConfigExtension.addPageDefinition(Pages.Public.Index.class); ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver(); ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Home.class); Assert.assertNotNull(viewConfigDescriptor); Assert.assertNotNull(viewConfigDescriptor.getMetaData()); Assert.assertEquals(2, viewConfigDescriptor.getMetaData().size()); Assert.assertEquals(1, viewConfigDescriptor.getMetaData(View.class).size()); Assert.assertEquals(1, viewConfigDescriptor.getMetaData(MyView.class).size()); Assert.assertEquals(View.NavigationMode.REDIRECT, viewConfigDescriptor.getMetaData(View.class).iterator().next().navigation()); Assert.assertEquals(View.ViewParameterMode.INCLUDE, viewConfigDescriptor.getMetaData(View.class).iterator().next().viewParams()); Assert.assertEquals("landing page", viewConfigDescriptor.getMetaData(MyView.class).iterator().next().description()); viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Public.Index.class); Assert.assertNotNull(viewConfigDescriptor); Assert.assertNotNull(viewConfigDescriptor.getMetaData()); Assert.assertEquals(2, viewConfigDescriptor.getMetaData().size()); Assert.assertEquals(1, viewConfigDescriptor.getMetaData(View.class).size()); Assert.assertEquals(1, viewConfigDescriptor.getMetaData(MyView.class).size()); Assert.assertEquals(View.NavigationMode.REDIRECT, viewConfigDescriptor.getMetaData(View.class).iterator().next().navigation()); Assert.assertEquals(View.ViewParameterMode.EXCLUDE, viewConfigDescriptor.getMetaData(View.class).iterator().next().viewParams()); Assert.assertEquals("public content", viewConfigDescriptor.getMetaData(MyView.class).iterator().next().description()); }
Example #14
Source File: ViewConfigAwareNavigationHandler.java From deltaspike with Apache License 2.0 | 5 votes |
private String convertEntryToOutcome(ExternalContext externalContext, ViewConfigDescriptor entry) { View viewMetaData = entry.getMetaData(View.class).iterator().next(); boolean performRedirect = View.NavigationMode.REDIRECT.equals(viewMetaData.navigation()); boolean includeViewParameters = View.ViewParameterMode.INCLUDE.equals(viewMetaData.viewParams()); StringBuilder result = new StringBuilder(entry.getViewId()); if (performRedirect) { result.append("?faces-redirect=true"); } if (includeViewParameters) { if (performRedirect) { result.append("&"); } else { result.append("?"); } result.append("includeViewParams=true"); return JsfUtils.addPageParameters(externalContext, result.toString(), false); } return result.toString(); }
Example #15
Source File: ViewConfigTest.java From deltaspike with Apache License 2.0 | 5 votes |
@Test public void testViewConfigWithStereotypeMetaData() { this.viewConfigExtension.addPageDefinition(Pages.Home.class); this.viewConfigExtension.addPageDefinition(Pages.Public.Index.class); ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver(); ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Home.class); Assert.assertNotNull(viewConfigDescriptor); Assert.assertNotNull(viewConfigDescriptor.getMetaData()); Assert.assertEquals(1, viewConfigDescriptor.getMetaData().size()); Assert.assertEquals(1, viewConfigDescriptor.getMetaData(View.class).size()); Assert.assertEquals(View.NavigationMode.REDIRECT, viewConfigDescriptor.getMetaData(View.class).iterator().next().navigation()); Assert.assertEquals(View.ViewParameterMode.INCLUDE, viewConfigDescriptor.getMetaData(View.class).iterator().next().viewParams()); viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Public.Index.class); Assert.assertNotNull(viewConfigDescriptor); Assert.assertNotNull(viewConfigDescriptor.getMetaData()); Assert.assertEquals(1, viewConfigDescriptor.getMetaData().size()); Assert.assertEquals(1, viewConfigDescriptor.getMetaData(View.class).size()); Assert.assertEquals(View.NavigationMode.REDIRECT, viewConfigDescriptor.getMetaData(View.class).iterator().next().navigation()); Assert.assertEquals(View.ViewParameterMode.EXCLUDE, viewConfigDescriptor.getMetaData(View.class).iterator().next().viewParams()); }
Example #16
Source File: DefaultViewConfigInheritanceStrategy.java From deltaspike with Apache License 2.0 | 5 votes |
private Annotation getFinalMetaDataFromNode(ViewConfigNode viewConfigNode, Annotation annotation) { Class<? extends Annotation> targetType = annotation.annotationType(); //skip @View and @Folder, because they get created dynamically to support their optional usage //the dynamic generation depends on the level and if it is a synthetic information if (View.class.equals(targetType) || Folder.class.equals(targetType)) { return annotation; } //skip aggregated meta-data, because it can't be replaced //(there is no info available about the instance which replaced the original one // which might be equivalent to the annotation passed to this method) ViewMetaData viewMetaData = annotation.annotationType().getAnnotation(ViewMetaData.class); if (viewMetaData == null) { return annotation; } Aggregated aggregated = viewMetaData.annotationType().getAnnotation(Aggregated.class); if (aggregated == null || aggregated.value()) { return annotation; } for (Annotation nodeMetaData : viewConfigNode.getMetaData()) { if (targetType.equals(nodeMetaData.annotationType())) { return nodeMetaData; } } return annotation; }
Example #17
Source File: DefaultConfigNodeConverter.java From deltaspike with Apache License 2.0 | 5 votes |
@Override public ConfigDescriptor convert(ViewConfigNode node) { List<Annotation> mergedMetaData = mergeMetaData(node.getMetaData(), node.getInheritedMetaData()); //e.g. replace default placeholders needed for the merge with real default values mergedMetaData = preProcessMetaData(mergedMetaData, node); Class sourceClass = node.getSource(); if (ViewConfigUtils.isFolderConfig(sourceClass)) { Folder folderAnnotation = findMetaDataByType(mergedMetaData, Folder.class); return new DefaultFolderConfigDescriptor(folderAnnotation.name(), node.getSource(), mergedMetaData, node.getCallbackDescriptors()); } else if (ViewConfig.class.isAssignableFrom(sourceClass)) { View viewAnnotation = findMetaDataByType(mergedMetaData, View.class); String viewId = viewAnnotation.basePath() + viewAnnotation.name() + "." + viewAnnotation.extension(); return new DefaultViewPathConfigDescriptor(viewId, (Class<? extends ViewConfig>) node.getSource(), filterInheritedFolderMetaData(mergedMetaData), node.getCallbackDescriptors()); } else { throw new IllegalStateException(node.getSource() + " isn't a valid view-config"); } }
Example #18
Source File: ViewConfigPathValidatorTest.java From deltaspike with Apache License 2.0 | 5 votes |
@Test(expected = IllegalStateException.class) public void testMissingPath() { this.viewConfigExtension.addPageDefinition(Pages.Index.class); ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver(); List<String> supportedExtensions = new ArrayList<String>(); supportedExtensions.add(View.Extension.XHTML); new MockedViewConfigPathValidator(false).validateViewConfigPaths(null, viewConfigResolver, supportedExtensions); }
Example #19
Source File: ViewConfigPathTest.java From deltaspike with Apache License 2.0 | 4 votes |
@BeforeClass public static void init() { active = true; ConfigResolver.addConfigSources(new ArrayList<ConfigSource>() { { add(new ConfigSource() { @Override public int getOrdinal() { return Integer.MAX_VALUE; } @Override public Map<String, String> getProperties() { return Collections.emptyMap(); } @Override public String getPropertyValue(String key) { if (active && View.ViewConfigPreProcessor.class.getName().equals(key)) { return ViewConfigPreProcessorWithoutValidation.class.getName(); } return null; } @Override public String getConfigName() { return "test-view-config"; } @Override public boolean isScannable() { return false; } }); } private static final long serialVersionUID = 3247551986947387154L; }); }
Example #20
Source File: ViewConfigAwareNavigationHandler.java From deltaspike with Apache License 2.0 | 4 votes |
@Override public void handleNavigation(FacesContext facesContext, String fromAction, String outcome) { lazyInit(); if (outcome != null && outcome.contains(".")) { String originalOutcome = outcome; if (!this.otherOutcomes.contains(outcome)) { //it isn't possible to support interfaces due to cdi restrictions if (outcome.startsWith("class ")) { outcome = outcome.substring(6); } ViewConfigDescriptor entry = this.viewConfigs.get(outcome); if (entry == null) { if (DefaultErrorView.class.getName().equals(originalOutcome)) { entry = this.viewConfigResolver.getDefaultErrorViewConfigDescriptor(); } } boolean allowCaching = true; if (entry == null) { Class<?> loadedClass = ClassUtils.tryToLoadClassForName(outcome); if (loadedClass == null) { this.otherOutcomes.add(originalOutcome); } else if (ViewConfig.class.isAssignableFrom(loadedClass)) { //a sub-classed page-config for annotating it with different view params if (loadedClass.getAnnotation(View.class) == null && loadedClass.getSuperclass().getAnnotation(View.class) != null) { allowCaching = false; addConfiguredViewParameters(loadedClass); loadedClass = loadedClass.getSuperclass(); } entry = this.viewConfigResolver .getViewConfigDescriptor((Class<? extends ViewConfig>) loadedClass); } } if (entry != null) { //in case of false it has been added already if (allowCaching) { this.viewConfigs.put(outcome, entry); addConfiguredViewParameters(entry.getConfigClass()); } String oldViewId = null; if (facesContext.getViewRoot() != null) { oldViewId = facesContext.getViewRoot().getViewId(); } PreViewConfigNavigateEvent navigateEvent = firePreViewConfigNavigateEvent(oldViewId, entry); entry = tryToUpdateEntry(entry, navigateEvent); if (entry != null) { outcome = convertEntryToOutcome(facesContext.getExternalContext(), entry); } } } } this.navigationHandler.handleNavigation(facesContext, fromAction, outcome); }
Example #21
Source File: NavigationCaseMapWrapper.java From deltaspike with Apache License 2.0 | 4 votes |
private Map<String, Set<NavigationCase>> createViewConfigBasedNavigationCases(boolean allowParameters) { Map<String, Set<NavigationCase>> result; if (this.wrapped instanceof ConfigurableNavigationHandler) { result = new DelegatingMap((ConfigurableNavigationHandler)this.wrapped); } else { LOG.warning("the wrapped navigation-handler doesn't extend " + ConfigurableNavigationHandler.class.getName() + ". therefore std. navigation-rules might not work correctly with mojarra"); result = new HashMap<String, Set<NavigationCase>>(); } Collection<ViewConfigDescriptor> viewConfigDescriptors = BeanProvider.getContextualReference(ViewConfigResolver.class).getViewConfigDescriptors(); if (!viewConfigDescriptors.isEmpty()) { Set<NavigationCase> navigationCase = new HashSet<NavigationCase>(); Map<String, List<String>> parameters = null; if (allowParameters) { parameters = resolveParameters(); } boolean includeParameters; for (ViewConfigDescriptor entry : viewConfigDescriptors) { View viewMetaData = entry.getMetaData(View.class).iterator().next(); includeParameters = View.ViewParameterMode.INCLUDE .equals(viewMetaData.viewParams()); navigationCase.add(new NavigationCase("*", null, null, null, entry.getViewId(), includeParameters ? parameters : null, View.NavigationMode.REDIRECT.equals(viewMetaData.navigation()), includeParameters)); result.put(entry.getViewId(), navigationCase); } } return result; }
Example #22
Source File: ViewConfigTest.java From deltaspike with Apache License 2.0 | 4 votes |
@BeforeClass public static void init() { active = true; ConfigResolver.addConfigSources(new ArrayList<ConfigSource>() { { add(new ConfigSource() { @Override public int getOrdinal() { return Integer.MAX_VALUE; } @Override public Map<String, String> getProperties() { return Collections.emptyMap(); } @Override public String getPropertyValue(String key) { if (active && View.ViewConfigPreProcessor.class.getName().equals(key)) { return TestConfigPreProcessor.class.getName(); } return null; } @Override public String getConfigName() { return "test-view-config"; } @Override public boolean isScannable() { return false; } }); } private static final long serialVersionUID = 3247551986947387154L; }); }
Example #23
Source File: TestConfigPreProcessor.java From deltaspike with Apache License 2.0 | 4 votes |
@Override public View beforeAddToConfig(View metaData, ViewConfigNode viewConfigNode) { return new ViewLiteral("/test/", "view", "custom", View.NavigationMode.DEFAULT, View.ViewParameterMode.DEFAULT, View.DefaultBasePathBuilder.class, View.DefaultFileNameBuilder.class, View.DefaultExtensionBuilder.class); }
Example #24
Source File: ViewConfigPreProcessorWithoutValidation.java From deltaspike with Apache License 2.0 | 4 votes |
@Override protected void validateViewMetaData(View view, ViewConfigNode viewConfigNode) { //do nothing to check intentionally ignored basePath usages at folder-nodes }
Example #25
Source File: ViewConfigTest.java From deltaspike with Apache License 2.0 | 4 votes |
@Test public void testNestedMetaDataTree() { this.viewConfigExtension.addPageDefinition(Pages.Index.class); this.viewConfigExtension.addPageDefinition(Pages.Home.class); this.viewConfigExtension.addPageDefinition(Pages.Admin.Index.class); ViewConfigNode node = this.viewConfigExtension.findNode(Pages.class); Assert.assertNotNull(node); Assert.assertNotNull(node.getParent()); //Root Assert.assertNull(node.getParent().getParent()); Assert.assertNotNull(node.getChildren()); Assert.assertEquals(3, node.getChildren().size()); Assert.assertNotNull(node.getMetaData()); Assert.assertEquals(0, node.getMetaData().size()); Assert.assertNotNull(node.getInheritedMetaData()); Assert.assertEquals(0, node.getInheritedMetaData().size()); node = this.viewConfigExtension.findNode(Pages.Admin.class); Assert.assertNotNull(node); Assert.assertNotNull(node.getParent()); //Admin Assert.assertNotNull(node.getParent().getParent()); //Root Assert.assertNull(node.getParent().getParent().getParent()); Assert.assertNotNull(node.getChildren()); Assert.assertEquals(1, node.getChildren().size()); Assert.assertNotNull(node.getMetaData()); Assert.assertEquals(0, node.getMetaData().size()); Assert.assertNotNull(node.getInheritedMetaData()); Assert.assertEquals(0, node.getInheritedMetaData().size()); node = this.viewConfigExtension.findNode(Pages.Index.class); Assert.assertNotNull(node); Assert.assertNotNull(node.getParent()); //Pages Assert.assertNotNull(node.getParent().getParent()); //Root Assert.assertNull(node.getParent().getParent().getParent()); Assert.assertNotNull(node.getChildren()); Assert.assertEquals(0, node.getChildren().size()); Assert.assertNotNull(node.getMetaData()); Assert.assertEquals(0, node.getMetaData().size()); Assert.assertNotNull(node.getInheritedMetaData()); Assert.assertEquals(0, node.getInheritedMetaData().size()); node = this.viewConfigExtension.findNode(Pages.Home.class); Assert.assertNotNull(node); Assert.assertNotNull(node.getParent()); //Pages Assert.assertNotNull(node.getParent().getParent()); //Root Assert.assertNull(node.getParent().getParent().getParent()); Assert.assertNotNull(node.getChildren()); Assert.assertEquals(0, node.getChildren().size()); Assert.assertNotNull(node.getMetaData()); Assert.assertEquals(1, node.getMetaData().size()); Assert.assertEquals(View.NavigationMode.DEFAULT, ((View) node.getMetaData().iterator().next()).navigation()); Assert.assertEquals(View.ViewParameterMode.DEFAULT, ((View) node.getMetaData().iterator().next()).viewParams()); Assert.assertEquals("", ((View) node.getMetaData().iterator().next()).name()); Assert.assertEquals(View.Extension.DEFAULT, ((View)node.getMetaData().iterator().next()).extension()); Assert.assertNotNull(node.getInheritedMetaData()); Assert.assertEquals(0, node.getInheritedMetaData().size()); node = this.viewConfigExtension.findNode(Pages.Admin.Index.class); Assert.assertNotNull(node); Assert.assertNotNull(node.getParent()); //Admin Assert.assertNotNull(node.getParent().getParent()); //Pages Assert.assertNotNull(node.getParent().getParent().getParent()); //Root Assert.assertNull(node.getParent().getParent().getParent().getParent()); Assert.assertNotNull(node.getChildren()); Assert.assertEquals(0, node.getChildren().size()); Assert.assertNotNull(node.getMetaData()); Assert.assertEquals(0, node.getMetaData().size()); Assert.assertNotNull(node.getInheritedMetaData()); Assert.assertEquals(0, node.getInheritedMetaData().size()); }
Example #26
Source File: ViewConfigTest.java From deltaspike with Apache License 2.0 | 4 votes |
@Test public void testMetaDataTreeWithStereotypeMetaData() { this.viewConfigExtension.addPageDefinition(Pages.Home.class); this.viewConfigExtension.addPageDefinition(Pages.Public.Index.class); ViewConfigNode node = this.viewConfigExtension.findNode(Pages.Home.class); Assert.assertNotNull(node); Assert.assertNotNull(node.getParent()); Assert.assertNotNull(node.getParent().getParent()); Assert.assertNull(node.getParent().getParent().getParent()); Assert.assertNotNull(node.getChildren()); Assert.assertEquals(0, node.getChildren().size()); Assert.assertNotNull(node.getMetaData()); Assert.assertEquals(2, node.getMetaData().size()); Assert.assertEquals(2, node.getMetaData().size()); boolean facesRedirectAnnotationFound = false; boolean viewAnnotationFound = false; for (Annotation metaData : node.getMetaData()) { if (TestFacesRedirect.class.isAssignableFrom(metaData.annotationType())) { facesRedirectAnnotationFound = true; } else if (View.class.isAssignableFrom(metaData.annotationType())) { viewAnnotationFound = true; } } Assert.assertTrue(facesRedirectAnnotationFound); Assert.assertTrue(viewAnnotationFound); Assert.assertNotNull(node.getInheritedMetaData()); Assert.assertEquals(0, node.getInheritedMetaData().size()); Assert.assertNotNull(node.getCallbackDescriptors()); Assert.assertEquals(0, node.getCallbackDescriptors().size()); node = this.viewConfigExtension.findNode(Pages.Public.class); Assert.assertNotNull(node); Assert.assertNotNull(node.getParent()); Assert.assertNotNull(node.getParent().getParent()); Assert.assertNull(node.getParent().getParent().getParent()); Assert.assertNotNull(node.getChildren()); Assert.assertEquals(1, node.getChildren().size()); Assert.assertNotNull(node.getMetaData()); Assert.assertEquals(1, node.getMetaData().size()); Assert.assertEquals(TestFacesRedirect.class, node.getMetaData().iterator().next().annotationType()); Assert.assertNotNull(node.getInheritedMetaData()); Assert.assertEquals(0, node.getInheritedMetaData().size()); Assert.assertNotNull(node.getCallbackDescriptors()); Assert.assertEquals(0, node.getCallbackDescriptors().size()); node = this.viewConfigExtension.findNode(Pages.Public.Index.class); Assert.assertNotNull(node); Assert.assertNotNull(node.getParent()); Assert.assertNotNull(node.getParent().getParent()); Assert.assertNotNull(node.getParent().getParent().getParent()); Assert.assertNull(node.getParent().getParent().getParent().getParent()); Assert.assertNotNull(node.getChildren()); Assert.assertEquals(0, node.getChildren().size()); Assert.assertNotNull(node.getMetaData()); Assert.assertEquals(0, node.getMetaData().size()); Assert.assertNotNull(node.getInheritedMetaData()); Assert.assertEquals(0, node.getInheritedMetaData().size()); Assert.assertNotNull(node.getCallbackDescriptors()); Assert.assertEquals(0, node.getCallbackDescriptors().size()); }
Example #27
Source File: ViewConfigTest.java From deltaspike with Apache License 2.0 | 4 votes |
@Test public void testMetaDataTreeWithStereotypeMetaData() { this.viewConfigExtension.addPageDefinition(Pages.Home.class); this.viewConfigExtension.addPageDefinition(Pages.Public.Index.class); ViewConfigNode node = this.viewConfigExtension.findNode(Pages.Home.class); Assert.assertNotNull(node); Assert.assertNotNull(node.getParent()); Assert.assertNotNull(node.getParent().getParent()); Assert.assertNull(node.getParent().getParent().getParent()); Assert.assertNotNull(node.getChildren()); Assert.assertEquals(0, node.getChildren().size()); Assert.assertNotNull(node.getMetaData()); Assert.assertEquals(2, node.getMetaData().size()); Assert.assertEquals(2, node.getMetaData().size()); boolean facesRedirectAnnotationFound = false; boolean viewAnnotationFound = false; for (Annotation metaData : node.getMetaData()) { if (MyView.class.isAssignableFrom(metaData.annotationType())) { facesRedirectAnnotationFound = true; } else if (View.class.isAssignableFrom(metaData.annotationType())) { viewAnnotationFound = true; } } Assert.assertTrue(facesRedirectAnnotationFound); Assert.assertTrue(viewAnnotationFound); Assert.assertNotNull(node.getInheritedMetaData()); Assert.assertEquals(0, node.getInheritedMetaData().size()); Assert.assertNotNull(node.getCallbackDescriptors()); Assert.assertEquals(0, node.getCallbackDescriptors().size()); node = this.viewConfigExtension.findNode(Pages.Public.class); Assert.assertNotNull(node); Assert.assertNotNull(node.getParent()); Assert.assertNotNull(node.getParent().getParent()); Assert.assertNull(node.getParent().getParent().getParent()); Assert.assertNotNull(node.getChildren()); Assert.assertEquals(1, node.getChildren().size()); Assert.assertNotNull(node.getMetaData()); Assert.assertEquals(1, node.getMetaData().size()); Assert.assertEquals(MyView.class, node.getMetaData().iterator().next().annotationType()); Assert.assertNotNull(node.getInheritedMetaData()); Assert.assertEquals(0, node.getInheritedMetaData().size()); Assert.assertNotNull(node.getCallbackDescriptors()); Assert.assertEquals(0, node.getCallbackDescriptors().size()); node = this.viewConfigExtension.findNode(Pages.Public.Index.class); Assert.assertNotNull(node); Assert.assertNotNull(node.getParent()); Assert.assertNotNull(node.getParent().getParent()); Assert.assertNotNull(node.getParent().getParent().getParent()); Assert.assertNull(node.getParent().getParent().getParent().getParent()); Assert.assertNotNull(node.getChildren()); Assert.assertEquals(0, node.getChildren().size()); Assert.assertNotNull(node.getMetaData()); Assert.assertEquals(0, node.getMetaData().size()); Assert.assertNotNull(node.getInheritedMetaData()); Assert.assertEquals(0, node.getInheritedMetaData().size()); Assert.assertNotNull(node.getCallbackDescriptors()); Assert.assertEquals(0, node.getCallbackDescriptors().size()); }
Example #28
Source File: ViewConfigTest.java From deltaspike with Apache License 2.0 | 4 votes |
@Test public void testMetaDataInheritanceInViewConfig() { this.viewConfigExtension.addPageDefinition(Pages.class); this.viewConfigExtension.addPageDefinition(Pages.Admin.class); this.viewConfigExtension.addPageDefinition(Pages.Admin.Index.class); ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver(); ConfigDescriptor<?> configDescriptor = viewConfigResolver.getConfigDescriptor(Pages.class); Assert.assertNotNull(configDescriptor); Assert.assertNotNull(configDescriptor.getConfigClass()); Assert.assertEquals(Pages.class, configDescriptor.getConfigClass()); Assert.assertNotNull(configDescriptor.getMetaData()); Assert.assertEquals(1, configDescriptor.getMetaData().size()); Assert.assertEquals(1, configDescriptor.getMetaData(Folder.class).size()); Assert.assertEquals("/pages/", configDescriptor.getMetaData(Folder.class).iterator().next().name()); configDescriptor = viewConfigResolver.getConfigDescriptor(Pages.Admin.class); Assert.assertNotNull(configDescriptor); Assert.assertNotNull(configDescriptor.getConfigClass()); Assert.assertEquals(Pages.Admin.class, configDescriptor.getConfigClass()); Assert.assertNotNull(configDescriptor.getMetaData()); Assert.assertEquals(1, configDescriptor.getMetaData().size()); Assert.assertEquals(1, configDescriptor.getMetaData(Folder.class).size()); Assert.assertEquals("/pages/admin/", configDescriptor.getMetaData(Folder.class).iterator().next().name()); ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Admin.Index.class); Assert.assertNotNull(viewConfigDescriptor); Assert.assertEquals("/pages/admin/index.xhtml", viewConfigDescriptor.getViewId()); Assert.assertEquals(Pages.Admin.Index.class, viewConfigDescriptor.getConfigClass()); Assert.assertNotNull(viewConfigDescriptor.getMetaData()); Assert.assertEquals(1, viewConfigDescriptor.getMetaData().size()); Assert.assertEquals(View.NavigationMode.FORWARD, viewConfigDescriptor.getMetaData(View.class).iterator().next().navigation()); Assert.assertEquals(View.ViewParameterMode.EXCLUDE, viewConfigDescriptor.getMetaData(View.class).iterator().next().viewParams()); Assert.assertEquals("index", viewConfigDescriptor.getMetaData(View.class).iterator().next().name()); Assert.assertEquals("xhtml", viewConfigDescriptor.getMetaData(View.class).iterator().next().extension()); Assert.assertEquals("/pages/admin/", viewConfigDescriptor.getMetaData(View.class).iterator().next().basePath()); }
Example #29
Source File: ViewConfigTest.java From deltaspike with Apache License 2.0 | 4 votes |
@Test public void testMetaDataInheritanceInTree() { this.viewConfigExtension.addPageDefinition(Pages.class); this.viewConfigExtension.addPageDefinition(Pages.Admin.class); this.viewConfigExtension.addPageDefinition(Pages.Admin.Index.class); ViewConfigNode node = this.viewConfigExtension.findNode(Pages.class); Assert.assertNotNull(node); Assert.assertNotNull(node.getParent()); //Root Assert.assertNull(node.getParent().getParent()); Assert.assertNotNull(node.getChildren()); Assert.assertEquals(1, node.getChildren().size()); Assert.assertNotNull(node.getMetaData()); Assert.assertEquals(1, node.getMetaData().size()); Assert.assertEquals(".", ((Folder) node.getMetaData().iterator().next()).name()); Assert.assertNotNull(node.getInheritedMetaData()); Assert.assertEquals(0, node.getInheritedMetaData().size()); node = this.viewConfigExtension.findNode(Pages.Admin.class); Assert.assertNotNull(node); Assert.assertNotNull(node.getParent()); //Admin Assert.assertNotNull(node.getParent().getParent()); //Root Assert.assertNull(node.getParent().getParent().getParent()); Assert.assertNotNull(node.getChildren()); Assert.assertEquals(1, node.getChildren().size()); Assert.assertNotNull(node.getMetaData()); Assert.assertEquals(1, node.getMetaData().size()); Assert.assertEquals(Folder.class, node.getMetaData().iterator().next().annotationType()); Assert.assertNotNull(node.getInheritedMetaData()); Assert.assertEquals(0, node.getInheritedMetaData().size()); node = this.viewConfigExtension.findNode(Pages.Admin.Index.class); Assert.assertNotNull(node); Assert.assertNotNull(node.getParent()); //Admin Assert.assertNotNull(node.getParent().getParent()); //Pages Assert.assertNotNull(node.getParent().getParent().getParent()); //Root Assert.assertNull(node.getParent().getParent().getParent().getParent()); Assert.assertNotNull(node.getChildren()); Assert.assertEquals(0, node.getChildren().size()); Assert.assertNotNull(node.getMetaData()); Assert.assertEquals(1, node.getMetaData().size()); Assert.assertEquals(View.NavigationMode.DEFAULT, ((View) node.getMetaData().iterator().next()).navigation()); Assert.assertEquals(View.ViewParameterMode.DEFAULT, ((View) node.getMetaData().iterator().next()).viewParams()); Assert.assertEquals("", ((View) node.getMetaData().iterator().next()).name()); Assert.assertEquals(View.Extension.DEFAULT, ((View) node.getMetaData().iterator().next()).extension()); Assert.assertNotNull(node.getInheritedMetaData()); Assert.assertEquals(0, node.getInheritedMetaData().size()); Assert.assertNotNull(node.getInheritedMetaData()); Assert.assertEquals(0, node.getInheritedMetaData().size()); }
Example #30
Source File: ViewConfigTest.java From deltaspike with Apache License 2.0 | 4 votes |
@Test public void testMetaDataInheritanceInViewConfig() { this.viewConfigExtension.addPageDefinition(Pages.class); ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver(); ConfigDescriptor<?> configDescriptor = viewConfigResolver.getConfigDescriptor(Pages.class); Assert.assertNotNull(configDescriptor); Assert.assertNotNull(configDescriptor.getConfigClass()); Assert.assertEquals(Pages.class, configDescriptor.getConfigClass()); Assert.assertNotNull(configDescriptor.getMetaData()); Assert.assertEquals(1, configDescriptor.getMetaData().size()); Assert.assertEquals(1, configDescriptor.getMetaData(Folder.class).size()); Assert.assertEquals("/", configDescriptor.getMetaData(Folder.class).iterator().next().name()); ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Index.class); Assert.assertNotNull(viewConfigDescriptor); Assert.assertEquals("/index.xhtml", viewConfigDescriptor.getViewId()); Assert.assertEquals(Pages.Index.class, viewConfigDescriptor.getConfigClass()); Assert.assertNotNull(viewConfigDescriptor.getMetaData()); Assert.assertEquals(1, viewConfigDescriptor.getMetaData().size()); Assert.assertEquals(View.NavigationMode.FORWARD, viewConfigDescriptor.getMetaData(View.class).iterator().next().navigation()); Assert.assertEquals(View.ViewParameterMode.EXCLUDE, viewConfigDescriptor.getMetaData(View.class).iterator().next().viewParams()); Assert.assertEquals("index", viewConfigDescriptor.getMetaData(View.class).iterator().next().name()); Assert.assertEquals("xhtml", viewConfigDescriptor.getMetaData(View.class).iterator().next().extension()); Assert.assertEquals("/", viewConfigDescriptor.getMetaData(View.class).iterator().next().basePath()); configDescriptor = viewConfigResolver.getConfigDescriptor(Pages.Admin.class); Assert.assertNotNull(configDescriptor); Assert.assertNotNull(configDescriptor.getConfigClass()); Assert.assertEquals(Pages.Admin.class, configDescriptor.getConfigClass()); Assert.assertNotNull(configDescriptor.getMetaData()); Assert.assertEquals(1, configDescriptor.getMetaData().size()); Assert.assertEquals(1, configDescriptor.getMetaData(Folder.class).size()); Assert.assertEquals("/admin/", configDescriptor.getMetaData(Folder.class).iterator().next().name()); viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Admin.Index.class); Assert.assertNotNull(viewConfigDescriptor); Assert.assertEquals("/admin/index.xhtml", viewConfigDescriptor.getViewId()); Assert.assertEquals(Pages.Admin.Index.class, viewConfigDescriptor.getConfigClass()); Assert.assertNotNull(viewConfigDescriptor.getMetaData()); Assert.assertEquals(1, viewConfigDescriptor.getMetaData().size()); Assert.assertEquals(View.NavigationMode.FORWARD, viewConfigDescriptor.getMetaData(View.class).iterator().next().navigation()); Assert.assertEquals(View.ViewParameterMode.EXCLUDE, viewConfigDescriptor.getMetaData(View.class).iterator().next().viewParams()); Assert.assertEquals("index", viewConfigDescriptor.getMetaData(View.class).iterator().next().name()); Assert.assertEquals("xhtml", viewConfigDescriptor.getMetaData(View.class).iterator().next().extension()); Assert.assertEquals("/admin/", viewConfigDescriptor.getMetaData(View.class).iterator().next().basePath()); configDescriptor = viewConfigResolver.getConfigDescriptor(Pages.Public.class); Assert.assertNotNull(configDescriptor); Assert.assertNotNull(configDescriptor.getConfigClass()); Assert.assertEquals(Pages.Public.class, configDescriptor.getConfigClass()); Assert.assertNotNull(configDescriptor.getMetaData()); Assert.assertEquals(1, configDescriptor.getMetaData().size()); Assert.assertEquals(1, configDescriptor.getMetaData(Folder.class).size()); Assert.assertEquals("/public/", configDescriptor.getMetaData(Folder.class).iterator().next().name()); viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Public.Index.class); Assert.assertNotNull(viewConfigDescriptor); Assert.assertEquals("/public/index.xhtml", viewConfigDescriptor.getViewId()); Assert.assertEquals(Pages.Public.Index.class, viewConfigDescriptor.getConfigClass()); Assert.assertNotNull(viewConfigDescriptor.getMetaData()); Assert.assertEquals(1, viewConfigDescriptor.getMetaData().size()); Assert.assertEquals(View.NavigationMode.FORWARD, viewConfigDescriptor.getMetaData(View.class).iterator().next().navigation()); Assert.assertEquals(View.ViewParameterMode.EXCLUDE, viewConfigDescriptor.getMetaData(View.class).iterator().next().viewParams()); Assert.assertEquals("index", viewConfigDescriptor.getMetaData(View.class).iterator().next().name()); Assert.assertEquals("xhtml", viewConfigDescriptor.getMetaData(View.class).iterator().next().extension()); Assert.assertEquals("/public/", viewConfigDescriptor.getMetaData(View.class).iterator().next().basePath()); }