Add strategy dataset retrieval and tests
diff --git a/src/test/java/com/intel/jndn/management/StrategyTestIT.java b/src/test/java/com/intel/jndn/management/StrategyTestIT.java
new file mode 100644
index 0000000..3c63dd7
--- /dev/null
+++ b/src/test/java/com/intel/jndn/management/StrategyTestIT.java
@@ -0,0 +1,56 @@
+/*
+ * jndn-management
+ * Copyright (c) 2015, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU Lesser General Public License,
+ * version 3, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
+ * more details.
+ */
+package com.intel.jndn.management;
+
+import com.intel.jndn.management.types.StrategyChoice;
+import com.intel.jndn.mock.MockKeyChain;
+import com.intel.jndn.utils.SegmentedServer;
+import java.util.List;
+import java.util.logging.Logger;
+import static junit.framework.Assert.assertEquals;
+import net.named_data.jndn.Face;
+import net.named_data.jndn.Name;
+import net.named_data.jndn.security.KeyChain;
+import org.junit.Test;
+
+/**
+ * Test strategy management on a real, local NFD
+ *
+ * @author Andrew Brown <andrew.brown@intel.com>
+ */
+public class StrategyTestIT {
+
+ private static final Logger logger = Logger.getLogger(StrategyTestIT.class.getName());
+ Name prefix;
+ Face face;
+
+ public StrategyTestIT() throws net.named_data.jndn.security.SecurityException {
+ this.prefix = new Name("/test/strategy");
+ this.face = new Face("localhost"); // strategy commands only available on localhost
+ KeyChain mockKeyChain = MockKeyChain.configure(new Name("/test/server"));
+ face.setCommandSigningInfo(mockKeyChain, mockKeyChain.getDefaultCertificateName());
+ }
+
+ @Test
+ public void testStrategySetUnset() throws Exception {
+ List<StrategyChoice> choices = NFD.getStrategyList(face);
+ int oldSize = choices.size();
+
+ NFD.setStrategy(face, prefix, Strategies.CLIENT_CONTROL);
+ choices = NFD.getStrategyList(face);
+ assertEquals(oldSize + 1, choices.size());
+
+ NFD.unsetStrategy(face, prefix);
+ }
+}
diff --git a/src/test/java/com/intel/jndn/management/types/StrategyChoiceTest.java b/src/test/java/com/intel/jndn/management/types/StrategyChoiceTest.java
new file mode 100644
index 0000000..7783bb1
--- /dev/null
+++ b/src/test/java/com/intel/jndn/management/types/StrategyChoiceTest.java
@@ -0,0 +1,56 @@
+/*
+ * jndn-management
+ * Copyright (c) 2015, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU Lesser General Public License,
+ * version 3, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
+ * more details.
+ */
+package com.intel.jndn.management.types;
+
+import com.intel.jndn.management.Strategies;
+import java.nio.ByteBuffer;
+import junit.framework.Assert;
+import net.named_data.jndn.Name;
+import net.named_data.jndn.encoding.EncodingException;
+import net.named_data.jndn.encoding.tlv.TlvDecoder;
+import net.named_data.jndn.encoding.tlv.TlvEncoder;
+import net.named_data.jndn.util.Blob;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author Andrew Brown <andrew.brown@intel.com>
+ */
+public class StrategyChoiceTest {
+
+ public StrategyChoiceTest() {
+ }
+
+ /**
+ * Test of wireEncode method, of class StrategyChoice.
+ */
+ @Test
+ public void testEncodeDecode() throws EncodingException {
+ StrategyChoice choice = new StrategyChoice();
+ choice.setName(new Name("/a/b"));
+ choice.setStrategy(Strategies.NCC);
+
+ // encode
+ Blob encoded = choice.wireEncode();
+
+ // decode
+ StrategyChoice decoded = new StrategyChoice();
+ decoded.wireDecode(encoded.buf());
+
+ // test
+ Assert.assertEquals(choice.getName().toUri(), decoded.getName().toUri());
+ Assert.assertEquals(choice.getStrategy().toUri(), decoded.getStrategy().toUri());
+ }
+}