/** * Test method for {@link * ch.entwine.weblounge.common.impl.content.page.PageletImpl#getMultiValueProperty(java.lang.String)} * . */ @Test public void testGetMultiValueProperty() { assertEquals(2, pagelet.getMultiValueProperty(multivaluePropertyName).length); assertEquals( multivaluePropertyValue[0], pagelet.getMultiValueProperty(multivaluePropertyName)[0]); assertEquals( multivaluePropertyValue[1], pagelet.getMultiValueProperty(multivaluePropertyName)[1]); }
/** * Test method for {@link * ch.entwine.weblounge.common.impl.content.page.PageletImpl#equals(java.lang.Object)} . */ @Test public void testEqualsObject() { assertTrue(pagelet.equals(new PageletImpl(module, id))); assertFalse(pagelet.equals(new PageletImpl(module, "x"))); assertFalse(pagelet.equals(new PageletImpl("x", id))); assertTrue(pagelet.equals(new PageletImpl(location, module, id))); PageletURI otherLocation = new PageletURIImpl(uri, composer, position + 1); assertFalse(pagelet.equals(new PageletImpl(otherLocation, module, id))); }
/** * Test method for {@link * ch.entwine.weblounge.common.impl.content.page.PageletImpl#getContent(java.lang.String, * ch.entwine.weblounge.common.language.Language)} . */ @Test public void testGetContentStringLanguage() { assertEquals(germanContent, pagelet.getContent(contentName, german)); assertEquals(frenchContent, pagelet.getContent(contentName, french)); // Test unsupported languages assertEquals(germanContent, pagelet.getContent(contentName, italian)); // Test lonely content (credits), available in German only assertEquals(lonelyContent, pagelet.getContent(lonelyContentName, german)); assertTrue(pagelet.getContent(lonelyContentName, french) == null); assertEquals(lonelyContent, pagelet.getContent(lonelyContentName, italian)); }
/** @throws java.lang.Exception */ @Before public void setUp() throws Exception { setupPreliminaries(); pagelet = new PageletImpl(location, module, id); pagelet.setContent(contentName, germanContent, german); pagelet.setContent(contentName, frenchContent, french); pagelet.setContent(lonelyContentName, lonelyContent, german); for (String s : multivalueGermanContent) pagelet.setContent(multivalueContentName, s, german); for (String s : multivalueFrenchContent) pagelet.setContent(multivalueContentName, s, french); pagelet.setProperty(propertyName, propertyValue); for (String s : multivaluePropertyValue) pagelet.addProperty(multivaluePropertyName, s); pagelet.setOwner(john); pagelet.setCreated(hans, creationDate); pagelet.setModified(hans, germanModificationDate, german); pagelet.setModified(amelie, frenchModificationDate, french); pagelet.setPublished(hans, publishingStartDate, publishingEndDate); }
/** * Test method for {@link * ch.entwine.weblounge.common.impl.content.page.PageletImpl#addSecurityListener(ch.entwine.weblounge.common.security.SecurityListener)} * . */ @Test @Ignore public void testAddSecurityListener() { final List<String> result = new ArrayList<String>(); pagelet.addSecurityListener( new SecurityListener() { public void ownerChanged(Securable source, User newOwner, User oldOwner) { result.add("Owner changed"); } public void permissionChanged(Securable source, Permission p) { result.add("Permission changed"); } }); pagelet.setOwner(john); pagelet.allow(SystemPermission.READ, SystemRole.EDITOR); assertEquals(2, result.size()); }
/** * Test method for {@link * ch.entwine.weblounge.common.impl.content.page.PageletImpl#getContent(java.lang.String)} . */ @Test public void testGetContentString() { assertEquals(germanContent, pagelet.getContent(contentName)); assertEquals(lonelyContent, pagelet.getContent(lonelyContentName)); pagelet.switchTo(french); assertEquals(frenchContent, pagelet.getContent(contentName)); assertTrue(pagelet.getContent(lonelyContentName) == null); // Test unsupported languages. // Switching to Italian will actually switch to German (original language) pagelet.switchTo(italian); assertEquals(germanContent, pagelet.getContent(contentName)); assertEquals(lonelyContent, pagelet.getContent(lonelyContentName)); }
/** * Test method for {@link * ch.entwine.weblounge.common.impl.content.page.PageletImpl#getMultiValueContent(java.lang.String, * ch.entwine.weblounge.common.language.Language)} . */ @Test public void testGetMultiValueContentStringLanguage() { assertEquals(2, pagelet.getMultiValueContent(multivalueContentName, german).length); assertEquals( multivalueGermanContent[0], pagelet.getMultiValueContent(multivalueContentName, german)[0]); assertEquals( multivalueGermanContent[1], pagelet.getMultiValueContent(multivalueContentName, german)[1]); // French assertEquals(2, pagelet.getMultiValueContent(multivalueContentName, french).length); assertEquals( multivalueFrenchContent[0], pagelet.getMultiValueContent(multivalueContentName, french)[0]); assertEquals( multivalueFrenchContent[1], pagelet.getMultiValueContent(multivalueContentName, french)[1]); // Test unsupported languages assertEquals(2, pagelet.getMultiValueContent(multivalueContentName, italian).length); assertEquals( multivalueGermanContent[0], pagelet.getMultiValueContent(multivalueContentName, italian)[0]); assertEquals( multivalueGermanContent[1], pagelet.getMultiValueContent(multivalueContentName, italian)[1]); }
/** * Test method for {@link * ch.entwine.weblounge.common.impl.content.page.PageletImpl#getPublishFrom()} . */ @Test public void testGetPublishFrom() { assertEquals(publishingStartDate, pagelet.getPublishFrom()); }
/** * Test method for {@link ch.entwine.weblounge.common.impl.content.page.PageletImpl#getModule()} . */ @Test public void testGetModule() { assertEquals(module, pagelet.getModule()); }
/** * Test method for {@link * ch.entwine.weblounge.common.impl.content.page.PageletImpl#isMultiValueContent(java.lang.String)} * . */ @Test public void testIsMultiValueContent() { assertFalse(pagelet.isMultiValueContent(contentName)); assertTrue(pagelet.isMultiValueContent(multivalueContentName)); }
/** * Test method for {@link * ch.entwine.weblounge.common.impl.content.page.PageletImpl#getContentNames(Language)} . */ @Test public void textGetContentNames() { assertEquals(3, pagelet.getContentNames(german).length); assertEquals(2, pagelet.getContentNames(french).length); }
/** Test method for {@link ch.entwine.weblounge.common.impl.content.page.PageletImpl#getURI()}. */ @Test public void testGetLocation() { assertEquals(location, pagelet.getURI()); }
/** * Test method for {@link * ch.entwine.weblounge.common.impl.content.page.PageletImpl#getIdentifier()} . */ @Test public void testGetIdentifier() { assertEquals(id, pagelet.getIdentifier()); }
/** * Test method for {@link ch.entwine.weblounge.common.impl.content.page.PageletImpl#hashCode()} . */ @Test public void testHashCode() { assertEquals(location.hashCode(), pagelet.hashCode()); }
/** * Test method for {@link * ch.entwine.weblounge.common.impl.content.page.PageletImpl#getPropertyNames()} . */ @Test public void testGetPropertyNames() { assertEquals(2, pagelet.getPropertyNames().length); }
/** * Test method for {@link ch.entwine.weblounge.common.impl.content.page.PageletImpl#getOwner()} . */ @Test public void testGetCreator() { assertEquals(hans, pagelet.getCreator()); }
/** * Test method for {@link * ch.entwine.weblounge.common.impl.content.page.PageletImpl#getProperty(java.lang.String)} . */ @Test public void testGetProperty() { assertEquals(propertyValue, pagelet.getProperty(propertyName)); }
/** * Test method for {@link * ch.entwine.weblounge.common.impl.content.page.PageletImpl#isMultiValueProperty(java.lang.String)} * . */ @Test public void testIsMultiValueProperty() { assertFalse(pagelet.isMultiValueProperty(propertyName)); assertTrue(pagelet.isMultiValueProperty(multivaluePropertyName)); }
/** * Test method for {@link * ch.entwine.weblounge.common.impl.content.page.PageletImpl#getMultiValueContent(java.lang.String)} * . */ @Test public void testGetMultiValueContentString() { assertEquals(2, pagelet.getMultiValueContent(multivalueContentName).length); assertEquals( multivalueGermanContent[0], pagelet.getMultiValueContent(multivalueContentName)[0]); assertEquals( multivalueGermanContent[1], pagelet.getMultiValueContent(multivalueContentName)[1]); // French pagelet.switchTo(french); assertEquals(2, pagelet.getMultiValueContent(multivalueContentName).length); assertEquals( multivalueFrenchContent[0], pagelet.getMultiValueContent(multivalueContentName)[0]); assertEquals( multivalueFrenchContent[1], pagelet.getMultiValueContent(multivalueContentName)[1]); // Test unsupported languages // Switching to Italian will actually switch to German (original language) pagelet.switchTo(italian); assertEquals(2, pagelet.getMultiValueContent(multivalueContentName, italian).length); assertEquals( multivalueGermanContent[0], pagelet.getMultiValueContent(multivalueContentName)[0]); assertEquals( multivalueGermanContent[1], pagelet.getMultiValueContent(multivalueContentName)[1]); }
/** * Test method for {@link * ch.entwine.weblounge.common.impl.content.page.PageletImpl#getPublishTo()} . */ @Test public void testGetPublishTo() { assertEquals(publishingEndDate, pagelet.getPublishTo()); }
/** * Test method for {@link * ch.entwine.weblounge.common.impl.content.page.PageletImpl#compareTo(ch.entwine.weblounge.common.language.Localizable, * ch.entwine.weblounge.common.language.Language)} . */ @Test public void testCompareTo() { PageletURI otherLocation = new PageletURIImpl(uri, composer, position + 1); assertEquals(0, pagelet.compareTo(new PageletImpl(module, id), german)); assertEquals(-1, pagelet.compareTo(new PageletImpl(otherLocation, module, id), german)); }
/** * Test method for {@link * ch.entwine.weblounge.common.impl.content.page.PageletImpl#getPublisher()} . */ @Test public void testGetPublisher() { assertEquals(hans, pagelet.getPublisher()); }