use of org.eclipse.jst.server.tomcat.core.internal.xml.server32.Context in project batfish by batfish.
the class NodJobTest method testNotNattedSat.
/**
* Test that traffic originating from 3.0.0.1 that is expected NOT to be NATed returns SAT when we
* constrain to only allow NOT-NATed results.
*/
@Test
public void testNotNattedSat() {
HeaderSpace headerSpace = new HeaderSpace();
headerSpace.setSrcIps(ImmutableList.of(new IpWildcard("3.0.0.1")));
NodJob nodJob = getNodJob(headerSpace, false);
Context z3Context = new Context();
Status status = nodJob.computeNodSat(System.currentTimeMillis(), z3Context);
assertThat(status, equalTo(Status.SATISFIABLE));
}
use of org.eclipse.jst.server.tomcat.core.internal.xml.server32.Context in project batfish by batfish.
the class NodJobTest method testNattedUnsat.
/**
* Test that traffic originating from 3.0.0.0 that is expected to be NATed returns UNSAT when we
* constrain to only allow NOT-NATed results.
*/
@Test
public void testNattedUnsat() {
HeaderSpace headerSpace = new HeaderSpace();
headerSpace.setSrcIps(ImmutableList.of(new IpWildcard("3.0.0.0")));
NodJob nodJob = getNodJob(headerSpace, false);
Context z3Context = new Context();
Status status = nodJob.computeNodSat(System.currentTimeMillis(), z3Context);
assertThat(status, equalTo(Status.UNSATISFIABLE));
}
use of org.eclipse.jst.server.tomcat.core.internal.xml.server32.Context in project batfish by batfish.
the class NodJobTest method testNatted.
/**
* Test that traffic originating from 3.0.0.0 is NATed
*/
@Test
public void testNatted() {
HeaderSpace headerSpace = new HeaderSpace();
headerSpace.setSrcIps(ImmutableList.of(new IpWildcard("3.0.0.0")));
NodJob nodJob = getNodJob(headerSpace);
Context z3Context = new Context();
SmtInput smtInput = nodJob.computeSmtInput(System.currentTimeMillis(), z3Context);
Map<OriginateVrf, Map<String, Long>> fieldConstraintsByOriginateVrf = nodJob.getOriginateVrfConstraints(z3Context, smtInput);
assertThat(fieldConstraintsByOriginateVrf.entrySet(), hasSize(1));
assertThat(fieldConstraintsByOriginateVrf, hasKey(_originateVrf));
Map<String, Long> fieldConstraints = fieldConstraintsByOriginateVrf.get(_originateVrf);
// Only one OriginateVrf choice, so this must be 0
assertThat(fieldConstraints, hasEntry(OriginateVrfInstrumentation.ORIGINATE_VRF_FIELD_NAME, new Long(0)));
assertThat(fieldConstraints, hasEntry(BasicHeaderField.ORIG_SRC_IP.getName(), new Ip("3.0.0.0").asLong()));
assertThat(fieldConstraints, hasEntry(equalTo(BasicHeaderField.SRC_IP.getName()), not(equalTo(new Ip("3.0.0.0").asLong()))));
assertThat(fieldConstraints, hasEntry(BasicHeaderField.SRC_IP.getName(), new Ip("1.0.0.10").asLong()));
Set<Flow> flows = nodJob.getFlows(fieldConstraintsByOriginateVrf);
_bdpDataPlanePlugin.processFlows(flows, _dataPlane);
List<FlowTrace> flowTraces = _bdpDataPlanePlugin.getHistoryFlowTraces(_dataPlane);
flowTraces.forEach(trace -> {
assertThat(trace.getNotes(), is("ACCEPTED"));
List<FlowTraceHop> hops = trace.getHops();
assertThat(hops, hasSize(1));
FlowTraceHop hop = hops.get(0);
assertThat(hop.getTransformedFlow(), notNullValue());
assertThat(hop.getTransformedFlow().getSrcIp(), equalTo(new Ip("1.0.0.10")));
});
}
use of org.eclipse.jst.server.tomcat.core.internal.xml.server32.Context in project batfish by batfish.
the class BoolExprTransformer method visitBasicRuleStatement.
@Override
public BoolExpr visitBasicRuleStatement(BasicRuleStatement basicRuleStatement) {
Context ctx = _nodContext.getContext();
ImmutableList.Builder<BoolExpr> preconditions = ImmutableList.<BoolExpr>builder().add(toBoolExpr(basicRuleStatement.getPreconditionStateIndependentConstraints(), _input, _nodContext));
basicRuleStatement.getPreconditionStates().stream().map(preconditionState -> toBoolExpr(preconditionState, _input, _nodContext)).forEach(preconditions::add);
return ctx.mkImplies(ctx.mkAnd(preconditions.build().stream().toArray(BoolExpr[]::new)), toBoolExpr(basicRuleStatement.getPostconditionState(), _input, _nodContext));
}
use of org.eclipse.jst.server.tomcat.core.internal.xml.server32.Context in project kie-wb-common by kiegroup.
the class DMNMarshallerTest method test_wrong_context.
@Test
public void test_wrong_context() throws IOException {
// DROOLS-2217
// SPECIAL CASE: to represent a partially edited DMN file.
// consider a LiteralExpression with null text as missing expression altogether.
final DMNRuntime runtime = roundTripUnmarshalMarshalThenUnmarshalDMN(this.getClass().getResourceAsStream("/wrong_context.dmn"));
DMNModel dmnModel = runtime.getModels().get(0);
// the DMN file is schema valid but is not a valid-DMN (a context-entry value is a literal expression missing text, which is null)
assertTrue(dmnModel.hasErrors());
// identify the error message for context-entry "ciao":
DMNMessage m0 = dmnModel.getMessages(DMNMessage.Severity.ERROR).get(0);
assertTrue("expected a message identifying the problem on a context entry for 'ciao'", m0.getMessage().startsWith("No expression defined for name 'ciao'"));
DecisionNode d0 = dmnModel.getDecisionById("_653b3426-933a-4050-9568-ab2a66b43c36");
// the identified DMN Decision is composed of a DMN Context where the first context-entry value is a literal expression missing text (text is null).
org.kie.dmn.model.v1_1.Context d0c = (org.kie.dmn.model.v1_1.Context) d0.getDecision().getExpression();
org.kie.dmn.model.v1_1.Expression contextEntryValue = d0c.getContextEntry().get(0).getExpression();
assertTrue(contextEntryValue instanceof org.kie.dmn.model.v1_1.LiteralExpression);
assertEquals(null, ((org.kie.dmn.model.v1_1.LiteralExpression) contextEntryValue).getText());
// -- Stunner side.
DMNMarshaller m = new DMNMarshaller(new XMLEncoderDiagramMetadataMarshaller(), applicationFactoryManager);
Graph<?, ?> g = m.unmarshall(null, this.getClass().getResourceAsStream("/wrong_context.dmn"));
DiagramImpl diagram = new DiagramImpl("", null);
Node<?, ?> decisionNode = g.getNode("_653b3426-933a-4050-9568-ab2a66b43c36");
assertNodeContentDefinitionIs(decisionNode, Decision.class);
View<Decision> view = ((View<Decision>) decisionNode.getContent());
// the identified DMN Decision is composed of a DMN Context where the first context-entry has missing Expression.
Context expression = (Context) view.getDefinition().getExpression();
assertEquals("a literalexpression with null text is threated as a missing expression altogether.", null, expression.getContextEntry().get(0).getExpression());
}
Aggregations