Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkuppe2008-12-16 09:56:20 -0500
committermkuppe2008-12-16 09:56:20 -0500
commitd079211432da24758960da6e8d7bc11695f446ec (patch)
tree0460e2aa883999210308f4f15069cedec88b47f0
parent7885e3a1336d3948a385c4dc5d995560f0a70da5 (diff)
downloadorg.eclipse.ecf-d079211432da24758960da6e8d7bc11695f446ec.tar.gz
org.eclipse.ecf-d079211432da24758960da6e8d7bc11695f446ec.tar.xz
org.eclipse.ecf-d079211432da24758960da6e8d7bc11695f446ec.zip
NEW - bug 258927: [Discovery][SLP] byte service properties aren't correctly converted into an octet sequence (Base64)
https://bugs.eclipse.org/bugs/show_bug.cgi?id=258927
-rw-r--r--protocols/bundles/ch.ethz.iks.slp/src/test/java/ch/ethz/iks/slp/impl/AttributeParserTest.java114
1 files changed, 114 insertions, 0 deletions
diff --git a/protocols/bundles/ch.ethz.iks.slp/src/test/java/ch/ethz/iks/slp/impl/AttributeParserTest.java b/protocols/bundles/ch.ethz.iks.slp/src/test/java/ch/ethz/iks/slp/impl/AttributeParserTest.java
new file mode 100644
index 000000000..809f25c14
--- /dev/null
+++ b/protocols/bundles/ch.ethz.iks.slp/src/test/java/ch/ethz/iks/slp/impl/AttributeParserTest.java
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Versant Corp.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Kuppe (mkuppe <at> versant <dot> com) - initial API and implementation
+ ******************************************************************************/
+
+package ch.ethz.iks.slp.impl;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import ch.ethz.iks.slp.ServiceLocationException;
+
+import junit.framework.TestCase;
+
+public class AttributeParserTest extends TestCase {
+
+ private static final String NEG_INTEGER = "(IntegerMax=-2147483648)";
+ private static final String POS_INTEGER = "(IntegerMin=2147483647)";
+ private static final String VENDOR_WITH_EN = "(x-28392-FOOBAR=FOOBAR)";
+ private static final String STRING = "(String=foobar asdflj24 aslkujh2)";
+ private static final String BOOLEAN = "(Boolean=false)";
+ private static final String BYTE = "(Byte=\\FF\\00\\01\\02\\A1\\99\\AA\\EE)";
+
+ /**
+ * Test method for {@link ch.ethz.iks.slp.impl.SLPMessage#attributeStringToList(java.lang.String)}.
+ */
+ public void testByteAttributeType() {
+ SLPTestMessage stm = new SLPTestMessage();
+ String input = BYTE;
+ List attributeStringToList = new ArrayList();
+ try {
+ attributeStringToList = stm.attributeStringToList(input);
+ } catch(ServiceLocationException e) {
+ fail("Input " + input + " must be valid");
+ }
+
+ assertEquals(1, attributeStringToList.size());
+ assertTrue(attributeStringToList.contains(BYTE));
+ }
+
+ /**
+ * Test method for {@link ch.ethz.iks.slp.impl.SLPMessage#attributeStringToList(java.lang.String)}.
+ */
+ public void testStringAttributeType() {
+ SLPTestMessage stm = new SLPTestMessage();
+ String input = STRING;
+ List attributeStringToList = new ArrayList();
+ try {
+ attributeStringToList = stm.attributeStringToList(input);
+ } catch(ServiceLocationException e) {
+ fail("Input " + input + " must be valid");
+ }
+
+ assertEquals(1, attributeStringToList.size());
+ assertTrue(attributeStringToList.contains(STRING));
+ }
+
+ /**
+ * Test method for {@link ch.ethz.iks.slp.impl.SLPMessage#attributeStringToList(java.lang.String)}.
+ */
+ public void testAllAttributeType() {
+ SLPTestMessage stm = new SLPTestMessage();
+ String input = STRING + "," + BOOLEAN + "," + BYTE + "," + VENDOR_WITH_EN + "," + POS_INTEGER + "," + NEG_INTEGER;
+ List attributeStringToList = new ArrayList();
+ try {
+ attributeStringToList = stm.attributeStringToList(input);
+ } catch(ServiceLocationException e) {
+ fail("Input " + input + " must be valid");
+ }
+
+ assertEquals(6, attributeStringToList.size());
+
+ assertTrue(attributeStringToList.contains(NEG_INTEGER));
+ assertTrue(attributeStringToList.contains(POS_INTEGER));
+ assertTrue(attributeStringToList.contains(VENDOR_WITH_EN));
+ assertTrue(attributeStringToList.contains(STRING));
+ assertTrue(attributeStringToList.contains(BOOLEAN));
+ assertTrue(attributeStringToList.contains(BYTE));
+ }
+
+ // just make attributeStringToList public
+ private class SLPTestMessage extends SLPMessage {
+ int getSize() {
+ return 0;
+ }
+
+ void writeTo(DataOutputStream out) throws IOException {
+ // no op
+ }
+
+ /* (non-Javadoc)
+ * @see ch.ethz.iks.slp.impl.SLPMessage#attributeStringToList(java.lang.String)
+ */
+ public List attributeStringToList(String input)
+ throws ServiceLocationException {
+ return super.attributeStringToList(input);
+ }
+
+ /* (non-Javadoc)
+ * @see ch.ethz.iks.slp.impl.SLPMessage#attributeStringToListLiberal(java.lang.String)
+ */
+ public List attributeStringToListLiberal(String input) {
+ return super.attributeStringToListLiberal(input);
+ }
+ }
+}

Back to the top