Java Code Examples for java.util.HashMap#SimpleEntry

The following examples show how to use java.util.HashMap#SimpleEntry . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StreamingContainer.java    From attic-apex-core with Apache License 2.0 6 votes vote down vote up
private HashMap.SimpleEntry<String, ComponentContextPair<Stream, StreamContext>> deployBufferServerPublisher(
    String connIdentifier, StreamCodec<?> streamCodec, long finishedWindowId, int queueCapacity,
    OperatorDeployInfo.OutputDeployInfo nodi)
    throws UnknownHostException
{
  String sinkIdentifier = "tcp://".concat(nodi.bufferServerHost).concat(":").concat(String.valueOf(nodi.bufferServerPort)).concat("/").concat(connIdentifier);

  StreamContext bssc = new StreamContext(nodi.declaredStreamId);
  bssc.setPortId(nodi.portName);
  bssc.setSourceId(connIdentifier);
  bssc.setSinkId(sinkIdentifier);
  bssc.setFinishedWindowId(finishedWindowId);
  bssc.put(StreamContext.CODEC, streamCodec);
  bssc.put(StreamContext.EVENT_LOOP, eventloop);
  bssc.setBufferServerAddress(InetSocketAddress.createUnresolved(nodi.bufferServerHost, nodi.bufferServerPort));
  bssc.put(StreamContext.BUFFER_SERVER_TOKEN, nodi.bufferServerToken);
  InetAddress inetAddress = bssc.getBufferServerAddress().getAddress();
  if (inetAddress != null && NetUtils.isLocalAddress(inetAddress)) {
    bssc.setBufferServerAddress(new InetSocketAddress(InetAddress.getByName(null), nodi.bufferServerPort));
  }

  Stream publisher = fastPublisherSubscriber ? new FastPublisher(connIdentifier, queueCapacity * 256) : new BufferServerPublisher(connIdentifier, queueCapacity);
  return new HashMap.SimpleEntry<>(sinkIdentifier, new ComponentContextPair<>(publisher, bssc));
}
 
Example 2
Source File: MondrianSecurityDialog.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void setMondrianProperties( final Properties properties ) {
  connectionProperties = properties;

  if ( properties == null ) {
    return;
  }

  // Update table with new data
  final Enumeration<Object> e = properties.keys();
  while ( e.hasMoreElements() ) {
    final String key = (String) e.nextElement();
    final String value = (String) properties.get( key );

    final Map.Entry<String, String> rowData = new HashMap.SimpleEntry<String, String>( key, value );
    if ( data.contains( rowData ) == false ) {
      data.add( rowData );
    }
  }

  fireTableDataChanged();
}
 
Example 3
Source File: SMGBuilderTests.java    From CogniCrypt with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void mockAeadPrimitiveRule() {
	StateMachineGraph expectedUsagePattern = new StateMachineGraph();
	StateNode minusOne = new StateNode("-1", true, true);
	StateNode zero = new StateNode("0", false, true);

	expectedUsagePattern.addNode(minusOne);
	expectedUsagePattern.addNode(zero);

	CrySLMethod aap = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.a", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));

	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {aap}), minusOne, zero));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {aap}), zero, zero));

	Assert.assertEquals(expectedUsagePattern.getAllTransitions(), readRuleFromFuleName("Testrule8").getUsagePattern().getAllTransitions());
}
 
