use of org.apache.twill.filesystem.LocalLocationFactory in project cdap by caskdata.
the class ArtifactRepositoryTest method createPluginJar.
private static File createPluginJar(Class<?> cls, File destFile, Manifest manifest) throws IOException {
Location deploymentJar = PluginJarHelper.createPluginJar(new LocalLocationFactory(TMP_FOLDER.newFolder()), manifest, cls);
DirUtils.mkdirs(destFile.getParentFile());
Files.copy(Locations.newInputSupplier(deploymentJar), destFile);
return destFile;
}
use of org.apache.twill.filesystem.LocalLocationFactory in project cdap by caskdata.
the class RemotePrivilegesTest method setup.
@BeforeClass
public static void setup() throws IOException, InterruptedException {
CConfiguration cConf = CConfiguration.create();
cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMPORARY_FOLDER.newFolder().getAbsolutePath());
cConf.setBoolean(Constants.Security.ENABLED, true);
cConf.setBoolean(Constants.Security.KERBEROS_ENABLED, false);
cConf.setBoolean(Constants.Security.Authorization.ENABLED, true);
cConf.setInt(Constants.Security.Authorization.CACHE_MAX_ENTRIES, 10000);
cConf.setInt(Constants.Security.Authorization.CACHE_TTL_SECS, CACHE_TIMEOUT);
Manifest manifest = new Manifest();
manifest.getMainAttributes().put(Attributes.Name.MAIN_CLASS, InMemoryAuthorizer.class.getName());
LocationFactory locationFactory = new LocalLocationFactory(TEMPORARY_FOLDER.newFolder());
Location externalAuthJar = AppJarHelper.createDeploymentJar(locationFactory, InMemoryAuthorizer.class, manifest);
cConf.set(Constants.Security.Authorization.EXTENSION_JAR_PATH, externalAuthJar.toString());
Injector injector = AppFabricTestHelper.getInjector(cConf);
discoveryService = injector.getInstance(DiscoveryServiceClient.class);
appFabricServer = injector.getInstance(AppFabricServer.class);
appFabricServer.startAndWait();
waitForService(Constants.Service.APP_FABRIC_HTTP);
authorizationEnforcer = injector.getInstance(RemoteAuthorizationEnforcer.class);
privilegesManager = injector.getInstance(PrivilegesManager.class);
}
use of org.apache.twill.filesystem.LocalLocationFactory in project cdap by caskdata.
the class GatewayFastTestsSuite method buildAppArtifact.
private static File buildAppArtifact(Class<?> cls, String name, File tmpFolder) throws IOException {
if (!name.endsWith(".jar")) {
name += ".jar";
}
LocationFactory locationFactory = new LocalLocationFactory(tmpFolder);
Location appJar = AppJarHelper.createDeploymentJar(locationFactory, cls);
File destination = new File(DirUtils.createTempDir(tmpFolder), name);
Files.copy(Locations.newInputSupplier(appJar), destination);
return destination;
}
use of org.apache.twill.filesystem.LocalLocationFactory in project cdap by caskdata.
the class ProgramGenerationStageTest method testProgramGenerationForToyApp.
@Test
public void testProgramGenerationForToyApp() throws Exception {
cConf.set(Constants.AppFabric.OUTPUT_DIR, "programs");
LocationFactory lf = new LocalLocationFactory(TEMP_FOLDER.newFolder());
// have to do this since we are not going through the route of create namespace -> deploy application
// in real scenarios, the namespace directory would already be created
Location namespaceLocation = lf.create(DefaultId.APPLICATION.getNamespace());
Locations.mkdirsIfNotExists(namespaceLocation);
LocationFactory jarLf = new LocalLocationFactory(TEMP_FOLDER.newFolder());
Location appArchive = AppJarHelper.createDeploymentJar(jarLf, ToyApp.class);
ApplicationSpecification appSpec = Specifications.from(new ToyApp());
ApplicationSpecificationAdapter adapter = ApplicationSpecificationAdapter.create(new ReflectionSchemaGenerator());
ApplicationSpecification newSpec = adapter.fromJson(adapter.toJson(appSpec));
ProgramGenerationStage pgmStage = new ProgramGenerationStage(new NoOpAuthorizer(), new AuthenticationTestContext());
// Can do better here - fixed right now to run the test.
pgmStage.process(new StageContext(Object.class));
pgmStage.process(new ApplicationDeployable(NamespaceId.DEFAULT.artifact("ToyApp", "1.0"), appArchive, DefaultId.APPLICATION, newSpec, null, ApplicationDeployScope.USER));
Assert.assertTrue(true);
}
use of org.apache.twill.filesystem.LocalLocationFactory in project cdap by caskdata.
the class LocalApplicationManagerTest method before.
@BeforeClass
public static void before() throws Exception {
lf = new LocalLocationFactory(TMP_FOLDER.newFolder());
NamespaceAdmin namespaceAdmin = AppFabricTestHelper.getInjector().getInstance(NamespaceAdmin.class);
namespaceAdmin.create(NamespaceMeta.DEFAULT);
}
Aggregations