package com.trs.example.publish;

import com.trs.BaseParserTest;
import com.trs.components.common.publish.domain.PublishServer;
import com.trs.components.common.publish.persistent.element.IPublishFolder;
import com.trs.components.common.publish.persistent.element.PublishElementFactory;
import com.trs.components.wcm.content.persistent.Channel;
import com.trs.components.wcm.content.persistent.Document;
import com.trs.infra.util.CMyException;
import com.trs.infra.util.CMyFile;

public class MyTagParserTest extends BaseParserTest {
    private static org.apache.log4j.Logger logger = org.apache.log4j.Logger
            .getLogger(MyTagParserTest.class);

    public void testChannelInFolder() {
        try {
            // 1 构造测试数据（栏目、模板片段）
            // 需要修改为实际存在的栏目ID哦！！！！！！！！！
            int nFolderType = Channel.OBJ_TYPE, nFolderId = 56;
//            String sTemplateContent = "My first test:[<TRS" +
//            		"_Channel Field='_RecURL'/>]";
            String sTemplateContent = CMyFile.readFile("d:\\test.html");
            

            // 2 测试
            parseFolders(new String[] { sTemplateContent }, new int[][] { {
                    nFolderType, nFolderId } });
        } catch (Exception ex) {
            logger.error("测试[testChannelInFolder]出现异常！", ex);
            fail("测试[testChannelInFolder]出现异常！\n"
                    + CMyException.getStackTraceText(ex));
        }

    }

    public void testDocumentInFolder() {
        try {
            // 1 构造测试数据（文档、模板片段）
            // 文档ID需要改为系统存在的ID哦！！！！！！
            int nContentType = Document.OBJ_TYPE, nDocumentId = 32;
            String sTemplateContent = "My first test:[<TRS_Document Field='DocTitle'/>]";

            // 2 测试
            parseContents(new String[] { sTemplateContent }, new int[][] { {
                    nContentType, nDocumentId } });
        } catch (Exception ex) {
            logger.error("测试[testChannelInFolder]出现异常！", ex);
            fail("测试[testChannelInFolder]出现异常！\n"
                    + CMyException.getStackTraceText(ex));
        }

    }

    public void testMirrorDocumentInFolder() {
        try {
            // 1 构造测试数据（文档、模板片段）
            // 需要修改为实际存在的栏目ID哦！！！！！！！！！
            int nFolderType = Channel.OBJ_TYPE, nFolderId = 32;
            // 文档ID需要改为系统存在的ID哦！！！！！！
            int nContentType = Document.OBJ_TYPE, nDocumentId = 32;
            String sTemplateContent = "My first test:[<TRS_Document Field='DocTitle'/>]";

            // 2 测试
            parseContents(new String[] { sTemplateContent }, new int[][] { {
                    nFolderType, nFolderId, nContentType, nDocumentId } });
        } catch (Exception ex) {
            logger.error("测试[testChannelInFolder]出现异常！", ex);
            fail("测试[testChannelInFolder]出现异常！\n"
                    + CMyException.getStackTraceText(ex));
        }

    }
}