Example 4
Source File: StreamingContainer.java    From Bats with Apache License 2.0 6 votes vote down vote up
private HashMap.SimpleEntry<String, ComponentContextPair<Stream, StreamContext>> deployBufferServerPublisher(
    String connIdentifier, StreamCodec<?> streamCodec, long finishedWindowId, int queueCapacity,
    OperatorDeployInfo.OutputDeployInfo nodi)
    throws UnknownHostException
{
  String sinkIdentifier = "tcp://".concat(nodi.bufferServerHost).concat(":").concat(String.valueOf(nodi.bufferServerPort)).concat("/").concat(connIdentifier);

  StreamContext bssc = new StreamContext(nodi.declaredStreamId);
  bssc.setPortId(nodi.portName);
  bssc.setSourceId(connIdentifier);
  bssc.setSinkId(sinkIdentifier);
  bssc.setFinishedWindowId(finishedWindowId);
  bssc.put(StreamContext.CODEC, streamCodec);
  bssc.put(StreamContext.EVENT_LOOP, eventloop);
  bssc.setBufferServerAddress(InetSocketAddress.createUnresolved(nodi.bufferServerHost, nodi.bufferServerPort));
  bssc.put(StreamContext.BUFFER_SERVER_TOKEN, nodi.bufferServerToken);
  InetAddress inetAddress = bssc.getBufferServerAddress().getAddress();
  if (inetAddress != null && NetUtils.isLocalAddress(inetAddress)) {
    bssc.setBufferServerAddress(new InetSocketAddress(InetAddress.getByName(null), nodi.bufferServerPort));
  }

  Stream publisher = fastPublisherSubscriber ? new FastPublisher(connIdentifier, queueCapacity * 256) : new BufferServerPublisher(connIdentifier, queueCapacity);
  return new HashMap.SimpleEntry<>(sinkIdentifier, new ComponentContextPair<>(publisher, bssc));
}
 
Example 5
Source File: SMGBuilderTests.java    From CogniCrypt with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void mockTrustAnchorRule() {
	StateMachineGraph expectedUsagePattern = new StateMachineGraph();
	StateNode minusOne = new StateNode("-1", true);
	StateNode zero = new StateNode("0", false, true);

	expectedUsagePattern.addNode(minusOne);
	expectedUsagePattern.addNode(zero);

	CrySLMethod aap = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.a", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));
	CrySLMethod abp = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.b", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));
	CrySLMethod acp = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.c", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));

	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {aap}), minusOne, zero));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {abp}), minusOne, zero));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {acp}), minusOne, zero));

	Assert.assertEquals(expectedUsagePattern.getAllTransitions(), readRuleFromFuleName("Testrule12").getUsagePattern().getAllTransitions());
}
 
Example 6
Source File: SMGBuilderTests.java    From CogniCrypt with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void mockPKCS7PaddingRule() {
	StateMachineGraph expectedUsagePattern = new StateMachineGraph();
	StateNode minusOne = new StateNode("-1", true);
	StateNode zero = new StateNode("0", false, true);
	StateNode one = new StateNode("1", false, true);

	expectedUsagePattern.addNode(minusOne);
	expectedUsagePattern.addNode(zero);
	expectedUsagePattern.addNode(one);

	CrySLMethod aap = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.a", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));
	CrySLMethod abp = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.b", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));

	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {aap}), minusOne, zero));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {abp}), zero, one));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {abp}), one, one));

	Assert.assertEquals(expectedUsagePattern.getAllTransitions(), readRuleFromFuleName("Testrule13").getUsagePattern().getAllTransitions());
}
 
Example 7
Source File: SMGBuilderTests.java    From CogniCrypt with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void issueCryptoAnalysis119() {
	// see https://github.com/CROSSINGTUD/CryptoAnalysis/issues/119

	StateMachineGraph expectedUsagePattern = new StateMachineGraph();
	StateNode minusOne = new StateNode("-1", true);
	StateNode zero = new StateNode("0", false, true);
	StateNode one = new StateNode("1", false, true);
	StateNode two = new StateNode("2", false, true);

	expectedUsagePattern.addNode(minusOne);
	expectedUsagePattern.addNode(zero);
	expectedUsagePattern.addNode(one);
	expectedUsagePattern.addNode(two);

	CrySLMethod aap = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.a", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));
	CrySLMethod abp = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.b", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));
	CrySLMethod acp = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.c", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));

	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {aap}), minusOne, zero));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {abp}), zero, one));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {abp}), one, one));

	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {acp}), one, two));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {acp}), two, two));

	Assert.assertEquals(expectedUsagePattern.getAllTransitions(), readRuleFromFuleName("Testrule2").getUsagePattern().getAllTransitions());
}
 
