⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testfacade.java

📁 Java Pattern Oriented Framework (Jt) 是为了实现Java快速开发的面向模式的框架。
💻 JAVA
字号:
package Jt.examples.patterns;

import Jt.JtFacade;
import Jt.JtFactory;
import Jt.JtMessage;
import Jt.JtObject;
import Jt.examples.HelloWorld;


/**
 * Demonstrates the use of JtFacade
 */

public class TestFacade extends JtFacade {

    public static final String JtCLASS_NAME = TestFacade.class.getName(); 

    private static final long serialVersionUID = 1L;


    public TestFacade () {
    }


    // Test the facade subsystems

    private Object test () {
        Object reply;
        JtFactory factory = new JtFactory ();
        String greeting;
        Object status = "OK";
        

        HelloWorld helloWorld;

        helloWorld = (HelloWorld) factory.createObject (HelloWorld.JtCLASS_NAME);

        if (helloWorld == null) {
            System.out.println ("createObject: FAIL");
            status = null;
        } else
            System.out.println  ("createObject: PASS");  


        factory.setValue (helloWorld, "greetingMessage", "Hi");

        greeting = (String) factory.getValue (helloWorld, "greetingMessage");

        if (!("Hi".equals (greeting))) {
            System.out.println  ("setValue/getValue: FAIL");
            status = null;
        } else
            System.out.println  ("setValue/getValue: PASS");    

        reply = factory.sendMessage (helloWorld, new JtMessage (HelloWorld.JtHELLO) );

        if (!("Hi".equals (reply))) {
            System.out.println  ("sendMessage: FAIL");
            status = null;
        } else
            System.out.println  ("sendMessage: PASS"); 


        return (status);

    }

    /**
     * Process object messages.
     */

    public Object processMessage (Object event) {

        String msgid = null;
        JtMessage e = (JtMessage) event;


        if (e == null)
            return null;

        msgid = (String) e.getMsgId ();

        if (msgid == null)
            return null;



        if (msgid.equals (JtObject.JtTEST)) {
            return (test ());     
        }

        return (super.processMessage (event));


    }


    /**
     * Implements a testing Facade to the Jt framework
     */


    public static void main(String[] args) {

        JtFactory factory = new JtFactory ();
        JtFacade facade;
        Object status;

        // Create an instance of JtFacade

        facade = (JtFacade) factory.createObject (TestFacade.JtCLASS_NAME, "facade");

        // Test the Jt modules using the Facade
        
        status = factory.sendMessage (facade, new JtMessage (JtObject.JtTEST));

        if (status == null) {
            System.out.println ("TestFacade: one of more tests failed");
            System.exit (1);
        } 
  

        factory.removeObject ("facade");


    }


}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -