Since Concordion 2.0.0
The ConcordionResources annotation can be used to apply a new theme to your specifications, tweak the existing styling, or add new css, javascript, images, or other resources.
The ConcordionResources annotation is applied to the fixture class corresponding to the specification. It can be applied to all classes in the fixture's class hierarchy - each class will be inspected in turn (parent first) for the annotation. Each annotation will be processed in isolation to others so they will operate independently. You will need to ensure that there are no conflicts.
The annotation has the following options:
value | One or more files to add to the generated specification:
|
---|---|
insertType | EMBEDDED or LINKED - applies to css and js files only |
includeDefaultStyling | Include or remove the default concordion css styling |
Executing the following fixture:
package resources.test; import org.concordion.api.ConcordionResources; import org.concordion.integration.junit4.ConcordionRunner; import org.junit.runner.RunWith; @RunWith(ConcordionRunner.class) @ConcordionResources( { "resources.js", "subfolder/resources with space.js", "../../resources.css" } ) public class ResourcesDemoTest { }
will include a link to the resources resources.js, subfolder/resources with space.js and ../../resources.css in the generated specification and leave the default CSS in the generated specification.
Executing the following fixture:
package resources.test; import org.concordion.api.ConcordionResources; import org.concordion.integration.junit4.ConcordionRunner; import org.junit.runner.RunWith; @RunWith(ConcordionRunner.class) @ConcordionResources( { "/resources.css", "/resources/test/resources.js" } ) public class ConcordionResourcesDemoTest { }
will include a link to the resources ../../resources.css and resources.js into the generated specification and leave the default CSS in the generated specification.
Executing the following fixture:
package resources.test; import org.concordion.api.ConcordionResources; import org.concordion.integration.junit4.ConcordionRunner; import org.junit.runner.RunWith; @RunWith(ConcordionRunner.class) @ConcordionResources( value = { "resources.*", "/resource?.c??" } ) public class ConcordionResourcesDemoTest { }
Will add the following resources to the generated specification:
Added Resources |
---|
resources.js |
resources.txt |
../../resources.css |
Executing the following fixture:
package resources.test; import org.concordion.api.ConcordionResources; import org.concordion.api.ConcordionResources.InsertType; import org.concordion.integration.junit4.ConcordionRunner; import org.junit.runner.RunWith; @RunWith(ConcordionRunner.class) @ConcordionResources( value = "/resources.css", insertType = InsertType.EMBEDDED ) public class ConcordionResourcesDemoTest { }
will embed the resource resources.css into the generated specification.
Executing the following fixture:
package resources.test; import org.concordion.api.ConcordionResources; import org.concordion.api.ConcordionResources.InsertType; import org.concordion.integration.junit4.ConcordionRunner; import org.junit.runner.RunWith; @RunWith(ConcordionRunner.class) @ConcordionResources( value = "/resources.css", includeDefaultStyling = false ) public class ConcordionResourcesDemoTest { }
will include a link to the resource ../../resources.css and remove the default CSS from the generated specification.
Executing the following fixture:
package resources.test; import org.concordion.api.ConcordionResources; import org.concordion.api.ConcordionResources.InsertType; import org.concordion.integration.junit4.ConcordionRunner; import org.junit.runner.RunWith; @RunWith(ConcordionRunner.class) @ConcordionResources( "im-not-here.txt" ) public class ConcordionResourcesDemoTest { }
will throw an exception containing the text "No file found".
Executing the following fixture:
package resources.test; import org.concordion.api.ConcordionResources; @ConcordionResources( "resources.js" ) public class ConcordionResourcesDemoTest extends ConcordionResourcesDemoParent { }
And parent class:
package resources.test; import org.concordion.api.ConcordionResources; import org.concordion.integration.junit4.ConcordionRunner; import org.junit.runner.RunWith; @RunWith(ConcordionRunner.class) @ConcordionResources( value = "/resources.css", includeDefaultStyling = false ) public class ConcordionResourcesDemoParent { }
will include a link to the resources ../../resources.css and resources.js, and will remove the default CSS from the generated specification.
Executing the following fixture:
package resources.test; import org.concordion.api.ConcordionResources; import org.concordion.integration.junit4.ConcordionRunner; import org.junit.runner.RunWith; @RunWith(ConcordionRunner.class) @ConcordionResources( value = { "/resources.css", "resources.js" }, includeDefaultStyling = false ) public class ConcordionResourcesDemoTest { }
With the following specification:
<head> <link href="../../concordion.css" rel="stylesheet" type="text/css" /> <link href="resources.css" rel="stylesheet" type="text/css" /> <link href="unknown.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="../resources.js"></script> </head>
Will update the generated specification:
The specified resources path is normalized to determine if the specified resource exists. This fixes issue #286, which occurred when the target resources folder corresponding to the current source folder did not exist.
Executing the following fixture:
package resources.test.missingresourcesfolder; import org.concordion.api.ConcordionResources; import org.concordion.integration.junit4.ConcordionRunner; import org.junit.runner.RunWith; @RunWith(ConcordionRunner.class) @ConcordionResources( { "../../../resources.css" } ) public class ResourcesDemoTest { }
will include a link to the resource ../../resources.css in the generated specification.