Example 8
Source File: JailbreakTest.java    From manifold with Apache License 2.0 5 votes vote down vote up
public void testParams()
{
  @Jailbreak Sample s = new Sample();
  assertSame( 5, s.primParam( 5 ) );
  assertSame( "hi", s.classParam( "hi" ) );
  int[][] primArrayParam = new int[][]{{1},{2}};
  assertSame( primArrayParam, s.primArrayParam( primArrayParam ) );
  String[][] classArrayParam = new String[][]{{"a"},{"b"}};
  assertSame( classArrayParam, s.classArrayParam( classArrayParam ) );
  HashMap.Entry<String, String> entry = new HashMap.SimpleEntry<>( "k", "v" );
  assertSame( entry, s.innerClassParam( entry ) );
}
 
Example 9
Source File: SMGBuilderTests.java    From CogniCrypt with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void mockSecureRandomRule() {
	StateMachineGraph expectedUsagePattern = new StateMachineGraph();
	StateNode minusOne = new StateNode("-1", true);
	StateNode zero = new StateNode("0", false, true);
	StateNode one = new StateNode("1", false, true);
	StateNode two = new StateNode("2", false, true);

	expectedUsagePattern.addNode(minusOne);
	expectedUsagePattern.addNode(zero);
	expectedUsagePattern.addNode(one);
	expectedUsagePattern.addNode(two);

	CrySLMethod aap = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.a", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));
	CrySLMethod abp = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.b", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));
	CrySLMethod acp = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.c", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));

	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {aap}), minusOne, zero));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {abp}), zero, one));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {acp}), one, two));

	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {acp}), zero, two));

	StateMachineGraph actualUsagePattern = readRuleFromFuleName("Testrule4").getUsagePattern();
	Assert.assertEquals(expectedUsagePattern.getAllTransitions(), actualUsagePattern.getAllTransitions());
}
 
Example 10
Source File: SMGBuilderTests.java    From CogniCrypt with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void mockCipherInputStreamRule() {
	StateMachineGraph expectedUsagePattern = new StateMachineGraph();
	StateNode minusOne = new StateNode("-1", true);
	StateNode zero = new StateNode("0", false);
	StateNode one = new StateNode("1", false);
	StateNode two = new StateNode("2", false, true);

	expectedUsagePattern.addNode(minusOne);
	expectedUsagePattern.addNode(zero);
	expectedUsagePattern.addNode(one);
	expectedUsagePattern.addNode(two);

	CrySLMethod aap = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.a", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));
	CrySLMethod abp = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.b", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));
	CrySLMethod acp = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.c", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));

	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {aap}), minusOne, zero));

	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {abp}), zero, one));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {abp}), one, one));

	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {acp}), one, two));

	Assert.assertEquals(expectedUsagePattern.getAllTransitions(), readRuleFromFuleName("Testrule6").getUsagePattern().getAllTransitions());
}
 
Example 11
Source File: SMGBuilderTests.java    From CogniCrypt with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void mockKeyPairRule() {
	StateMachineGraph expectedUsagePattern = new StateMachineGraph();
	StateNode minusOne = new StateNode("-1", true, true);
	StateNode zero = new StateNode("0", false, true);
	StateNode one = new StateNode("1", false, true);
	StateNode two = new StateNode("2", false, true);

	expectedUsagePattern.addNode(minusOne);
	expectedUsagePattern.addNode(zero);
	expectedUsagePattern.addNode(one);
	expectedUsagePattern.addNode(two);

	CrySLMethod aap = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.a", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));
	CrySLMethod abp = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.b", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));
	CrySLMethod acp = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.c", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));

	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {aap}), minusOne, zero));

	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {abp}), zero, one));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {abp}), one, one));

	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {acp}), one, two));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {acp}), two, two));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {acp}), zero, two));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {abp}), two, one));

	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {abp}), minusOne, one));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {acp}), minusOne, two));

	Assert.assertEquals(expectedUsagePattern.getAllTransitions(), readRuleFromFuleName("Testrule7").getUsagePattern().getAllTransitions());
}
 
