Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

There are some handy classes available when creating tests for your Magnolia functionality. To get them working in your Maven project, add the following dependencies to your project descriptor.

Code Block
titlepom.xml

    ...

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.4</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <version>1.8.5</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>info.magnolia</groupId>
      <artifactId>magnolia-core</artifactId>
      <version>${magnoliaVersion}</version>
      <type>test-jar</type>
      <scope>test</scope>
    </dependency>

    ...

...

Code Block
titleCreateMockContentFromString.java
public final String CONTENT = ""
+ "main/content@type = mgnl:contentNode"
+ "main/content@uuid = 4"
+ "main/content.value = Content Value";

MockUtil.createAndSetHierarchyManager(ContentRepository.USERS, getClass().getResourceAsStream("sample.properties")CONTENT);

You may also directly instantiate a MockContent and then add the child Contents and or NodeData's as required

...