Search in sources :

Example 16 with HeaderItem

use of org.apache.wicket.markup.head.HeaderItem in project wicket by apache.

the class ResourceAggregatorTest method assertItems.

private void assertItems(ResourceReference... references) {
    List<HeaderItem> items = new ArrayList<HeaderItem>();
    for (ResourceReference curReference : references) items.add(forReference(curReference));
    assertItems(items);
}
Also used : ArrayList(java.util.ArrayList) HeaderItem(org.apache.wicket.markup.head.HeaderItem) PriorityHeaderItem(org.apache.wicket.markup.head.PriorityHeaderItem) ResourceReference(org.apache.wicket.request.resource.ResourceReference)

Example 17 with HeaderItem

use of org.apache.wicket.markup.head.HeaderItem in project wicket by apache.

the class ResourceAggregatorTest method testTwoBundlesWithDependenciesAndPriority.

/**
 * bundle {a, b->a} and {c->a, d->c->a}, render [priority(b), d], should render [priority(ab),
 * cd]
 */
@Test
public void testTwoBundlesWithDependenciesAndPriority() {
    HeaderItem bundleAB = Application.get().getResourceBundles().addJavaScriptBundle(Application.class, "ab.js", new ResourceReferenceA(), new ResourceReferenceB());
    HeaderItem bundleCD = Application.get().getResourceBundles().addJavaScriptBundle(Application.class, "cd.js", new ResourceReferenceC(), new ResourceReferenceD());
    aggregator.render(new PriorityHeaderItem(forReference(new ResourceReferenceB())));
    aggregator.render(forReference(new ResourceReferenceD()));
    assertItems(new PriorityHeaderItem(bundleAB), bundleCD);
}
Also used : PriorityHeaderItem(org.apache.wicket.markup.head.PriorityHeaderItem) HeaderItem(org.apache.wicket.markup.head.HeaderItem) PriorityHeaderItem(org.apache.wicket.markup.head.PriorityHeaderItem) Test(org.junit.Test)

Example 18 with HeaderItem

use of org.apache.wicket.markup.head.HeaderItem in project wicket by apache.

the class ResourceAggregatorTest method testTwoResourcesWithBundleAsDependency.

/**
 * bundle {bun1 -> x, bun2 -> y}, render [bun1], should render [x, y, bun12]
 */
@Test
public void testTwoResourcesWithBundleAsDependency() {
    HeaderItem bundle12 = Application.get().getResourceBundles().addJavaScriptBundle(Application.class, "bun12.js", new ResourceReferenceBun1(), new ResourceReferenceBun2());
    aggregator.render(forReference(new ResourceReferenceBun1()));
    assertItems(forReference(new ResourceReferenceX()), forReference(new ResourceReferenceY()), bundle12);
}
Also used : HeaderItem(org.apache.wicket.markup.head.HeaderItem) PriorityHeaderItem(org.apache.wicket.markup.head.PriorityHeaderItem) Test(org.junit.Test)

Example 19 with HeaderItem

use of org.apache.wicket.markup.head.HeaderItem in project wicket by apache.

the class ResourceAggregatorTest method testBundleWithDependencies.

/**
 * bundle {c->a, d->c->a}, render [d], should render [a, cd]
 */
@Test
public void testBundleWithDependencies() {
    HeaderItem bundleCD = Application.get().getResourceBundles().addJavaScriptBundle(Application.class, "cd.js", new ResourceReferenceC(), new ResourceReferenceD());
    aggregator.render(forReference(new ResourceReferenceD()));
    assertItems(forReference(new ResourceReferenceA()), bundleCD);
}
Also used : HeaderItem(org.apache.wicket.markup.head.HeaderItem) PriorityHeaderItem(org.apache.wicket.markup.head.PriorityHeaderItem) Test(org.junit.Test)

Example 20 with HeaderItem

use of org.apache.wicket.markup.head.HeaderItem in project wicket by apache.

the class ResourceAggregatorTest method testTwoBundlesWithDependencies.

/**
 * bundle {a, b->a} and {c->a, d->c->a}, render [d], should render [ab, cd]
 */
@Test
public void testTwoBundlesWithDependencies() {
    HeaderItem bundleAB = Application.get().getResourceBundles().addJavaScriptBundle(Application.class, "ab.js", new ResourceReferenceA(), new ResourceReferenceB());
    HeaderItem bundleCD = Application.get().getResourceBundles().addJavaScriptBundle(Application.class, "cd.js", new ResourceReferenceC(), new ResourceReferenceD());
    aggregator.render(forReference(new ResourceReferenceD()));
    assertItems(bundleAB, bundleCD);
}
Also used : HeaderItem(org.apache.wicket.markup.head.HeaderItem) PriorityHeaderItem(org.apache.wicket.markup.head.PriorityHeaderItem) Test(org.junit.Test)

Aggregations

HeaderItem (org.apache.wicket.markup.head.HeaderItem)22 PriorityHeaderItem (org.apache.wicket.markup.head.PriorityHeaderItem)10 Test (org.junit.Test)10 JavaScriptHeaderItem (org.apache.wicket.markup.head.JavaScriptHeaderItem)7 JavaScriptResourceReference (org.apache.wicket.request.resource.JavaScriptResourceReference)6 ResourceReference (org.apache.wicket.request.resource.ResourceReference)5 ArrayList (java.util.ArrayList)4 LinkedHashSet (java.util.LinkedHashSet)2 CssHeaderItem (org.apache.wicket.markup.head.CssHeaderItem)2 IHeaderResponse (org.apache.wicket.markup.head.IHeaderResponse)2 WicketAjaxJQueryResourceReference (org.apache.wicket.ajax.WicketAjaxJQueryResourceReference)1 IReferenceHeaderItem (org.apache.wicket.markup.head.IReferenceHeaderItem)1 IWrappedHeaderItem (org.apache.wicket.markup.head.IWrappedHeaderItem)1 JavaScriptReferenceHeaderItem (org.apache.wicket.markup.head.JavaScriptReferenceHeaderItem)1 ResourceAggregator (org.apache.wicket.markup.head.ResourceAggregator)1 HeaderResponse (org.apache.wicket.markup.head.internal.HeaderResponse)1 DecoratingHeaderResponse (org.apache.wicket.markup.html.DecoratingHeaderResponse)1 XmlPullParser (org.apache.wicket.markup.parser.XmlPullParser)1 XmlTag (org.apache.wicket.markup.parser.XmlTag)1 PackageResourceReference (org.apache.wicket.request.resource.PackageResourceReference)1