Search in sources :

Example 1 with Static

use of com.laytonsmith.core.Static in project CommandHelper by EngineHub.

the class StaticTest method InstallFakeServerFrontend.

/**
 * This installs a fake server frontend. You must have already included
 *
 * @PrepareForTest(Static.class) in the calling test code, which will allow the proper static methods to be mocked.
 */
public static void InstallFakeServerFrontend() {
    if (frontendInstalled) {
        return;
    }
    ClassDiscovery.getDefaultInstance().addDiscoveryLocation(ClassDiscovery.GetClassContainer(Static.class));
    ClassDiscovery.getDefaultInstance().addDiscoveryLocation(ClassDiscovery.GetClassContainer(StaticTest.class));
    ExtensionManager.Initialize(ClassDiscovery.getDefaultInstance());
    Implementation.setServerType(Implementation.Type.TEST);
    AliasCore fakeCore = mock(AliasCore.class);
    fakeCore.autoIncludes = new ArrayList<File>();
    SetPrivate(CommandHelperPlugin.class, "ac", fakeCore, AliasCore.class);
    frontendInstalled = true;
    try {
        Prefs.init(new File("preferences.ini"));
    } catch (IOException ex) {
        Logger.getLogger(StaticTest.class.getName()).log(Level.SEVERE, null, ex);
    }
    CHLog.initialize(new File("."));
}
Also used : AliasCore(com.laytonsmith.core.AliasCore) IOException(java.io.IOException) Static(com.laytonsmith.core.Static) File(java.io.File)

Aggregations

AliasCore (com.laytonsmith.core.AliasCore)1 Static (com.laytonsmith.core.Static)1 File (java.io.File)1 IOException (java.io.IOException)1