Package atg.tools.dynunit.nucleus

Source Code of atg.tools.dynunit.nucleus.NucleusUtilsTest

/*
* Copyright 2013 Matt Sicker and Contributors
*
* 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.
*/


package atg.tools.dynunit.nucleus;

import atg.nucleus.Nucleus;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

/**
* NucleusUtilsTest
*
* @author adamb
*/
public class NucleusUtilsTest {

    /**
     * Tests the addComponent method of NucleusUtils to make sure that when a
     * component is added that exact same one
     */
    @Test
    public void testAddComponent()
            throws Exception {
        Nucleus n = null;
        try {
            n = new Nucleus("");
            Object component = "I'm the test component";
            String path = "/foo/Test";
            Object component2 = "I'm the test component too";
            String path2 = "/foo/Test2";
            NucleusUtils.addComponent(n, path, component);
            NucleusUtils.addComponent(n, path2, component2);
            Object result = n.resolveName(path);
            Object result2 = n.resolveName(path2);
            // Make sure we get something
            assertNotNull(result);
            assertNotNull(result2);
            // Make sure it's the same component we added
            assertEquals(component, result);
            assertEquals(component2, result2);
        } finally {
            if (n != null) {
                n.stopService();
            }
        }
    }

    /**
     * Tests that NucleusUtils is able to find
     * the global testconfig directory from
     * a system property.
     */
    @Test
    public void testGetGlobalTestConfig() {
        NucleusUtils ntu = new NucleusUtils();
        String testConfig = "/foo/baz/testconfig/";
        System.setProperty(NucleusUtils.DYNUNIT_TESTCONFIG, testConfig);
        assertNotNull(testConfig);
        assertEquals(testConfig, NucleusUtils.getGlobalTestConfig());
    }
}
TOP

Related Classes of atg.tools.dynunit.nucleus.NucleusUtilsTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.