-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
302 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
|
||
name: Deploy | ||
|
||
concurrency: ${{ github.workflow }} | ||
|
||
on: | ||
push: | ||
branches: | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
core/src/main/java/io/wcm/testing/mock/aem/MockJcrTagManagerFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package io.wcm.testing.mock.aem; | ||
|
||
import javax.jcr.Session; | ||
|
||
import org.apache.sling.api.resource.ResourceResolver; | ||
import org.osgi.annotation.versioning.ProviderType; | ||
import org.osgi.service.component.annotations.Component; | ||
|
||
import com.day.cq.tagging.JcrTagManagerFactory; | ||
import com.day.cq.tagging.TagManager; | ||
|
||
/** | ||
* Mock implementation of {@link JcrTagManagerFactory}. | ||
*/ | ||
@Component(service = JcrTagManagerFactory.class) | ||
@ProviderType | ||
public final class MockJcrTagManagerFactory implements JcrTagManagerFactory { | ||
|
||
@Override | ||
public TagManager getTagManager(final Session session) { | ||
// Tried to implement this method by injecting the ResourceResolverFactory as an OSGi Service, but this is not possible, due to the fact that | ||
// ResourceResolverType.NONE doesn't register the service on the BundleContext at construction of the AemContext. | ||
// This method is deprecated and shouldn't be used anyway, so it shouldn't be a problem. | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public TagManager getTagManager(final ResourceResolver resourceResolver) { | ||
if (resourceResolver == null) { | ||
throw new IllegalArgumentException("ResourceResolver must not be null"); | ||
} | ||
return new MockTagManager(resourceResolver); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
core/src/test/java/io/wcm/testing/mock/aem/MockJcrTagManagerFactoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package io.wcm.testing.mock.aem; | ||
|
||
import static org.junit.Assert.assertNotNull; | ||
|
||
import javax.jcr.Session; | ||
|
||
import org.apache.sling.api.resource.ResourceResolver; | ||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
|
||
import com.day.cq.tagging.JcrTagManagerFactory; | ||
import com.day.cq.tagging.Tag; | ||
import com.day.cq.tagging.TagManager; | ||
|
||
import io.wcm.testing.mock.aem.context.TestAemContext; | ||
import io.wcm.testing.mock.aem.junit.AemContext; | ||
|
||
public class MockJcrTagManagerFactoryTest { | ||
|
||
@Rule | ||
public AemContext context = TestAemContext.newAemContext(); | ||
|
||
private JcrTagManagerFactory underTest; | ||
|
||
@Before | ||
public void setUp() { | ||
context.create().tag("test:test-tag"); | ||
underTest = context.getService(JcrTagManagerFactory.class); | ||
} | ||
|
||
@Test | ||
public void testGetTagManagerFromResourceResolver() { | ||
TagManager tagManager = underTest.getTagManager(context.resourceResolver()); | ||
assertNotNull(tagManager); | ||
|
||
Tag tag = tagManager.resolve("test:test-tag"); | ||
assertNotNull(tag); | ||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void testGetTagManagerFromResourceResolverWithNull() { | ||
underTest.getTagManager((ResourceResolver)null); | ||
} | ||
|
||
@SuppressWarnings("deprecation") | ||
@Test(expected = UnsupportedOperationException.class) | ||
public void testGetTagManagerFromSession() { | ||
underTest.getTagManager((Session)null); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.