Search in sources :

Example 26 with ByteSource

use of com.google.common.io.ByteSource in project controller by opendaylight.

the class SnapshotTrackerTest method testAddChunks.

@Test
public void testAddChunks() throws IOException {
    try (SnapshotTracker tracker = new SnapshotTracker(LOG, 3, "leader", mockContext)) {
        tracker.addChunk(1, chunk1, Optional.of(LeaderInstallSnapshotState.INITIAL_LAST_CHUNK_HASH_CODE));
        tracker.addChunk(2, chunk2, Optional.of(Arrays.hashCode(chunk1)));
        tracker.addChunk(3, chunk3, Optional.of(Arrays.hashCode(chunk2)));
        ByteSource snapshotBytes = tracker.getSnapshotBytes();
        assertEquals("Deserialized", data, SerializationUtils.deserialize(snapshotBytes.read()));
    }
    verify(fbos).cleanup();
}
Also used : ByteSource(com.google.common.io.ByteSource) Test(org.junit.Test)

Example 27 with ByteSource

use of com.google.common.io.ByteSource in project controller by opendaylight.

the class MigratedMessagesTest method testNoSnapshotAfterStartupWithNoMigratedMessages.

@Test
public void testNoSnapshotAfterStartupWithNoMigratedMessages() {
    TEST_LOG.info("testNoSnapshotAfterStartupWithNoMigratedMessages starting");
    String id = factory.generateActorId("test-actor-");
    InMemoryJournal.addEntry(id, 1, new UpdateElectionTerm(1, id));
    InMemoryJournal.addEntry(id, 2, new SimpleReplicatedLogEntry(0, 1, new MockRaftActorContext.MockPayload("A")));
    InMemoryJournal.addEntry(id, 3, new ApplyJournalEntries(0));
    DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
    config.setCustomRaftPolicyImplementationClass(DisableElectionsRaftPolicy.class.getName());
    RaftActorSnapshotCohort snapshotCohort = new RaftActorSnapshotCohort() {

        @Override
        public void createSnapshot(ActorRef actorRef, java.util.Optional<OutputStream> installSnapshotStream) {
            actorRef.tell(new CaptureSnapshotReply(ByteState.empty(), installSnapshotStream), actorRef);
        }

        @Override
        public void applySnapshot(Snapshot.State snapshotState) {
        }

        @Override
        public State deserializeSnapshot(ByteSource snapshotBytes) {
            throw new UnsupportedOperationException();
        }
    };
    TestActorRef<MockRaftActor> raftActorRef = factory.createTestActor(MockRaftActor.builder().id(id).config(config).snapshotCohort(snapshotCohort).persistent(Optional.of(true)).props().withDispatcher(Dispatchers.DefaultDispatcherId()), id);
    MockRaftActor mockRaftActor = raftActorRef.underlyingActor();
    mockRaftActor.waitForRecoveryComplete();
    Uninterruptibles.sleepUninterruptibly(750, TimeUnit.MILLISECONDS);
    List<Snapshot> snapshots = InMemorySnapshotStore.getSnapshots(id, Snapshot.class);
    assertEquals("Snapshots", 0, snapshots.size());
    TEST_LOG.info("testNoSnapshotAfterStartupWithNoMigratedMessages ending");
}
Also used : CaptureSnapshotReply(org.opendaylight.controller.cluster.raft.base.messages.CaptureSnapshotReply) Optional(com.google.common.base.Optional) ActorRef(akka.actor.ActorRef) TestActorRef(akka.testkit.TestActorRef) Snapshot(org.opendaylight.controller.cluster.raft.persisted.Snapshot) SimpleReplicatedLogEntry(org.opendaylight.controller.cluster.raft.persisted.SimpleReplicatedLogEntry) ByteState(org.opendaylight.controller.cluster.raft.persisted.ByteState) State(org.opendaylight.controller.cluster.raft.persisted.Snapshot.State) ApplyJournalEntries(org.opendaylight.controller.cluster.raft.persisted.ApplyJournalEntries) DisableElectionsRaftPolicy(org.opendaylight.controller.cluster.raft.policy.DisableElectionsRaftPolicy) ByteSource(com.google.common.io.ByteSource) UpdateElectionTerm(org.opendaylight.controller.cluster.raft.persisted.UpdateElectionTerm) Test(org.junit.Test)

