Skip to content

Commit

Permalink
For zerocracy#1232: Implement heapdump tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulodamaso committed Aug 2, 2018
1 parent 2cc7feb commit ca363e0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 21 deletions.
12 changes: 2 additions & 10 deletions src/main/groovy/com/zerocracy/stk/internal/update_heapdump.groovy
Expand Up @@ -17,7 +17,6 @@
package com.zerocracy.stk.internal

import com.jcabi.log.Logger
import com.jcabi.s3.Bucket
import com.jcabi.s3.fake.FkBucket
import com.jcabi.xml.XML
import com.zerocracy.Farm
Expand All @@ -26,29 +25,22 @@ import com.zerocracy.entry.ExtBucket
import com.zerocracy.entry.HeapDump
import com.zerocracy.farm.Assume
import com.zerocracy.farm.props.Props

import java.nio.file.Path
import java.nio.file.Paths

def exec(Project project, XML xml) {
/**
* @todo #766:30min Add a unit test for this stakeholder using fake S3 storage.
* Maybe you will need to modify the stakeholder itself so that is
* allows using fake S3 storage.
*/
new Assume(project, xml).isPmo()
new Assume(project, xml).type('Ping hourly')
Farm farm = binding.variables.farm
if (new Props(farm).has('//testing')) {
Logger.debug(this, 'Saving test heap')
Logger.info(this, 'Saving test heap')
new HeapDump(
new FkBucket(
'target/testing-bundles/update_heapdump/bucket',
'dumpbucket'
),
'',
Paths.get('target/testing-bundles/update_heapdump/'),
'dump'
'heap'
).save()
} else {
try {
Expand Down
Expand Up @@ -16,19 +16,22 @@
*/
package com.zerocracy.bundles.update_heapdump

import com.jcabi.s3.Bucket
import com.jcabi.s3.Ocket
import com.jcabi.s3.fake.FkBucket
import com.jcabi.xml.XML
import com.zerocracy.Farm
import com.zerocracy.Project
import com.zerocracy.entry.HeapDump
import com.zerocracy.pmo.Catalog
import org.hamcrest.MatcherAssert
import org.hamcrest.Matchers
import org.hamcrest.core.IsEqual

def exec(Project project, XML xml) {
Bucket bucket = new FkBucket(
MatcherAssert.assertThat(
'Dumped wrong value to bucket',
new Ocket.Text(
new FkBucket(
'target/testing-bundles/update_heapdump/bucket',
'dumpbucket'
).list('')
).ocket('heap')
).read(),
new IsEqual<>('This is a heap file for testing purposes')
)
}
Expand Up @@ -17,19 +17,17 @@
package com.zerocracy.bundles.update_heapdump

import com.jcabi.xml.XML
import com.zerocracy.Farm
import com.zerocracy.Project
import java.nio.file.Files
import java.nio.file.Paths
import org.cactoos.io.LengthOf
import org.cactoos.io.TeeInput

def exec(Project project, XML xml) {
Farm farm = binding.variables.farm
new LengthOf(
new TeeInput(
"This is a dump file for testing purposes",
Files.createFile(Paths.get('target/testing-bundles/update_heapdump/dump'))
'This is a heap file for testing purposes',
Files.createFile(Paths.get('target/testing-bundles/update_heapdump/heap'))
)
).intValue()
}

0 comments on commit ca363e0

Please sign in to comment.