Skip to content

Commit

Permalink
Docs changes and more stub coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamcin committed Jul 7, 2019
1 parent 5c1f271 commit 59804ea
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 15 deletions.
11 changes: 1 addition & 10 deletions cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,5 @@ CLI architecture
* Docker-oriented: the Dockerfile will live in the root of the oakpal repo, and it will run a multi-stage build to execute maven, then extract the cli distributable.
* Multi-stage, and multi-space (base command home dir + machine workspace + scan workspace)

## Environment Variables

`OAKPAL_HOME`: defines base command directory. `${OAKPAL_HOME}/bin/oakpal` should execute the tool with standard classpath behavior of listing `${OAKPAL_HOME}/lib/*.jar`.
The contents of `OAKPAL_HOME` should be established in the base docker image. This base image should also set the `ENTRYPOINT` to properly execute the `bin/oakpal` command
with the appropriate `OAKPAL_PLAN` directory referenced

`OAKPAL_PLAN`: defines the directory where additional modules, checklists, configurations, and pre-install packages are downloaded prior to a scan. Downstream Dockerfiles
should use the base oakpal command to prepare the OAKPAL_PLAN directory using `RUN` directives.


see [`Main --help`](src/main/resources/net/adamcin/oakpal/cli/help.txt)

Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void onNodeTypeRegistrationError(final Throwable e, final URL resource) {
onNodeTypeRegistrationError(e.getCause(), resource);
} else {
final String message = String.format("NodeType registration error (%s): %s \"%s\"",
String.valueOf(resource), e.getClass().getName(), e.getMessage());
String.valueOf(resource), e.getClass().getName(), e.getMessage());
LOGGER.trace("[onNodeTypeRegistrationError] stack trace for: " + message, e);
reportViolation(new SimpleViolation(Violation.Severity.MAJOR, message));
}
Expand All @@ -60,7 +60,7 @@ public void onJcrNamespaceRegistrationError(final Throwable e, final String pref
onJcrNamespaceRegistrationError(e.getCause(), prefix, uri);
} else {
final String message = String.format("JCR namespace registration error (%s=%s): %s \"%s\"",
prefix, uri, e.getClass().getName(), e.getMessage());
prefix, uri, e.getClass().getName(), e.getMessage());
LOGGER.trace("[onJcrNamespaceRegistrationError] stack trace for: " + message, e);
reportViolation(new SimpleViolation(Violation.Severity.MAJOR, message));
}
Expand All @@ -72,7 +72,7 @@ public void onJcrPrivilegeRegistrationError(final Throwable e, final String jcrP
onJcrPrivilegeRegistrationError(e.getCause(), jcrPrivilege);
} else {
final String message = String.format("JCR privilege registration error (%s): %s \"%s\"",
jcrPrivilege, e.getClass().getName(), e.getMessage());
jcrPrivilege, e.getClass().getName(), e.getMessage());
LOGGER.trace("[onJcrPrivilegeRegistrationError] stack trace for: " + message, e);
reportViolation(new SimpleViolation(Violation.Severity.MAJOR, message));
}
Expand All @@ -84,7 +84,7 @@ public void onForcedRootCreationError(final Throwable e, final ForcedRoot forced
onForcedRootCreationError(e.getCause(), forcedRoot);
} else {
final String message = String.format("Forced root creation error (%s): %s \"%s\"",
forcedRoot.getPath(), e.getClass().getName(), e.getMessage());
forcedRoot, e.getClass().getName(), e.getMessage());
LOGGER.trace("[onForcedRootCreationError] stack trace for: " + message, e);
reportViolation(new SimpleViolation(Violation.Severity.MAJOR, message));
}
Expand All @@ -93,7 +93,8 @@ public void onForcedRootCreationError(final Throwable e, final ForcedRoot forced
@Override
public void onListenerException(final Exception e, final ProgressCheck listener, final PackageId packageId) {
final String message = String.format("Listener error (%s): %s \"%s\"",
listener.getClass().getName(), e.getClass().getName(), e.getMessage());
Optional.ofNullable(listener).map(lstr -> lstr.getClass().getName()).orElse(null),
e.getClass().getName(), e.getMessage());
LOGGER.trace("[onListenerException] stack trace for: " + message, e);
reportViolation(new SimpleViolation(Violation.Severity.MAJOR, message, packageId));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* Copyright 2019 Mark Adamcin
*
* 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 net.adamcin.oakpal.core;

import static org.junit.Assert.*;

import org.junit.Test;

public class DefaultErrorListenerTest {

final Exception simpleCause = new IllegalStateException(new IllegalArgumentException());

@Test
public void testOnNodeTypeRegistrationError() {
new DefaultErrorListener().onNodeTypeRegistrationError(simpleCause, null);
}

@Test
public void testOnJcrNamespaceRegistrationError() {
new DefaultErrorListener().onJcrNamespaceRegistrationError(simpleCause, null, null);
}

@Test
public void testOnJcrPrivilegeRegistrationError() {
new DefaultErrorListener().onJcrPrivilegeRegistrationError(simpleCause, null);
}

@Test
public void testOnForcedRootCreationError() {
new DefaultErrorListener().onForcedRootCreationError(simpleCause, null);
}

@Test
public void testOnListenerException() {
new DefaultErrorListener().onListenerException(simpleCause, null, null);
}

@Test
public void testOnSubpackageException() {
new DefaultErrorListener().onSubpackageException(simpleCause, null);
}

@Test
public void testOnImporterException() {
new DefaultErrorListener().onImporterException(simpleCause, null, null);
}

@Test
public void testOnListenerPathException() {
new DefaultErrorListener().onListenerPathException(simpleCause, null, null, null);
}

@Test
public void testOnInstallHookError() {
new DefaultErrorListener().onInstallHookError(simpleCause, null);
}

@Test
public void testOnProhibitedInstallHookRegistration() {
new DefaultErrorListener().onProhibitedInstallHookRegistration(null);
}
}

0 comments on commit 59804ea

Please sign in to comment.