| /** |
| * |
| * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany) |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License 2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation |
| */ |
| package org.eclipse.osbp.infogrid.services.tests; |
| |
| import static org.junit.Assert.assertEquals; |
| import static org.junit.Assert.assertNotNull; |
| import static org.junit.Assert.assertNull; |
| |
| import java.util.List; |
| |
| import org.eclipse.emf.ecore.util.EcoreUtil; |
| import org.eclipse.xtext.common.types.JvmGenericType; |
| import org.eclipse.xtext.common.types.JvmParameterizedTypeReference; |
| import org.eclipse.xtext.common.types.TypesFactory; |
| import org.junit.Before; |
| import org.junit.Test; |
| import org.knowhowlab.osgi.testing.utils.BundleUtils; |
| import org.knowhowlab.osgi.testing.utils.ServiceUtils; |
| import org.eclipse.osbp.infogrid.api.IGridSourceCache; |
| import org.eclipse.osbp.infogrid.model.gridsource.CxGridSource; |
| import org.eclipse.osbp.infogrid.model.gridsource.CxGridSourceFactory; |
| import org.eclipse.osbp.infogrid.services.tests.data.MyDto; |
| import org.eclipse.osbp.infogrid.services.tests.data.TestClass1; |
| import org.eclipse.osbp.infogrid.services.tests.data.TestClass2; |
| import org.osgi.framework.BundleContext; |
| import org.osgi.framework.FrameworkUtil; |
| |
| public class GridSourceCacheBuilderTest { |
| |
| private BundleContext bc; |
| private IGridSourceCache cache; |
| |
| @Before |
| public void setup() throws Exception { |
| bc = getBundleContext(); |
| BundleUtils.startBundleAsync(bc, "org.eclipse.osbp.infogrid.model"); |
| BundleUtils.startBundleAsync(bc, "org.eclipse.osbp.infogrid.services"); |
| |
| cache = ServiceUtils.getService(getBundleContext(), |
| IGridSourceCache.class); |
| assertNotNull(cache); |
| } |
| |
| private BundleContext getBundleContext() { |
| return FrameworkUtil.getBundle(getClass()).getBundleContext(); |
| } |
| |
| @Test |
| public void test_getById() { |
| |
| CxGridSource result = cache.getSource("org.my"); |
| assertNotNull(result); |
| assertEquals("org.my", result.getId()); |
| } |
| |
| @Test |
| public void test_getByClass() { |
| |
| List<CxGridSource> result = cache.getSources(MyDto.class); |
| assertEquals(1, result.size()); |
| assertEquals("org.my", result.get(0).getId()); |
| } |
| |
| } |