Package com.splunk.shuttl.archiver.model

Examples of com.splunk.shuttl.archiver.model.LocalBucket


  }

  @Parameters(value = { "splunk.home" })
  public void _givenTwoFormats_archivesBothFormats(String splunkHome)
      throws IOException {
    LocalBucket realBucket = TUtilsBucket.createRealBucket();
    TUtilsFunctional.archiveBucket(realBucket, bucketArchiver, splunkHome);

    assertBucketIsArchivedInFormat(realBucket, BucketFormat.SPLUNK_BUCKET);
    assertBucketIsArchivedInFormat(realBucket, BucketFormat.CSV);
    assertFalse(realBucket.getDirectory().exists());
  }
View Full Code Here


    bucketImportController = new BucketImportController(importers);
  }

  @Test(groups = { "fast-unit" })
  public void _bucketInSplunkBucketFormat_sameBucket() {
    LocalBucket bucket = TUtilsBucket.createBucket();
    assertEquals(BucketFormat.SPLUNK_BUCKET, bucket.getFormat());
    Bucket restoredBucket = bucketImportController
        .restoreToSplunkBucketFormat(bucket);
    assertTrue(restoredBucket == bucket);
  }
View Full Code Here

        .restoreToSplunkBucketFormat(bucket);
    assertTrue(restoredBucket == bucket);
  }

  public void _bucketInCsvFormat_returnBucketFromCsvImporter() {
    LocalBucket realCsvBucket = TUtilsBucket.createRealCsvBucket();
    LocalBucket importedBucket = mock(LocalBucket.class);
    when(csvImporter.importBucket(realCsvBucket)).thenReturn(importedBucket);
    Bucket restoredBucket = bucketImportController
        .restoreToSplunkBucketFormat(realCsvBucket);
    assertEquals(importedBucket, restoredBucket);
  }
View Full Code Here

    assertEquals(importedBucket, restoredBucket);
  }

  @Test(expectedExceptions = { UnsupportedOperationException.class })
  public void _bucketInUnknownFormat_throwsUnsupportedOperationException() {
    LocalBucket unknownBucket = mock(LocalBucket.class);
    when(unknownBucket.getFormat()).thenReturn(BucketFormat.UNKNOWN);
    bucketImportController.restoreToSplunkBucketFormat(unknownBucket);
  }
View Full Code Here

    emptyMap = Collections.<String, String> emptyMap();
  }

  @Test(groups = { "fast-unit" })
  public void _givenCsvBucket_callsSplunkImportToolWithCsvFile() {
    LocalBucket csvBucket = TUtilsBucket.createRealCsvBucket();
    List<String> importTooExecutable = asList("path/to/importtool");
    when(splunkImportTool.getExecutableCommand()).thenReturn(
        importTooExecutable);
    when(splunkImportTool.getEnvironment()).thenReturn(emptyMap);
    File csvFile = UtilsBucket.getCsvFile(csvBucket);
    String[] arguments = new String[] {
        csvBucket.getDirectory().getAbsolutePath(), // <-- should move
        // this logic
        // somewhere.
        csvFile.getAbsolutePath() };
    List<String> command = UtilsList.join(importTooExecutable,
        asList(arguments));
View Full Code Here

    verify(shellExecutor).executeCommand(emptyMap, command);
  }

  @SuppressWarnings("unchecked")
  public void _givenSuccessfulImportAndBucketCreation_removeCsvFile() {
    LocalBucket csvBucket = TUtilsBucket.createRealCsvBucket();
    File csvFile = UtilsBucket.getCsvFile(csvBucket);
    assertTrue(csvFile.exists());
    when(shellExecutor.executeCommand(anyMap(), anyList())).thenReturn(0);
    when(
        bucketFactory.createWithIndexDirectoryAndFormat(anyString(),
View Full Code Here

    assertFalse(csvFile.exists());
  }

  @SuppressWarnings("unchecked")
  public void _givenUnsuccessfulImport_dontRemoveCsvFile() {
    LocalBucket csvBucket = TUtilsBucket.createRealCsvBucket();
    File csvFile = UtilsBucket.getCsvFile(csvBucket);
    when(shellExecutor.executeCommand(anyMap(), anyList())).thenReturn(1);

    assertTrue(csvFile.exists());
    csvImporter.importBucket(csvBucket);
View Full Code Here

    assertTrue(csvFile.exists());
  }

  @SuppressWarnings("unchecked")
  public void _givenUnsuccessfulBucketCreation_dontRemoveCsvFile() {
    LocalBucket csvBucket = TUtilsBucket.createRealCsvBucket();
    File csvFile = UtilsBucket.getCsvFile(csvBucket);

    when(
        bucketFactory.createWithIndexDirectoryAndFormat(anyString(),
            any(File.class), any(BucketFormat.class))).thenThrow(
View Full Code Here

    assertTrue(csvFile.exists());
  }

  @Test(expectedExceptions = { IllegalArgumentException.class })
  public void _bucketNotInCsvFormat_throwsIllegalArgumentException() {
    LocalBucket nonCsvBucket = TUtilsBucket.createBucket();
    assertNotEquals(BucketFormat.CSV, nonCsvBucket.getFormat());
    csvImporter.importBucket(nonCsvBucket);
  }
View Full Code Here

  }

  private static LocalBucket createBucketWithIndexInDirectoryAndFormat(
      String index, File bucketDir, BucketFormat format) {
    try {
      return new LocalBucket(bucketDir, index, format);
    } catch (Exception e) {
      TUtilsTestNG.failForException("Couldn't create a test bucket", e);
      throw new RuntimeException(
          "There was a UtilsTestNG.failForException() method call above me that stoped me from happening. Where did it go?");
    }
View Full Code Here

TOP

Related Classes of com.splunk.shuttl.archiver.model.LocalBucket

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.