Example 28 with ByteSource

use of com.google.common.io.ByteSource in project solution-finder by knewjade.

the class UtilFigTetfuCaseTest method useTetfuCase2.

@Test
void useTetfuCase2() throws Exception {
    // オプション: next, delay, loop, hold
    String tetfu = "v115@vhHRQYLFFLDmClcJSAVDEHBEooRBJoAVBq+jFDM3KW?CaujPC0/DxCznFgCpCmFDzvaFDK+VWCPNmFDpintCvvjFDJ?HExCpurgCziPPCvyjFDpu3LCviLuC0HztCpOUPCaX9VCUt/?VCzurgCK+NMCsvaFDTnLuC0SNPCMNOMCanntCauaPC0i3LC?UNUFDv+bgCqX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RpFeg0CewhFeg?0QpQaAeQ4BtBegHBPCeQpAeAtAeQpyhQaxhBtA8zwA8AAIe?A8BeAAIeA8BeAAmeA8AeAAJeW9AvhA/1ALfQ4IeR4RpAeg0?DeQaQ4Rpwhi0BeRaQpQaxhBtBegHQLRaAexhgWAtAeySwhQ?awhBtC8i0Q4wDwhBtA8zwA8CeAAFeA8EeAAFeA8BeAAceA8?AeAAEeAAAeA8GeAACeA8Jet5AvhGa5AZ3AG+A01Ad9A58A/?CBeewhQ4HewhR4BeBtBexhwwQ4BeQ4BtAeD8AeL8AeI8AeI?8AeI8AeK8AeA8Q4whB8AeE8Q4xhA8AeBtB8R4QpwhA8Aewh?BtA8DeA8AAIeAAAeA8GeAAAeA8GeAAAeA8IeA8AAIeAAA8E?eA8BeAAFeA8BeAAKeTWAvhHvYAOUAibA5rA62A91ATsAXpA?HfR4DeRpAeQ4AewDCewwBeg0QawDCewwAeRaAeQLQ4Aehlw?SAewwAeglQ4whA8g0gWg0Qpwhg0AfA8BeAAgeAAEeA8KeMj?AyeAtHeAtAeR4DeRpAeQpAewDCewwBeglQawDCewwAeRaAe?QLQ4AehlwSAewwAeglQ4whA8g0gWg0Qpwhg0AfA8BeAAgeA?AEeA8CeA8EeAAKe9pAvhOpIB2+AS/AT7AU4AO3AM6ApIBNN?B/MBTKBKBBq8AzCB34AkfglAeR4EeglAeQ4AewDGeQLAPQp?GewwEeRpBtAeAtwSBeAtCegWwSAewwAeAtCeglBtwhQpA8B?twSwwfeAAEeA8CeA8EeAAHeAAA8KelIBvhAAAA";
    String command = String.format("util fig -t %s -n 6 -d 10 -L false -H hidden", tetfu);
    RunnerHelper.runnerCatchingLog(() -> EntryPointMain.main(command.split(" ")));
    ByteSource actual = FigureFileHelper.loadGifByteSource();
    ByteSource expect = FigureFileHelper.loadResourceByteSource(UtilFigResources.TetfuCase2);
    assertThat(actual.contentEquals(expect)).isTrue();
}
Also used : ByteSource(com.google.common.io.ByteSource) Test(org.junit.jupiter.api.Test)

Example 29 with ByteSource

use of com.google.common.io.ByteSource in project solution-finder by knewjade.

the class UtilFigTetfuCaseTest method useTetfuCase5.

