/*
* Copyright © 2015 Cask Data, Inc.
*
* 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 co.cask.cdap.data.view;
import co.cask.cdap.api.metrics.MetricsCollectionService;
import co.cask.cdap.common.conf.CConfiguration;
import co.cask.cdap.common.guice.ConfigModule;
import co.cask.cdap.common.guice.DiscoveryRuntimeModule;
import co.cask.cdap.common.guice.LocationRuntimeModule;
import co.cask.cdap.common.metrics.NoOpMetricsCollectionService;
import co.cask.cdap.common.namespace.AbstractNamespaceClient;
import co.cask.cdap.common.namespace.InMemoryNamespaceClient;
import co.cask.cdap.data.runtime.DataFabricModules;
import co.cask.cdap.data.runtime.DataSetServiceModules;
import co.cask.cdap.data.runtime.DataSetsModules;
import co.cask.cdap.data2.datafabric.dataset.service.DatasetService;
import co.cask.cdap.explore.client.ExploreClient;
import co.cask.cdap.explore.client.MockExploreClient;
import co.cask.cdap.store.guice.NamespaceStoreModule;
import co.cask.tephra.TransactionManager;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Scopes;
import com.google.inject.Singleton;
import org.apache.hadoop.conf.Configuration;
import org.junit.AfterClass;
import org.junit.BeforeClass;
/**
* Test the {@link InMemoryViewStore} implementation.
*/
public class MDSViewStoreTest extends ViewStoreTestBase {
private static ViewStore viewStore;
private static DatasetService datasetService;
private static TransactionManager transactionManager;
@BeforeClass
public static void init() throws Exception {
Injector injector = Guice.createInjector(
new ConfigModule(CConfiguration.create(), new Configuration()),
new DataSetServiceModules().getInMemoryModules(),
new DataSetsModules().getStandaloneModules(),
new DataFabricModules().getInMemoryModules(),
new DiscoveryRuntimeModule().getInMemoryModules(),
new NamespaceStoreModule().getInMemoryModules(),
new LocationRuntimeModule().getInMemoryModules(),
new AbstractModule() {
@Override
protected void configure() {
bind(AbstractNamespaceClient.class).to(InMemoryNamespaceClient.class);
bind(MetricsCollectionService.class).to(NoOpMetricsCollectionService.class).in(Singleton.class);
bind(ExploreClient.class).to(MockExploreClient.class);
bind(ViewStore.class).to(MDSViewStore.class).in(Scopes.SINGLETON);
}
}
);
viewStore = injector.getInstance(ViewStore.class);
transactionManager = injector.getInstance(TransactionManager.class);
transactionManager.startAndWait();
datasetService = injector.getInstance(DatasetService.class);
datasetService.startAndWait();
}
@AfterClass
public static void destroy() throws Exception {
datasetService.stopAndWait();
transactionManager.stopAndWait();
}
@Override
protected ViewStore getExploreViewStore() {
return viewStore;
}
}