You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@river.apache.org by pe...@apache.org on 2011/12/19 20:42:38 UTC
svn commit: r1220916 [2/2] - in /river/jtsk/skunk/peterConcurrentPolicy:
qa/src/com/sun/jini/test/spec/jeri/https/ src/net/jini/security/
src/net/jini/security/policy/ src/org/apache/river/api/delegates/
src/org/apache/river/api/security/ src/org/apach...
Modified: river/jtsk/skunk/peterConcurrentPolicy/src/org/apache/river/impl/security/policy/util/Segment.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/peterConcurrentPolicy/src/org/apache/river/impl/security/policy/util/Segment.java?rev=1220916&r1=1220915&r2=1220916&view=diff
==============================================================================
--- river/jtsk/skunk/peterConcurrentPolicy/src/org/apache/river/impl/security/policy/util/Segment.java (original)
+++ river/jtsk/skunk/peterConcurrentPolicy/src/org/apache/river/impl/security/policy/util/Segment.java Mon Dec 19 19:42:37 2011
@@ -20,6 +20,8 @@ package org.apache.river.impl.security.p
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
import java.util.Properties;
import org.apache.river.impl.security.policy.util.PolicyUtils.ExpansionFailedException;
@@ -36,47 +38,88 @@ import org.apache.river.impl.security.po
* every possible unique string combination is produced, before the status of
* the first link becomes complete.
*
- * Segments
+ * Segments are not thread safe.
+ *
+ * Segments are comparable, but shouldn't be compared until after segmentation
+ * is completed, so initially should be stored in an unsorted Collection.
+ *
* @author Peter Firmstone.
*/
public class Segment implements Comparable {
private Segment previous;
- private String [] properties;
+ private Segment [] divisions;
private String original;
- private int length = 0;
+// private int length = 0;
int counter = 0;
Status stat;
+ private StringBuilder sb;
+ private boolean toggle;
public Segment(String s, Segment preceed){
previous = preceed;
stat = Status.STRING;
- properties = null;
+ divisions = null;
+ original = s;
+ sb = null;
+ toggle = false;
}
@Override
public String toString(){
- if (stat.equals(Status.STRING)) return original;
- return properties[counter];
+ return original;
}
public Status status(){
return stat;
}
+
+ public boolean hasNext(){
+ if (allStringState()) return true;
+ if ( stat.equals(Status.COMPLETE) || stat.equals(Status.STRING)) {
+ return previous == null ? false : previous.hasNext();
+ }
+ return true;
+ }
+
+ private boolean allStringState(){
+ if (toggle) return false;
+ toggle = true;
+ if ( ( previous == null || previous.allStringState()) && status().equals(Status.STRING)) return true;
+ return false;
+ }
- public void next(){
+ /**
+ * Must only be called on the last segment in the Set after sorting.
+ */
+ public String next(){
+ if (sb == null) sb = new StringBuilder(120);
+ else sb.delete(0, sb.capacity() -1 );
+ append(sb);
if ( stat.equals(Status.COMPLETE)){
- counter = 0;
- stat = Status.MORE;
if (previous != null ){
previous.next();
}
} else if ( stat.equals(Status.MORE)){
- counter ++;
- if (counter == length){
+ if (divisions[counter].status().equals(Status.MORE)){
+ divisions[counter].next();
+ } else {
+ counter ++;
+ }
+ if (counter == divisions.length){
stat = Status.COMPLETE;
}
} else if ( stat.equals(Status.STRING)&& previous != null){
- previous.next();
+ if (previous != null) {
+ previous.next(); // ensures backward propagation.
+ }
}
+ return sb.toString();
+ }
+
+ private StringBuilder append(StringBuilder sb){
+ if (previous != null) previous.append(sb);
+ if (divisions != null) divisions[counter].append(sb);
+ else sb.append(original);
+ return sb;
}
private int sequenceNumber(){
@@ -107,12 +150,19 @@ public class Segment implements Comparab
* @param p
* @return
*/
- public Collection<Segment> divideAndReplace(String START_MARK, String END_MARK,
+ public void divideAndReplace(String START_MARK, String END_MARK,
String regex, Properties p) throws ExpansionFailedException{
- Collection<Segment> result = new ArrayList<Segment>();
+ if (previous != null) previous.divideAndReplace(START_MARK, END_MARK, regex, p);
+ if (divisions != null ){
+ int l = divisions.length;
+ for (int i = 0; i < l ; i++ ){
+ divisions[i].divideAndReplace(START_MARK, END_MARK, regex, p);
+ }
+ // If divisions exist, then this Segment has already been processed.
+ return;
+ }
String orig = original; //original reference is replaced
- Segment last = previous; //previous reference too.
- ArrayList<String> segments = new ArrayList<String>();
+ Segment prev = previous; //previous reference too.
final int START_OFFSET = START_MARK.length();
final int END_OFFSET = END_MARK.length();
int start = orig.indexOf(START_MARK);
@@ -120,47 +170,45 @@ public class Segment implements Comparab
int beginning = 0;
while (start >= 0) {
// Get the segment preceeding the key, or between keys.
- Segment seg = new Segment(orig.substring(beginning, start), last);
- result.add(seg);
- last = seg;
+ Segment seg;
+ if ( start > beginning && beginning >= 0){
+ seg = new Segment(orig.substring(beginning, start), prev);
+ prev = seg;
+ }
end = orig.indexOf(END_MARK, start);
if (end >= 0) {
String key = orig.substring(start + START_OFFSET, end);
String value = p.getProperty(key);
if (value != null) {
- seg = new Segment(value, last);
+ seg = new Segment(value, prev);
if (regex != null) {
seg.split(regex);
seg.status(Status.MORE);
}
- result.add(seg);
- last = seg;
+ prev = seg;
} else {
throw new ExpansionFailedException(Messages.getString("security.14F", key)); //$NON-NLS-1$
}
}
- beginning = end;
- start = orig.indexOf(START_MARK, start);
+ beginning = end + END_OFFSET;
+ start = orig.indexOf(START_MARK, beginning);
}
// Now there could be a trailing string.
- if (end < orig.length()){
+ if (beginning < orig.length()){
// Use this to represent it.
- previous = last;
- original = orig.substring(end);
- } else if ( end == orig.length() && last != null){
+ previous = prev;
+ original = orig.substring(beginning);
+ } else if ( beginning == orig.length() && prev != null){
// Replace the last Segment in the list with this, after
// making it equal. The reason for doing so is that a downstream
// Segment may reference this.
- result.remove(last);
- previous = last.previous;
- original = last.original;
- properties = last.properties;
- length = last.length;
- stat = last.stat;
+ previous = prev.previous;
+ original = prev.original;
+ divisions = prev.divisions;
+// length = last.length;
+ stat = prev.stat;
}
- result.add(this); //We must always keep this since other Segments may reference it.
- return result;
}
/**
@@ -168,7 +216,13 @@ public class Segment implements Comparab
* internally.
*/
private void split(String regex){
- properties = original.split(regex);
+ String [] prop = original.split(regex);
+ int l = prop.length;
+ divisions = new Segment[l];
+ for (int i = 0; i < l; i++ ){
+ // Divisions are parallel, they don't preceed or link to each other.
+ divisions[i] = new Segment(prop[i], null);
+ }
}
private void status(Status status){
Modified: river/jtsk/skunk/peterConcurrentPolicy/test/src/net/jini/security/ConcurrentPermissionsTest.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/peterConcurrentPolicy/test/src/net/jini/security/ConcurrentPermissionsTest.java?rev=1220916&r1=1220915&r2=1220916&view=diff
==============================================================================
--- river/jtsk/skunk/peterConcurrentPolicy/test/src/net/jini/security/ConcurrentPermissionsTest.java (original)
+++ river/jtsk/skunk/peterConcurrentPolicy/test/src/net/jini/security/ConcurrentPermissionsTest.java Mon Dec 19 19:42:37 2011
@@ -1,6 +1,19 @@
/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.jini.security;
Copied: river/jtsk/skunk/peterConcurrentPolicy/test/src/net/jini/security/DynamicPermissionCollectionTest.java (from r1213147, river/jtsk/skunk/peterConcurrentPolicy/test/src/net/jini/security/MultiReadPermissionCollectionTest.java)
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/peterConcurrentPolicy/test/src/net/jini/security/DynamicPermissionCollectionTest.java?p2=river/jtsk/skunk/peterConcurrentPolicy/test/src/net/jini/security/DynamicPermissionCollectionTest.java&p1=river/jtsk/skunk/peterConcurrentPolicy/test/src/net/jini/security/MultiReadPermissionCollectionTest.java&r1=1213147&r2=1220916&rev=1220916&view=diff
==============================================================================
--- river/jtsk/skunk/peterConcurrentPolicy/test/src/net/jini/security/MultiReadPermissionCollectionTest.java (original)
+++ river/jtsk/skunk/peterConcurrentPolicy/test/src/net/jini/security/DynamicPermissionCollectionTest.java Mon Dec 19 19:42:37 2011
@@ -1,11 +1,30 @@
/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.jini.security;
+import java.util.Collection;
+import java.io.IOException;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
import java.security.Permission;
import java.security.PermissionCollection;
import java.util.ArrayList;
@@ -21,9 +40,9 @@ import static org.junit.Assert.*;
*
* @author peter
*/
-public class MultiReadPermissionCollectionTest {
+public class DynamicPermissionCollectionTest {
- public MultiReadPermissionCollectionTest() {
+ public DynamicPermissionCollectionTest() {
}
@org.junit.BeforeClass
@@ -49,19 +68,18 @@ public class MultiReadPermissionCollecti
public void isReadOnly() {
System.out.println("isReadOnly");
Permission permission0 = new RuntimePermission("getClassLoader");
- MultiReadPermissionCollection instance = new MultiReadPermissionCollection(permission0);
+ PermissionCollection instance =
+ new DynamicPermissionCollection(null,permission0.getClass());
instance.setReadOnly();
- SecurityException exp = new SecurityException("attempt to add a Permission to a readonly PermissionCollection");
- String result = null;
+ Exception result = null;
Permission permission1 = new RuntimePermission("getProtectionDomain");
try {
instance.add(permission1);
}catch (SecurityException e) {
- result = e.toString();
+ result = e;
System.out.println(e.toString());
}
- String expResult = exp.toString();
- assertEquals(expResult, result);
+ assertTrue(result instanceof SecurityException );
}
/**
@@ -71,7 +89,8 @@ public class MultiReadPermissionCollecti
public void implies() {
System.out.println("add");
Permission permission = new RuntimePermission("getClassLoader");
- PermissionCollection instance = new MultiReadPermissionCollection(permission);
+ PermissionCollection instance =
+ new DynamicPermissionCollection(null,permission.getClass());
instance.add(permission);
boolean result = instance.implies(permission);
assertEquals(true, result);
@@ -86,7 +105,7 @@ public class MultiReadPermissionCollecti
Permission permission0 = new AccessPermission("org.some.class");
Permission permission1 = new AccessPermission("org.some.other.class");
Permission permission2 = new AccessPermission("org.another.class");
- PermissionCollection instance = new MultiReadPermissionCollection(permission0);
+ PermissionCollection instance = new DynamicPermissionCollection(null,permission0.getClass());
instance.add(permission0);
instance.add(permission1);
instance.add(permission2);
@@ -104,6 +123,42 @@ public class MultiReadPermissionCollecti
assertEquals(expRes, res);
}
-
+ /**
+ * Test of readResolve method.
+ */
+ @Test
+ public void testSerialization() {
+ System.out.println("Serialization test");
+ Permission permission0 = new AccessPermission("org.some.class");
+ Permission permission1 = new AccessPermission("org.some.other.class");
+ Permission permission2 = new AccessPermission("org.another.class");
+ PermissionCollection pc = new DynamicPermissionCollection(null,permission0.getClass());
+ Collection<Permission> expResult = new ArrayList<Permission>(3);
+ pc.add(permission0);
+ pc.add(permission1);
+ pc.add(permission2);
+ expResult.add(permission0);
+ expResult.add(permission1);
+ expResult.add(permission2);
+ Collection<Permission> result = new ArrayList<Permission>(3);
+ ObjectOutputStream out = null;
+ ObjectInputStream in = null;
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try {
+ out = new ObjectOutputStream(baos);
+ out.writeObject(pc);
+ // Unmarshall it
+ in = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
+ Enumeration<Permission> en = ((PermissionCollection) in.readObject()).elements();
+ while(en.hasMoreElements()){
+ result.add(en.nextElement());
+ }
+ } catch (IOException ex) {
+ ex.printStackTrace(System.out);
+ } catch (ClassNotFoundException ex){
+ ex.printStackTrace(System.out);
+ }
+ assertEquals(expResult, result);
+ }
}
\ No newline at end of file
Modified: river/jtsk/skunk/peterConcurrentPolicy/test/src/net/jini/security/GrantPermissionTest.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/peterConcurrentPolicy/test/src/net/jini/security/GrantPermissionTest.java?rev=1220916&r1=1220915&r2=1220916&view=diff
==============================================================================
--- river/jtsk/skunk/peterConcurrentPolicy/test/src/net/jini/security/GrantPermissionTest.java (original)
+++ river/jtsk/skunk/peterConcurrentPolicy/test/src/net/jini/security/GrantPermissionTest.java Mon Dec 19 19:42:37 2011
@@ -1,6 +1,19 @@
/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.jini.security;
Modified: river/jtsk/skunk/peterConcurrentPolicy/test/src/net/jini/security/MultiReadPermissionCollectionTest.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/peterConcurrentPolicy/test/src/net/jini/security/MultiReadPermissionCollectionTest.java?rev=1220916&r1=1220915&r2=1220916&view=diff
==============================================================================
--- river/jtsk/skunk/peterConcurrentPolicy/test/src/net/jini/security/MultiReadPermissionCollectionTest.java (original)
+++ river/jtsk/skunk/peterConcurrentPolicy/test/src/net/jini/security/MultiReadPermissionCollectionTest.java Mon Dec 19 19:42:37 2011
@@ -1,6 +1,19 @@
/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.jini.security;
Modified: river/jtsk/skunk/peterConcurrentPolicy/test/src/org/apache/river/api/security/DelegateCombinerSecurityManagerTest.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/peterConcurrentPolicy/test/src/org/apache/river/api/security/DelegateCombinerSecurityManagerTest.java?rev=1220916&r1=1220915&r2=1220916&view=diff
==============================================================================
--- river/jtsk/skunk/peterConcurrentPolicy/test/src/org/apache/river/api/security/DelegateCombinerSecurityManagerTest.java (original)
+++ river/jtsk/skunk/peterConcurrentPolicy/test/src/org/apache/river/api/security/DelegateCombinerSecurityManagerTest.java Mon Dec 19 19:42:37 2011
@@ -111,7 +111,7 @@ public class DelegateCombinerSecurityMan
Boolean result = Boolean.FALSE;
Boolean expectedResult = Boolean.FALSE;
try {
- sm.checkPermission(p1, acc);
+ sm.checkPermission(p1, acc);
result = Boolean.TRUE;
} catch (SecurityException e){
result = Boolean.FALSE;
@@ -125,7 +125,41 @@ public class DelegateCombinerSecurityMan
Boolean result = Boolean.FALSE;
Boolean expectedResult = Boolean.TRUE;
try {
- sm.checkPermission(p2, acc);
+ /* This permission check is cached, lets test performance.
+ */
+ for (int i = 0; i < 200000; i++ ){
+ sm.checkPermission(p2, acc);
+ }
+ result = Boolean.TRUE;
+ } catch (Exception e){
+ e.printStackTrace(System.out);
+ result = Boolean.FALSE;
+ }
+ assertEquals(expectedResult,result);
+ }
+
+ @Test
+ public void testCheckPermission3() {
+ System.out.println("checkPermission3");
+ Boolean result = Boolean.FALSE;
+ Boolean expectedResult = Boolean.FALSE;
+ try {
+ sm.checkPermission(p3, acc);
+ result = Boolean.TRUE;
+ } catch (Exception e){
+ e.printStackTrace(System.out);
+ result = Boolean.FALSE;
+ }
+ assertEquals(expectedResult,result);
+ }
+
+ @Test
+ public void testCheckPermission4() {
+ System.out.println("checkPermission4");
+ Boolean result = Boolean.FALSE;
+ Boolean expectedResult = Boolean.TRUE;
+ try {
+ sm.checkPermission(p4, acc);
result = Boolean.TRUE;
} catch (Exception e){
e.printStackTrace(System.out);
Modified: river/jtsk/skunk/peterConcurrentPolicy/test/src/org/apache/river/impl/security/policy/util/DefaultPolicyParserTest.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/peterConcurrentPolicy/test/src/org/apache/river/impl/security/policy/util/DefaultPolicyParserTest.java?rev=1220916&r1=1220915&r2=1220916&view=diff
==============================================================================
--- river/jtsk/skunk/peterConcurrentPolicy/test/src/org/apache/river/impl/security/policy/util/DefaultPolicyParserTest.java (original)
+++ river/jtsk/skunk/peterConcurrentPolicy/test/src/org/apache/river/impl/security/policy/util/DefaultPolicyParserTest.java Mon Dec 19 19:42:37 2011
@@ -22,8 +22,8 @@
package org.apache.river.impl.security.policy.util;
-import org.apache.river.impl.security.policy.util.*;
-import org.apache.river.impl.security.policy.util.DefaultPolicyParser;
+import java.util.Properties;
+import java.util.SortedSet;
import java.io.File;
import java.io.FileWriter;
import java.net.URL;
@@ -32,13 +32,14 @@ import java.security.Permission;
import java.security.Principal;
import java.security.SecurityPermission;
import java.security.cert.Certificate;
-import java.util.Arrays;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
-
import java.util.List;
+
import junit.framework.TestCase;
import org.apache.river.api.security.PermissionGrant;
+import org.junit.Test;
/**
@@ -94,6 +95,35 @@ public class DefaultPolicyParserTest ext
tmp.delete();
}
}
+
+// /**
+// * Test of segment method, of class DefaultPolicyParser.
+// */
+// @Test
+// public void testSegment() throws Exception {
+// System.out.println("segment");
+// String s = "";
+// Properties p = null;
+// DefaultPolicyParser instance = new DefaultPolicyParser();
+// List expResult = new ArrayList();
+// List result = instance.segment(s, p);
+// assertEquals(expResult, result);
+// }
+//
+// /**
+// * Test of expandURLs method, of class DefaultPolicyParser.
+// */
+// @Test
+// public void testExpandURLs() throws Exception {
+// System.out.println("expandURLs");
+// String s = "";
+// Properties p = null;
+// DefaultPolicyParser instance = new DefaultPolicyParser();
+// Collection expResult = null;
+// Collection result = instance.expandURLs(s, p);
+// assertEquals(expResult, result);
+// }
+//
}
class FakePrincipal implements Principal {
Modified: river/jtsk/skunk/peterConcurrentPolicy/test/src/org/apache/river/impl/security/policy/util/SegmentTest.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/peterConcurrentPolicy/test/src/org/apache/river/impl/security/policy/util/SegmentTest.java?rev=1220916&r1=1220915&r2=1220916&view=diff
==============================================================================
--- river/jtsk/skunk/peterConcurrentPolicy/test/src/org/apache/river/impl/security/policy/util/SegmentTest.java (original)
+++ river/jtsk/skunk/peterConcurrentPolicy/test/src/org/apache/river/impl/security/policy/util/SegmentTest.java Mon Dec 19 19:42:37 2011
@@ -18,7 +18,10 @@
package org.apache.river.impl.security.policy.util;
+import java.util.List;
+import java.util.Collection;
import java.util.Properties;
+import org.apache.river.impl.security.policy.util.PolicyUtils.ExpansionFailedException;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
@@ -35,14 +38,72 @@ public class SegmentTest {
@Before
public void setup(){
p = new Properties();
- p.setProperty("java.ext.dirs", "tests:foo:bar:cat");
+ p.setProperty("java.ext.dirs", "tests:foo:bar:${jini.home}");
+ p.setProperty("jini.home", "${river.apache.org}");
+ p.setProperty("river.apache.org", "/opt/src/river");
}
@Test
- public void divideAndReplace(){
+ public void divideAndReplace() throws ExpansionFailedException{
System.out.println("Test divideAndReplace");
+ System.out.println(p.toString());
String policyGrantln = "file:${{java.ext.dirs}}/*";
+ System.out.println(policyGrantln);
+ Segment seg = new Segment(policyGrantln, null);
+ String startMark = "${{";
+ String endMark = "}}";
+ seg.divideAndReplace(startMark, endMark, ":", p);
+ while (seg.hasNext()){
+ System.out.println(seg.next());
+ }
+ }
+
+ @Test
+ public void divideAndReplaceTwice() throws ExpansionFailedException{
+ System.out.println("Test nested divideAndReplace");
+ System.out.println(p.toString());
+ String policyGrantln = "file:${{java.ext.dirs}}/*";
+ System.out.println(policyGrantln);
+ Segment seg = new Segment(policyGrantln, null);
+ String startMark = "${{";
+ String endMark = "}}";
+ seg.divideAndReplace(startMark, endMark, ":", p);
+ seg.divideAndReplace("${", "}", null, p);
+ while (seg.hasNext()){
+ System.out.println(seg.next());
+ }
+ }
+
+ @Test
+ public void divideAndReplaceThrice() throws ExpansionFailedException{
+ System.out.println("Test duplicate nested divideAndReplace");
+ System.out.println(p.toString());
+ String policyGrantln = "file:${{java.ext.dirs}}/*";
+ System.out.println(policyGrantln);
+ Segment seg = new Segment(policyGrantln, null);
+ String startMark = "${{";
+ String endMark = "}}";
+ seg.divideAndReplace(startMark, endMark, ":", p);
+ seg.divideAndReplace("${", "}", null, p);
+ seg.divideAndReplace("${", "}", null, p);
+ while (seg.hasNext()){
+ System.out.println(seg.next());
+ }
+ }
+
+ @Test
+ public void divideAndReplaceNoArray() throws ExpansionFailedException{
+ System.out.println("Test divideAndReplace");
+ System.out.println(p.toString());
+ String policyGrantln = "file:${jini.home}/*";
+ System.out.println(policyGrantln);
+ Segment seg = new Segment(policyGrantln, null);
+ String startMark = "${";
+ String endMark = "}";
+ seg.divideAndReplace(startMark, endMark, null, p);
+ while (seg.hasNext()){
+ System.out.println(seg.next());
+ }
}
-
}