@Test
void useTetfuCase5() throws Exception {
    // オプション: next, delay, frame:right, start:3, end:158, hold
    String tetfu = "v115@vhKWSYzDFLDmClcJSAVDEHBEooRBUoAVBqybgCpHUx?CMn3LC6ubMCKHstCPt/VCa+VxCJNMgCqHUWCqubMCPtbMCq?+KWCTHUPC0nFgCqO8LCzHztCpCmPCan/wCJtjWCzuzPCpya?PCM3LMC6uzPCT+VWCvnNPCv+TWCa+TPCU9aPCP+9tCs3zPC?0yLMCvvjFDvS9wC0fjWCPujPCvHMMCs+TWCUuaPCat/VCpH?LxCPNWWC6PltC0i3LCanbMCKHExCTNUPCp+aFD6vbgCpOst?CUnjWCpf/wC6ybgCJtzPCMuKxC0SNPCa9qBASwBXmBTpBJn?BUoBVhBvXB6WBzdBOfB5fhlQ4HeglR4Deh0AeglwwQ4AeRp?Aeg0BeywwhRpAeg0AehWAeQ4whBtAeRpAewwAeQLwhg0Btx?SBewSQLwhRpg0glB8RpQLQ4xwA8glC8whwDQ4BtA8xwA8xh?gWQ4glBtxwA8h0gWQ4ilJepKBvhEMEBFRBMKBdWBeTBRgg0?LeAtBehlQ4g0AeBtCegWBewhgWBewSC8g0whwDCtQ4ieA8A?eAALeTQBvhEiRBphBTkBvmBmfBpgi0AeQ4EeRpg0AeR4g0C?exSAPglQLQ4g0BeAtxwglA8xhglAeB8xwh0gWwhglB8AtDe?AABeA8Le6WBvhBMeB3LBCgR4GeR4hlFeg0RaglQ4DeAtBPA?tAeR4g0AeBtxSAPAeQLQ4g0AeAtAexwglg0xhglAeBtxwh0?gWwhglA8BtDeAABeA8FeA8AeAAGeA8AeAAMelIBvhBlOBpK?BAgwhKeR4GeQ4AeQLglywCeBPBewSglwhAeAtQpxwi0whgl?AeBtDeAABeA8PeA8AeAASeA8BeAAJeZ8AvhEq8ATtAuTBUT?BfUBZfRpHeRpHewhglHegWQaEeQ4Aew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eA8T4xwAtA8w?Dwhg0xwg0AACeA8EeAACeA8EeAACeA8EeAACeA8YeS7AvhG?99AZNBTSBXPBPTB0MBTJBffRpDeBtAeQ4RpR4BeCtT4glAe?BtwwRpQ4ilAeI8AeE8xwB8AeA8BtA8whxwxhAeA8Ctzhg0A?eBtQpxwwhi07e+sAvhOZkBNLBCMB2JBMNBiLBzMBZkBXjBN?kBTiB+eBvmB8bBCdBjgAtDeg0CeAtAeilFeQpAexhg0Aeww?BeAPAewwBexhAewwAeQpAPAeQpAtAeQaQLQpA8xwwhglxhg?lTeFgBvhV/fBSdBRXBRSBzIBOeBFbBPgB+ZB8YBCPBcWBZk?BTkBTZBPdB9YBKPBMOBmfBFhBpPBKgwhQeAtglGeAtJewhA?ewhEeQ4whAexhFeglCeRpBtAeBPQawhQpwSAtAewSwhhWAe?glAeA8whAtT4AtgHglJePhBvhDykBNkBmlBphB2fwhEewhC?ewhEewhAeAtglwhEewhBtglwhwwAei0whAtwwhlH8AeJ8Qa?E8Q4C8QaE8Q4A8Atg0QaE8Q4Btg0QaQpA8ilQ4AtQpg0gWF?eAAAeA8KesGBvhZMGBzHB2HBz9AiJBNGBfPBXHB6NBOOBpj?B9oBTkBMoBxqB2kB8nBzgBXbB9eB6hB3VB5YBNQBMUBSXBL?gwwHeAtAewwCeglAewhAtBeglQ4hlDewhglBewwDewhAeQa?BeAPwhCeQaBeRaDeQpAeQaxSQLhWQaDexwT4AeCtAeAADeA?8MeJiBvhB2gBzYBIgRpAewwAeg0DeRpAtxwi0glAewhBtww?R4ilAewhAtwwT4hlAegWglwwQpAeglD8xwAtRpilg0A8QaB?tQpxhi0A8QaAtQpzhh0A8QaRpAeA8EeAALeGABvhNlBBSIB?X+AT3AJOB3MBUKBmGB0CBpABz/AFOBdTBAAA";
    String command = String.format("util fig -t %s -n 7 -d 17 -f right -s 3 -e 158 -H hidden", tetfu);
    RunnerHelper.runnerCatchingLog(() -> EntryPointMain.main(command.split(" ")));
    ByteSource actual = FigureFileHelper.loadGifByteSource();
    ByteSource expect = FigureFileHelper.loadResourceByteSource(UtilFigResources.TetfuCase5);
    assertThat(actual.contentEquals(expect)).isTrue();
}
Also used : ByteSource(com.google.common.io.ByteSource) Test(org.junit.jupiter.api.Test)