Example 12
Source File: HostBasedAuthenticationTest.java    From crate with Apache License 2.0 5 votes vote down vote up
@Test
public void testMatchUser() throws Exception {
    // only "crate" matches
    Map.Entry<String, Map<String, String>> entry = new HashMap.SimpleEntry<>(
        "0", Collections.singletonMap("user", "crate")
    );
    assertTrue(isValidUser(entry, "crate"));
    assertFalse(isValidUser(entry, "postgres"));

    // any user matches
    entry = new HashMap.SimpleEntry<>(
        "0", Collections.emptyMap() // key "user" not present in map
    );
    assertTrue(isValidUser(entry, randomAlphaOfLength(8)));
}
 
Example 13
Source File: SMGBuilderTests.java    From CogniCrypt with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void mockSSLParametersRule() {
	StateMachineGraph expectedUsagePattern = new StateMachineGraph();
	StateNode minusOne = new StateNode("-1", true);
	StateNode zero = new StateNode("0", false);
	StateNode one = new StateNode("1", false);
	StateNode two = new StateNode("2", false, true);
	StateNode three = new StateNode("3", false);
	StateNode four = new StateNode("4", false);

	expectedUsagePattern.addNode(minusOne);
	expectedUsagePattern.addNode(zero);
	expectedUsagePattern.addNode(one);
	expectedUsagePattern.addNode(two);
	expectedUsagePattern.addNode(three);
	expectedUsagePattern.addNode(four);

	CrySLMethod aap = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.a", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));
	CrySLMethod abp = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.b", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));
	CrySLMethod acp = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.c", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));
	CrySLMethod adp = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.d", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));
	CrySLMethod aep = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.e", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));

	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {aap}), minusOne, zero));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {abp}), zero, one));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {acp}), one, two));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {acp}), zero, three));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {abp}), three, two));

	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {adp}), minusOne, four));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {abp}), four, two));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {aep}), minusOne, two));

	Assert.assertEquals(expectedUsagePattern.getAllTransitions(), readRuleFromFuleName("Testrule11").getUsagePattern().getAllTransitions());
}
 
Example 14
Source File: SMGBuilderTests.java    From CogniCrypt with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void mockCBCBlockCipherRule() {
	StateMachineGraph expectedUsagePattern = new StateMachineGraph();
	StateNode minusOne = new StateNode("-1", true);
	StateNode zero = new StateNode("0", false);
	StateNode one = new StateNode("1", false);
	StateNode two = new StateNode("2", false);
	StateNode three = new StateNode("3", false, true);
	StateNode four = new StateNode("4", false);

	expectedUsagePattern.addNode(minusOne);
	expectedUsagePattern.addNode(zero);
	expectedUsagePattern.addNode(one);
	expectedUsagePattern.addNode(two);
	expectedUsagePattern.addNode(three);
	expectedUsagePattern.addNode(four);

	CrySLMethod aap = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.a", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));
	CrySLMethod abp = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.b", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));
	CrySLMethod acp = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.c", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));
	CrySLMethod adp = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.d", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));

	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {aap}), minusOne, zero));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {abp}), zero, one));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {abp}), one, one));

	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {acp}), one, two));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {acp}), two, two));

	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {adp}), two, three));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {adp}), one, three));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {adp}), three, three));

	Assert.assertEquals(expectedUsagePattern.getAllTransitions(), readRuleFromFuleName("Testrule14").getUsagePattern().getAllTransitions());
}
 
