All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.adobe.granite.activitystreams.serversidetests.ActivityStreamsSST Maven / Gradle / Ivy

/*************************************************************************
 *
 * ADOBE CONFIDENTIAL
 * __________________
 *
 *  Copyright 2012 Adobe Systems Incorporated
 *  All Rights Reserved.
 *
 * NOTICE:  All information contained herein is, and remains
 * the property of Adobe Systems Incorporated and its suppliers,
 * if any.  The intellectual and technical concepts contained
 * herein are proprietary to Adobe Systems Incorporated and its
 * suppliers and are protected by trade secret or copyright law.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from Adobe Systems Incorporated.
 *************************************************************************/

package com.adobe.granite.activitystreams.serversidetests;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ResourceResolverFactory;
import org.apache.sling.junit.annotations.SlingAnnotationsTestRunner;
import org.apache.sling.junit.annotations.TestReference;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import com.adobe.granite.activitystreams.ActivityManager;
import com.adobe.granite.activitystreams.ActivityStream;

/** Example integration test that runs server-side, in the Sling instance under test */ 
@RunWith(SlingAnnotationsTestRunner.class)
public class ActivityStreamsSST {

    private ResourceResolver resolver;
    public final static String TEST_USER = "admin";
    public final static String TEST_STREAM_NAME = "TestStream" + ActivityStreamsSST.class.getName();
    
    @TestReference
    private ActivityManager activityManager;
    
    @TestReference
    private ResourceResolverFactory resolverFactory;
    
    @Before
    public void setup() throws Exception {
        resolver = resolverFactory.getAdministrativeResourceResolver(null);
    }
    
    @After
    public void cleanup() throws Exception {
        resolver.close();
    }
    
    @Test
    public void activityManagerPresent() {
        assertNotNull(activityManager.newActivity());
    }
    
    @Test
    public void canCreateActivityStream() {
        final ActivityStream s = activityManager.getUserStream(resolver, TEST_USER, TEST_STREAM_NAME, true);
        assertNotNull("Expecting stream " + TEST_STREAM_NAME + " to be created for user " + TEST_USER, s);
        assertEquals(TEST_STREAM_NAME, s.getName());
    }
    
    @Test
    public void unknownStreamNotFound() {
        final String nonExistentStream = "NOSTREAM_" + System.currentTimeMillis();
        final ActivityStream s = activityManager.getUserStream(resolver, TEST_USER, nonExistentStream, false);
        assertNull("Expecting null when getting stream " + nonExistentStream, s);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy