/*
 * Copyright 2007 Kickmogu Co. Ltd. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
 * either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */



/* * 作成日: 2006/12/19
 *
 */
package com.kickmogu.rhythm.core.test;

import com.kickmogu.Config;
import com.kickmogu.rhythm.core.*;
import com.kickmogu.rhythm.core.ws.*;
import jp.co.dgic.testing.framework.DJUnitTestCase;

public class RoleTest extends DJUnitTestCase {
	protected void setUp() throws Exception {
		super.setUp();
	}

	protected void tearDown() throws Exception {
		super.tearDown();
	}

	public void test001() throws Exception {
        System.out.println("------------読み込み直後のTree------------" + Config.getProperty("Role.path.xml"));
		Role rootRole = (Role) RhythmTreeManager.getRoot(Role.class);
        System.out.println(rootRole.toString());
	}
	
	public void test002() throws Exception {
        System.out.println("------------Roleに権限を追加------------");
		Role rootRole = (Role) RhythmTreeManager.getRoot(Role.class);
		rootRole = (Role) rootRole.search(-1);
		rootRole.assignPermission(Permission.ROLE_ALL, -1);
		RhythmTreeManager.write(Role.class);
        System.out.println(rootRole.toString());
	}

	public void test003() throws Exception {
        System.out.println("------------読み込み直後のTree------------" + Config.getProperty("Role.path.xml"));
		Role rootRole = (Role) RhythmTreeManager.getRoot(Role.class);
        System.out.println(rootRole.toXmlAll());
	}
	
	public void test004() throws Exception {
        System.out.println("------------自分の権限を持つTree------------");
        RoleWs roleWs = new RoleWs();
        MemberWs memWs = new MemberWs();
        Member member = (Member) memWs.authorize("mogu", "hfc01415").getResult();
        System.out.println(roleWs.getAllByXml(member).getResult());
	}

	static public void main(String[] arg) throws Exception {
	}
}