Example 15
Source File: SMGBuilderTests.java    From CogniCrypt with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void mockSHA256DigestRule() {
	StateMachineGraph expectedUsagePattern = new StateMachineGraph();
	StateNode minusOne = new StateNode("-1", true);
	StateNode zero = new StateNode("0", false, true);
	StateNode one = new StateNode("1", false, true);
	StateNode two = new StateNode("2", false, true);
	StateNode three = new StateNode("3", false);

	expectedUsagePattern.addNode(minusOne);
	expectedUsagePattern.addNode(zero);
	expectedUsagePattern.addNode(one);
	expectedUsagePattern.addNode(two);
	expectedUsagePattern.addNode(three);

	CrySLMethod aap = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.a", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void")); // SHA256()
	CrySLMethod abp = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.b", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void")); // reset()
	CrySLMethod acp = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.c", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void")); // doFinal()
	CrySLMethod adp = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.d", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void")); // update()

	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {aap}), minusOne, zero));

	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {abp}), zero, one));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {acp}), one, two));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {adp}), one, three));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {adp}), three, three));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {acp}), three, two));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {acp}), zero, two));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {adp}), zero, three));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {acp}), two, two));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {adp}), two, three));

	Assert.assertEquals(expectedUsagePattern.getAllTransitions(), readRuleFromFuleName("Testrule15").getUsagePattern().getAllTransitions());
}
 
Example 16
Source File: SMGBuilderTests.java    From CogniCrypt with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void mockKeyStoreRule() {
	StateMachineGraph expectedUsagePattern = new StateMachineGraph();
	StateNode minusOne = new StateNode("-1", true);
	StateNode zero = new StateNode("0", false);
	StateNode one = new StateNode("1", false, true);
	StateNode two = new StateNode("2", false);
	StateNode three = new StateNode("3", false, true);
	StateNode four = new StateNode("4", false);

	expectedUsagePattern.addNode(minusOne);
	expectedUsagePattern.addNode(zero);
	expectedUsagePattern.addNode(one);
	expectedUsagePattern.addNode(two);
	expectedUsagePattern.addNode(three);
	expectedUsagePattern.addNode(four);

	CrySLMethod aap = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.a", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));
	CrySLMethod abp = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.b", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));
	CrySLMethod acp = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.c", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));
	CrySLMethod adp = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.d", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));
	CrySLMethod aep = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.e", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));
	CrySLMethod afp = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.f", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));

	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {aap}), minusOne, zero));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {abp}), zero, one));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {acp}), one, two));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {adp}), two, three));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {adp}), one, three));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {aep}), one, four));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {afp}), four, three));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {acp}), three, two));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {adp}), three, three));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {aep}), three, four));

	Assert.assertEquals(expectedUsagePattern.getAllTransitions(), readRuleFromFuleName("Testrule10").getUsagePattern().getAllTransitions());
}
 
Example 17
Source File: SMGBuilderTests.java    From CogniCrypt with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void mockRsaDigestSignerRule() {
	StateMachineGraph expectedUsagePattern = new StateMachineGraph();
	StateNode minusOne = new StateNode("-1", true);
	StateNode zero = new StateNode("0", false);
	StateNode one = new StateNode("1", false);
	StateNode two = new StateNode("2", false);
	StateNode three = new StateNode("3", false, true);
	StateNode four = new StateNode("4", false);
	StateNode five = new StateNode("5", false);
	StateNode six = new StateNode("6", false);
	StateNode seven = new StateNode("7", false, true);

	expectedUsagePattern.addNode(minusOne);
	expectedUsagePattern.addNode(zero);
	expectedUsagePattern.addNode(one);
	expectedUsagePattern.addNode(two);
	expectedUsagePattern.addNode(three);
	expectedUsagePattern.addNode(four);
	expectedUsagePattern.addNode(five);
	expectedUsagePattern.addNode(six);
	expectedUsagePattern.addNode(seven);

	CrySLMethod aap = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.a", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));
	CrySLMethod acp = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.c", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));
	CrySLMethod adp = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.d", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));
	CrySLMethod aep = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.e", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));
	CrySLMethod abp = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.b", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));
	CrySLMethod afp = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.f", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));

	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {aap}), minusOne, zero));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {acp}), zero, one));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {adp}), one, two));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {aep}), two, three));

	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {abp}), minusOne, four));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {acp}), four, five));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {adp}), five, six));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {afp}), six, seven));

	Assert.assertEquals(expectedUsagePattern.getAllTransitions(), readRuleFromFuleName("Testrule9").getUsagePattern().getAllTransitions());
}
 
