ProjectTest.java :  » Groupware » LibreSource » org » libresource » core » test » Java Open Source

Java Open Source » Groupware » LibreSource 
LibreSource » org » libresource » core » test » ProjectTest.java
/**
 * LibreSource
 * Copyright (C) 2004-2008 Artenum SARL / INRIA
 * http://www.libresource.org - contact@artenum.com
 *
 * This file is part of the LibreSource software, 
 * which can be used and distributed under license conditions.
 * The license conditions are provided in the LICENSE.TXT file 
 * at the root path of the packaging that enclose this file. 
 * More information can be found at 
 * - http://dev.libresource.org/home/license
 *
 * Initial authors :
 *
 * Guillaume Bort / INRIA
 * Francois Charoy / Universite Nancy 2
 * Julien Forest / Artenum
 * Claude Godart / Universite Henry Poincare
 * Florent Jouille / INRIA
 * Sebastien Jourdain / INRIA / Artenum
 * Yves Lerumeur / Artenum
 * Pascal Molli / Universite Henry Poincare
 * Gerald Oster / INRIA
 * Mariarosa Penzi / Artenum
 * Gerard Sookahet / Artenum
 * Raphael Tani / INRIA
 *
 * Contributors :
 *
 * Stephane Bagnier / Artenum
 * Amadou Dia / Artenum-IUP Blois
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 */
package org.libresource.core.test;

import junit.framework.TestCase;
import junit.framework.TestSuite;

import org.libresource.Libresource;

import org.libresource.core.interfaces.LibresourceCoreService;

import java.net.URI;

import javax.security.auth.login.LoginContext;


public class ProjectTest extends TestCase {
    static String key = System.currentTimeMillis() + "_testProject";
    LoginContext loginContext;
    LibresourceCoreService libresourceCoreService;

    public ProjectTest(String arg0) {
        super(arg0);
    }

    protected void setUp() throws Exception {
        libresourceCoreService = (LibresourceCoreService) Libresource.getService("LibresourceCore");
    }

    protected void tearDown() throws Exception {
        loginContext.logout();
    }

    public void testCreateProject() throws Exception {
        URI uri = new URI("/projects" + key);
        libresourceCoreService.createProject(uri, "Test project", "");

        try {
            libresourceCoreService.getProject(uri);
        } catch (Exception e) {
            assertTrue(false);
        }
    }

    public void testEditProject() throws Exception {
        URI uri = new URI("/projects" + key);
        libresourceCoreService.editProject(uri, "Test project", "aaa");
        assertEquals("aaa", libresourceCoreService.getProject(uri).getDescription());
    }

    public static TestSuite suite() {
        TestSuite suite = new TestSuite();
        suite.addTest(new ProjectTest("testCreateProject"));
        suite.addTest(new ProjectTest("testEditProject"));
        suite.addTest(new ProjectTest("testDeleteProject"));

        return suite;
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.