protoj.lang.internal.acme.AssertScp Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of protoj-jdk6 Show documentation
Show all versions of protoj-jdk6 Show documentation
ProtoJ: the pure java build library with maximum dependencies
The newest version!
/**
* Copyright 2009 Ashley Williams
*
* Licensed under the Apache License, Version 2.0 (the "License"); you
* may not use this file except in compliance with the License. You may
* obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package protoj.lang.internal.acme;
import org.junit.Assert;
import protoj.lang.ProjectLayout;
import protoj.lang.ScriptSession;
import protoj.util.ArgRunnable;
import protoj.util.CommandTask;
/**
* These assertions trigger when the scp command is specified. Check the
* commented code for more information.
*
* @author Ashley Williams
*
*/
final class AssertScp implements ArgRunnable {
public static final String MANDATORY_ARCHIVE_OPTION = "no archive option";
public static final String MANDATORY_DIR_OPTION = "no dir option";
public static final String BAD_ARCHIVE = "bad archive";
public static final String MISSING_ARCHIVE = "missing archive";
public static final String OK = "ok";
private final AcmeSession acmeSession;
public AssertScp(AcmeSession acmeSession) {
this.acmeSession = acmeSession;
}
public void run(ScriptSession projectSession) {
ProjectLayout acmeLayout = acmeSession.getProject().getLayout();
CommandTask exec = projectSession.getCurrentExec();
String log = acmeSession.getProject().getLayout().loadLog();
String tag = projectSession.getCurrentTag();
if (tag.equals(MANDATORY_ARCHIVE_OPTION)) {
// the mandatory archive option hasn't been specified
Assert.assertTrue(log
.contains("please specify the name of an archive"));
Assert.assertFalse(exec.getResult(), exec.isSuccess());
} else if (tag.equals(MANDATORY_DIR_OPTION)) {
// the mandatory dir option hasn't been specified
Assert.assertTrue(log.contains("please specify a dir option"));
Assert.assertFalse(exec.getResult(), exec.isSuccess());
} else if (tag.equals(BAD_ARCHIVE)) {
// the archive option refers to an invalid archive name
Assert.assertTrue(log.contains("unrecognized archive name"));
Assert.assertFalse(exec.getResult(), exec.isSuccess());
} else if (tag.equals(MISSING_ARCHIVE)) {
// the correctly named archive hasn't been generated
Assert.assertTrue(log.contains("can't find the archive at"));
Assert.assertFalse(exec.getResult(), exec.isSuccess());
} else if (tag.equals(OK)) {
// all should be well
Assert.assertTrue(log.contains("skipping the remote copy"));
Assert.assertTrue(exec.getResult(), exec.isSuccess());
}
// should be fine, just check the configuration details
acmeLayout.getLogFile().delete();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy