blob: a44bda4eecf71ecd691aceeca6d95568df083e0c [file] [log] [blame]
/*
* 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 org.apache.sling.fsprovider.internal.mapper;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class EscapeTest {
@Test
public void testFileToResourceName() {
assertEquals("abc", Escape.fileToResourceName("abc"));
assertEquals("abc.txt", Escape.fileToResourceName("abc.txt"));
assertEquals("xyz:abc.txt", Escape.fileToResourceName("xyz%3Aabc.txt"));
assertEquals("a<>:\"/\\|?*b", Escape.fileToResourceName("a%3C%3E%3A%22/%5C%7C%3F%2Ab"));
assertEquals("", Escape.fileToResourceName(""));
}
@Test
public void testResourceToFileName() {
assertEquals("abc", Escape.resourceToFileName("abc"));
assertEquals("abc.txt", Escape.resourceToFileName("abc.txt"));
assertEquals("xyz%3Aabc.txt", Escape.resourceToFileName("xyz:abc.txt"));
// URLEncoder does not encode '*'
assertEquals("a%3C%3E%3A%22/%5C%7C%3F*b", Escape.resourceToFileName("a<>:\"/\\|?*b"));
assertEquals("", Escape.resourceToFileName(""));
}
}