Example 18
Source File: SMGBuilderTests.java    From CogniCrypt with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void mockSignatureRule() {
	StateMachineGraph expectedUsagePattern = new StateMachineGraph();
	StateNode minusOne = new StateNode("-1", true);
	StateNode zero = new StateNode("0", false);
	StateNode one = new StateNode("1", false);
	StateNode two = new StateNode("2", false);
	StateNode three = new StateNode("3", false, true);
	StateNode four = new StateNode("4", false);
	StateNode five = new StateNode("5", false);
	StateNode six = new StateNode("6", false, true);

	expectedUsagePattern.addNode(minusOne);
	expectedUsagePattern.addNode(zero);
	expectedUsagePattern.addNode(one);
	expectedUsagePattern.addNode(two);
	expectedUsagePattern.addNode(three);
	expectedUsagePattern.addNode(four);
	expectedUsagePattern.addNode(five);
	expectedUsagePattern.addNode(six);

	CrySLMethod aap = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.a", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));
	CrySLMethod abp = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.b", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));
	CrySLMethod acp = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.c", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));
	CrySLMethod adp = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.d", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));
	CrySLMethod aep = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.e", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));
	CrySLMethod afp = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.f", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));

	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {aap}), minusOne, zero));

	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {abp}), zero, one));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {abp}), one, one));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {acp}), one, two));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {acp}), two, two));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {adp}), two, three));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {adp}), three, three));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {acp}), three, two));

	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {aep}), zero, four));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {aep}), four, four));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {acp}), four, five));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {acp}), five, five));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {afp}), five, six));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {afp}), six, six));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {afp}), four, six));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {acp}), six, five));

	Assert.assertEquals(expectedUsagePattern.getAllTransitions(), readRuleFromFuleName("Testrule5").getUsagePattern().getAllTransitions());
}
 
Example 19
Source File: SMGBuilderTests.java    From CogniCrypt with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void mockCipherRule() {
	StateMachineGraph expectedUsagePattern = new StateMachineGraph();
	StateNode minusOne = new StateNode("-1", true);
	StateNode zero = new StateNode("0", false);
	StateNode one = new StateNode("1", false);
	StateNode two = new StateNode("2", false, true);
	StateNode three = new StateNode("3", false, true);
	StateNode four = new StateNode("4", false);

	expectedUsagePattern.addNode(minusOne);
	expectedUsagePattern.addNode(zero);
	expectedUsagePattern.addNode(one);
	expectedUsagePattern.addNode(two);
	expectedUsagePattern.addNode(three);
	expectedUsagePattern.addNode(four);

	CrySLMethod aap = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.a", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));
	CrySLMethod abp = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.b", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));
	CrySLMethod acp = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.c", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));
	CrySLMethod adp = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.d", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));
	CrySLMethod aep = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.e", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));
	CrySLMethod afp = new CrySLMethod("de.cognicrypt.cryslhandler.TestA.f", new ArrayList<Entry<String, String>>(), new ArrayList<Boolean>(),
			new HashMap.SimpleEntry<String, String>("_", "void"));

	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {aap}), minusOne, zero));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {abp}), zero, one));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {abp}), one, one));

	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {acp}), one, two));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {acp}), two, two));

	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {adp}), one, three));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {aep}), one, four));

	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {aep}), four, four));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {adp, afp}), four, three));
	
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {acp}), three, two));
	
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {adp}), two, three));
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {aep}), two, four));
	
	expectedUsagePattern.addEdge(new TransitionEdge(Arrays.asList(new CrySLMethod[] {aep}), three, four));

	Assert.assertEquals(expectedUsagePattern.getAllTransitions(), readRuleFromFuleName("Testrule3").getUsagePattern().getAllTransitions());
}
 
Example 20
Source File: PartitionedRegionCustomEvictionDUnitTest.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
@Override
public Object next() {
  int key = (Integer)itr.next();
  int routingObject = key;
  return new HashMap.SimpleEntry(key, routingObject);
}