Search in sources :

Example 1 with StandaloneTester

use of co.cask.cdap.StandaloneTester in project cdap by caskdata.

the class MetadataHttpHandlerTestRun method testSystemScopeArtifacts.

@Test
public void testSystemScopeArtifacts() throws Exception {
    // add a system artifact. currently can't do this through the rest api (by design)
    // so bypass it and use the repository directly
    ArtifactId systemId = NamespaceId.SYSTEM.artifact("wordcount", "1.0.0");
    File systemArtifact = createArtifactJarFile(WordCountApp.class, "wordcount", "1.0.0", new Manifest());
    StandaloneTester tester = STANDALONE.get();
    tester.addSystemArtifact(systemId.getArtifact(), systemId.toId().getVersion(), systemArtifact, null);
    // verify that user metadata can be added for system-scope artifacts
    Map<String, String> userProperties = ImmutableMap.of("systemArtifactKey", "systemArtifactValue");
    Set<String> userTags = ImmutableSet.of();
    addProperties(systemId, userProperties);
    addTags(systemId, userTags);
    // verify that user and system metadata can be retrieved for system-scope artifacts
    Assert.assertEquals(ImmutableSet.of(new MetadataRecord(systemId, MetadataScope.USER, userProperties, userTags), new MetadataRecord(systemId, MetadataScope.SYSTEM, ImmutableMap.of(AbstractSystemMetadataWriter.ENTITY_NAME_KEY, systemId.getEntityName()), ImmutableSet.<String>of())), removeCreationTime(getMetadata(systemId)));
    // verify that system scope artifacts can be returned by a search in the default namespace
    // with no target type
    Assert.assertEquals(ImmutableSet.of(new MetadataSearchResultRecord(systemId)), searchMetadata(NamespaceId.DEFAULT, "system*"));
    // with target type as artifact
    Assert.assertEquals(ImmutableSet.of(new MetadataSearchResultRecord(systemId)), searchMetadata(NamespaceId.DEFAULT, "system*", EntityTypeSimpleName.ARTIFACT));
    // verify that user metadata can be deleted for system-scope artifacts
    removeMetadata(systemId);
    Assert.assertEquals(ImmutableSet.of(new MetadataRecord(systemId, MetadataScope.USER, ImmutableMap.<String, String>of(), ImmutableSet.<String>of()), new MetadataRecord(systemId, MetadataScope.SYSTEM, ImmutableMap.of(AbstractSystemMetadataWriter.ENTITY_NAME_KEY, systemId.getEntityName()), ImmutableSet.<String>of())), removeCreationTime(getMetadata(systemId)));
    artifactClient.delete(systemId);
}
Also used : StandaloneTester(co.cask.cdap.StandaloneTester) ArtifactId(co.cask.cdap.proto.id.ArtifactId) MetadataSearchResultRecord(co.cask.cdap.proto.metadata.MetadataSearchResultRecord) Manifest(java.util.jar.Manifest) MetadataRecord(co.cask.cdap.proto.metadata.MetadataRecord) File(java.io.File) Test(org.junit.Test)

Example 2 with StandaloneTester

use of co.cask.cdap.StandaloneTester in project cdap by caskdata.

the class AbstractClientTest method setUp.

@Before
public void setUp() throws Throwable {
    StandaloneTester standalone = getStandaloneTester();
    ConnectionConfig connectionConfig = InstanceURIParser.DEFAULT.parse(standalone.getBaseURI().toString());
    clientConfig = new ClientConfig.Builder().setDefaultReadTimeout(60 * 1000).setUploadReadTimeout(120 * 1000).setConnectionConfig(connectionConfig).build();
}
Also used : StandaloneTester(co.cask.cdap.StandaloneTester) ClientConfig(co.cask.cdap.client.config.ClientConfig) ConnectionConfig(co.cask.cdap.client.config.ConnectionConfig) Before(org.junit.Before)

Aggregations

StandaloneTester (co.cask.cdap.StandaloneTester)2 ClientConfig (co.cask.cdap.client.config.ClientConfig)1 ConnectionConfig (co.cask.cdap.client.config.ConnectionConfig)1 ArtifactId (co.cask.cdap.proto.id.ArtifactId)1 MetadataRecord (co.cask.cdap.proto.metadata.MetadataRecord)1 MetadataSearchResultRecord (co.cask.cdap.proto.metadata.MetadataSearchResultRecord)1 File (java.io.File)1 Manifest (java.util.jar.Manifest)1 Before (org.junit.Before)1 Test (org.junit.Test)1