Example 30 with ByteSource

use of com.google.common.io.ByteSource in project solution-finder by knewjade.

the class UtilFigTetfuCaseTest method pngCase2.

@Test
void pngCase2() throws Exception {
    // オプション: format:png
    String tetfu = "v115@vhK2OJzkBifB9tB0sBXjBplB2mBMrBXsBAAA";
    String command = String.format("util fig -F png -f no -t %s", tetfu);
    Log log = RunnerHelper.runnerCatchingLog(() -> EntryPointMain.main(command.split(" ")));
    // 出力ディレクトリを取得
    String output = log.getOutput();
    String outputDirectory = extractOutputDirectory(output);
    // 出力されたPNGを取得
    List<ByteSource> actuals = java.nio.file.Files.walk(Paths.get(outputDirectory)).map(Path::toFile).filter(File::isFile).sorted(Comparator.comparing(File::getName)).map(Files::asByteSource).collect(Collectors.toList());
    // Assertion
    List<ByteSource> expects = FigureFileHelper.loadResourcesByteSource(UtilFigResources.PngCase2);
    assertThat(actuals).hasSameSizeAs(expects);
    for (int index = 0; index < actuals.size(); index++) assertThat(actuals.get(index).contentEquals(expects.get(index))).isTrue();
    // 出力されたPNGを削除
    // noinspection ResultOfMethodCallIgnored
    new File(outputDirectory).delete();
}
Also used : Path(java.nio.file.Path) Log(_usecase.Log) ByteSource(com.google.common.io.ByteSource) File(java.io.File) Test(org.junit.jupiter.api.Test)

Aggregations

ByteSource (com.google.common.io.ByteSource)138 IOException (java.io.IOException)58 Test (org.junit.Test)58 InputStream (java.io.InputStream)42 ByteArrayInputStream (java.io.ByteArrayInputStream)33 File (java.io.File)33 ContentItemImpl (ddf.catalog.content.data.impl.ContentItemImpl)18 Metacard (ddf.catalog.data.Metacard)17 ContentItem (ddf.catalog.content.data.ContentItem)16 StringWriter (java.io.StringWriter)14 FileInputStream (java.io.FileInputStream)13 Test (org.junit.jupiter.api.Test)12 URI (java.net.URI)11 Path (java.nio.file.Path)11 ArrayList (java.util.ArrayList)11 URL (java.net.URL)10 CreateStorageRequestImpl (ddf.catalog.content.operation.impl.CreateStorageRequestImpl)9 ByteArrayOutputStream (java.io.ByteArrayOutputStream)9 TemporaryFileBackedOutputStream (org.codice.ddf.platform.util.TemporaryFileBackedOutputStream)9 FilterInputStream (java.io.FilterInputStream)8