Skip to content

Commit

Permalink
SEAMFACES-33 Fixed the failing test for the Qualifier cache
Browse files Browse the repository at this point in the history
  • Loading branch information
bleathem committed Mar 23, 2011
1 parent 7d3d3c6 commit 1b2de43
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
Expand Up @@ -12,6 +12,7 @@

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import org.jboss.logging.Logger;

/**
* Data store for view specific data.
Expand All @@ -22,6 +23,7 @@
@ApplicationScoped
public class ViewConfigStoreImpl implements ViewConfigStore
{
private static final Logger log = Logger.getLogger(ViewConfigSecurityEnforcer.class);
/**
* cache of viewId to a given data list
*/
Expand Down Expand Up @@ -59,21 +61,25 @@ public synchronized void addAnnotationData(String viewId, Annotation annotation)
{
annotationMap = new ConcurrentHashMap<String, Annotation>();
viewPatternDataByAnnotation.put(annotation.annotationType(), annotationMap);
log.infof("Putting new annotation map for anotation type %s", annotation.annotationType().getName());
}
annotationMap.put(viewId, annotation);
log.infof("Putting new annotation (type: %s) for viewId: %s", annotation.annotationType().getName(), viewId);

Annotation[] annotations = annotation.getClass().getAnnotations();
Annotation[] annotations = annotation.annotationType().getAnnotations();
for (Annotation qualifier : annotations)
{
if (qualifier.getClass().getName().startsWith("java."))
if (qualifier.annotationType().getName().startsWith("java."))
{
log.infof("Disregarding java.* package %s", qualifier.annotationType().getName());
continue;
}
ConcurrentHashMap<String, Annotation> qualifierMap = viewPatternDataByQualifier.get(qualifier.annotationType());
if (qualifierMap == null)
{
qualifierMap = new ConcurrentHashMap<String, Annotation>();
viewPatternDataByQualifier.put(qualifier.annotationType(), qualifierMap);
log.infof("Putting new qualifier map for qualifier type %s", qualifier.annotationType().getName());
}
qualifierMap.put(viewId, qualifier);
}
Expand Down
Expand Up @@ -7,21 +7,27 @@

import org.jboss.seam.faces.view.config.ViewConfigStore;
import org.jboss.seam.faces.view.config.ViewConfigStoreImpl;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

public class ViewConfigStoreTest
{
@Test
public void testViewConfigStore()
ViewConfigStore store;

@Before
public void setp()
{
ViewConfigStore store = new ViewConfigStoreImpl();
store = new ViewConfigStoreImpl();
store.addAnnotationData("/*", new IconLiteral("default.gif"));
store.addAnnotationData("/sad/*", new IconLiteral("sad.gif"));
store.addAnnotationData("/happy/*", new IconLiteral("happy.gif"));
store.addAnnotationData("/happy/done.xhtml", new IconLiteral("finished.gif"));
store.addAnnotationData("/qualified/yes.xhtml", new QualifiedIconLiteral("qualified.gif"));

}
@Test
public void testViewConfigStore()
{
Icon data;
data = store.getAnnotationData("/happy/done.xhtml", Icon.class);
Assert.assertEquals("finished.gif", data.value());
Expand Down Expand Up @@ -49,16 +55,8 @@ public void testViewConfigStore()
}

@Test
@Ignore
public void testViewConfigStoreQualified()
{
ViewConfigStore store = new ViewConfigStoreImpl();
store.addAnnotationData("/*", new IconLiteral("default.gif"));
store.addAnnotationData("/sad/*", new IconLiteral("sad.gif"));
store.addAnnotationData("/happy/*", new IconLiteral("happy.gif"));
store.addAnnotationData("/happy/done.xhtml", new IconLiteral("finished.gif"));
store.addAnnotationData("/qualified/yes.xhtml", new QualifiedIconLiteral("qualified.gif"));

List<? extends Annotation> qdlist;
qdlist = store.getAllQualifierData("/qualified/yes.xhtml", TestQualifier.class);
Assert.assertEquals(1, qdlist.size());
Expand Down

0 comments on commit 1b2de43

Please sign in to comment.