summaryrefslogtreecommitdiff
path: root/src/test/java/openjava/mop/OJSystemTest.java
blob: 3cdf6105557a160415a696477887c0b106a5adbb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
 * OJSystemTest.java
 *
 * Created on 2003/11/02 $Id: OJSystemTest.java,v 1.2 2003/11/14 13:52:02 tatsubori Exp $
 */
package io.devnulllabs.openjava.mop;

import java.io.File;

import junit.framework.TestCase;
import io.devnulllabs.openjava.mop.edit.OJEditableClass;
import io.devnulllabs.openjava.ptree.ClassDeclaration;
import io.devnulllabs.openjava.ptree.StatementList;

/**
 * The type OJSystemTest.
 *
 * @author Michiaki Tatsubori
 * @version 1.0 2003/11/02
 */
public class OJSystemTest extends TestCase {

    public static void main(String[] args) {
        junit.textui.TestRunner.run(OJSystemTest.class);
    }

    /*
     * @see TestCase#setUp()
     */
    protected void setUp() throws Exception {
        OJSystem.initConstants();
    }

    class TestFileEnvironment extends FileEnvironment {
        public TestFileEnvironment(Environment env) {
            super(env);
        }
        public String getPackage() {
            return "test";
        }
        public File getFile() {
            return new File("test", "A.oj");
        }
        public String currentClassName() {
            return "A";
        }
    }

    public void testAddNewClasses() throws MOPException {
        FileEnvironment fenv = new TestFileEnvironment(OJSystem.env);
        StatementList stmts =
            OJClass.makeStatementList(OJSystem.env, "class A { }");
        ClassDeclaration cdecl = (ClassDeclaration) stmts.get(0);

        OJEditableClass newClass =
            new OJEditableClass(new OJClass(OJSystem.env, null, cdecl));
        OJSystem.addNewClass(newClass);
    }

}