001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */
019:
020: package org.apache.geronimo.kernel.config;
021:
022: import java.util.ArrayList;
023: import java.util.Collection;
024: import java.util.Collections;
025: import java.util.List;
026:
027: import org.apache.geronimo.gbean.AbstractName;
028: import org.apache.geronimo.gbean.AbstractNameQuery;
029: import org.apache.geronimo.kernel.Kernel;
030: import org.apache.geronimo.kernel.repository.Artifact;
031: import org.apache.geronimo.kernel.repository.ArtifactManager;
032: import org.apache.geronimo.kernel.repository.ArtifactResolver;
033:
034: import com.agical.rmock.extension.junit.RMockTestCase;
035:
036: /**
037: *
038: * @version $Rev:$ $Date:$
039: */
040: public class EditableKernelConfigurationManagerTest extends
041: RMockTestCase {
042:
043: private ConfigurationStore storeA;
044: private ConfigurationStore storeB;
045: private EditableKernelConfigurationManager manager;
046: private Artifact artifact;
047: private Collection<ConfigurationStore> stores;
048: private AbstractName nameA;
049: private AbstractName nameB;
050:
051: @Override
052: protected void setUp() throws Exception {
053: Kernel kernel = (Kernel) mock(Kernel.class);
054:
055: ManageableAttributeStore attributeStore = (ManageableAttributeStore) mock(ManageableAttributeStore.class);
056: PersistentConfigurationList configurationList = (PersistentConfigurationList) mock(PersistentConfigurationList.class);
057: ArtifactManager artifactManager = (ArtifactManager) mock(ArtifactManager.class);
058: ArtifactResolver artifactResolver = (ArtifactResolver) mock(ArtifactResolver.class);
059:
060: storeA = (ConfigurationStore) mock(ConfigurationStore.class,
061: "ConfigurationStoreA");
062: storeB = (ConfigurationStore) mock(ConfigurationStore.class,
063: "ConfigurationStoreB");
064:
065: stores = new ArrayList<ConfigurationStore>();
066:
067: artifact = new Artifact("groupId", "artifactId", "2.0", "car");
068:
069: storeA.getAbstractName();
070: nameA = new AbstractName(artifact, Collections.singletonMap(
071: "name", "A"));
072: modify().multiplicity(expect.from(0)).returnValue(nameA);
073:
074: storeB.getAbstractName();
075: nameB = new AbstractName(artifact, Collections.singletonMap(
076: "name", "B"));
077: modify().multiplicity(expect.from(0)).returnValue(nameB);
078:
079: manager = new EditableKernelConfigurationManager(kernel,
080: new AbstractNameQuery(artifact, Collections
081: .singletonMap("name", "B")), stores,
082: attributeStore, configurationList, artifactManager,
083: artifactResolver, Collections.EMPTY_LIST,
084: Collections.EMPTY_LIST,
085: EditableKernelConfigurationManagerTest.class
086: .getClassLoader());
087: }
088:
089: public void testThatFirstStoreOfListStoresIsDefaultStore()
090: throws Exception {
091: stores.add(storeA);
092: stores.add(storeB);
093:
094: startVerification();
095:
096: List listStores = manager.listStores();
097: assertEquals(2, listStores.size());
098: assertEquals(nameB, listStores.get(0));
099: assertEquals(nameA, listStores.get(1));
100: }
101:
102: }
|