Skip to content

Commit

Permalink
ftest: Partial implementation for global SSC functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
rsenden committed Mar 27, 2024
1 parent 26ba73f commit 5d03bb0
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Copyright 2023 Open Text.
*
* The only warranties for products and services of Open Text
* and its affiliates and licensors ("Open Text") are as may
* be set forth in the express warranty statements accompanying
* such products and services. Nothing herein should be construed
* as constituting an additional warranty. Open Text shall not be
* liable for technical or editorial errors or omissions contained
* herein. The information contained herein is subject to change
* without notice.
*/
package com.fortify.cli.ftest.ssc

import static com.fortify.cli.ftest._common.spec.FcliSessionType.SSC

import com.fortify.cli.ftest._common.spec.FcliBaseSpec
import com.fortify.cli.ftest._common.spec.FcliSession
import com.fortify.cli.ftest._common.spec.Prefix
import com.fortify.cli.ftest.ssc._common.SSCGlobal

@Prefix("test") @FcliSession(SSC)
class SSCTestSpec extends FcliBaseSpec {
def setupSpec() {
println "setup"
}

def "t"() {
println SSCGlobal.AppVersion.eightball.version
when:
def a = "b"
then:
a=="b"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class SSCAppVersionSupplier implements Closeable, AutoCloseable {



public class SSCAppVersion {
public static class SSCAppVersion {
private final String random = System.currentTimeMillis()
private final String fcliVariableName = "ssc_appversion_"+random
private final String appName = "fcli-"+random
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.fortify.cli.ftest.ssc._common;

import org.spockframework.runtime.extension.IGlobalExtension

import com.fortify.cli.ftest._common.Fcli
import com.fortify.cli.ftest.ssc._common.SSCAppVersionSupplier.SSCAppVersion

import groovy.transform.CompileStatic

@CompileStatic
class SSCGlobal implements IGlobalExtension {
@Override
public void start() {}

@Override
public void stop() {
AppVersion.values().each { v->v.close() }
}

public static enum AppVersion implements Closeable, AutoCloseable {
empty(AppVersion.&initEmpty),
eightball(AppVersion.&initEightball),

private SSCAppVersion version;
private Closure initVersion;
private AppVersion(Closure initVersion) {
this.initVersion = initVersion;
}

private static void initEmpty(SSCAppVersion version) {

}

private static void initEightball(SSCAppVersion version) {
//Fcli.run("ssc artifact upload -f $fpr1 --appversion ${version.variableRef} --store globalEightBallFpr")
//Fcli.run("ssc artifact wait-for ::globalEightBallFpr:: -i 2s")
}

public SSCAppVersion getVersion() {
if ( !version ) {
version = new SSCAppVersion().create()
initVersion(version)
}
return version
}

@Override
public void close() {
if ( version ) {
version.close();
version = null;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
com.fortify.cli.ftest.ssc._common.SSCGlobal
com.fortify.cli.ftest._common.extension.FcliInitializerExtension
com.fortify.cli.ftest._common.extension.TestResourceExtension
com.fortify.cli.ftest._common.extension.TempPathExtension
Expand Down

0 comments on commit 5d03bb0

Please sign in to comment.