We have StandardCharsets, use those.
Change-Id: I92677e8a72cf16fc03df25226c967221959f14c5
Signed-off-by: Robert Varga <rovarga@cisco.com>
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
-import com.google.common.base.Charsets;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
+import java.nio.charset.StandardCharsets;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
}
public static Document readXmlToDocument(final String xmlContent) throws SAXException, IOException {
- return readXmlToDocument(new ByteArrayInputStream(xmlContent.getBytes(Charsets.UTF_8)));
+ return readXmlToDocument(new ByteArrayInputStream(xmlContent.getBytes(StandardCharsets.UTF_8)));
}
@Test
package org.opendaylight.yangtools.yang.data.impl.codec.xml;
-import com.google.common.base.Charsets;
import com.google.common.base.Optional;
import com.google.common.collect.Lists;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
}
public static Document readXmlToDocument(final String xmlContent) throws SAXException, IOException {
- return readXmlToDocument(new ByteArrayInputStream(xmlContent.getBytes(Charsets.UTF_8)));
+ return readXmlToDocument(new ByteArrayInputStream(xmlContent.getBytes(StandardCharsets.UTF_8)));
}
public static Document readXmlToDocument(final InputStream xmlContent) throws SAXException, IOException {
import static org.junit.Assert.assertNull;
-import com.google.common.base.Charsets;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.io.Files;
import java.io.StringWriter;
import java.net.URISyntaxException;
import java.net.URL;
+import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
-
import javax.activation.UnsupportedDataTypeException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
return ModifyAction.MERGE;
}
- return ModifyAction.fromXmlValue(Files.toString(new File(resource.toURI()), Charsets.UTF_8).trim());
+ return ModifyAction.fromXmlValue(Files.toString(new File(resource.toURI()), StandardCharsets.UTF_8).trim());
}
private void verifyModificationResult(final Optional<ContainerNode> result, final Optional<ContainerNode> expectedResult)
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
-import com.google.common.base.Charsets;
import com.google.common.base.Function;
import com.google.common.base.MoreObjects;
import com.google.common.base.Optional;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
assertThat(fileNames, both(hasItem("test2@0000-00-00")).and(hasItem("test@2012-12-12")));
- assertThat(Files.toString(storedFiles.get(0), Charsets.UTF_8), either(containsString(content)).or(containsString(content2)));
- assertThat(Files.toString(storedFiles.get(1), Charsets.UTF_8), either(containsString(content)).or(containsString(content2)));
+ assertThat(Files.toString(storedFiles.get(0), StandardCharsets.UTF_8), either(containsString(content)).or(containsString(content2)));
+ assertThat(Files.toString(storedFiles.get(1), StandardCharsets.UTF_8), either(containsString(content)).or(containsString(content2)));
verify(this.registry, times(2)).registerSchemaSource(any(SchemaSourceProvider.class), any(PotentialSchemaSource.class));
@Override
public InputStream openStream() throws IOException {
- return new ByteArrayInputStream(this.content.getBytes(Charsets.UTF_8));
+ return new ByteArrayInputStream(this.content.getBytes(StandardCharsets.UTF_8));
}
}
}
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doReturn;
-import com.google.common.base.Charsets;
import com.google.common.base.MoreObjects;
import com.google.common.base.Optional;
import com.google.common.util.concurrent.CheckedFuture;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import org.junit.Assert;
@Override
public InputStream openStream() throws IOException {
- return new ByteArrayInputStream(this.content.getBytes(Charsets.UTF_8));
+ return new ByteArrayInputStream(this.content.getBytes(StandardCharsets.UTF_8));
}
}
package org.opendaylight.yangtools.yang.parser.util;
import com.google.common.annotations.Beta;
-import com.google.common.base.Charsets;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Futures;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
import org.antlr.v4.runtime.ParserRuleContext;
import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
//:TODO missing validation (YangModelBasicValidationListener should be re-implemented to new parser)
// Backwards compatibility
- final String text = input.asCharSource(Charsets.UTF_8).read();
+ final String text = input.asCharSource(StandardCharsets.UTF_8).read();
return Futures.immediateCheckedFuture(ASTSchemaSource.create(input.getIdentifier(), ctx, text));
}
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
-
-import com.google.common.base.Charsets;
import com.google.common.base.Function;
import com.google.common.base.MoreObjects;
import com.google.common.base.Optional;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ExecutionException;
import org.junit.Test;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.repo.api.MissingSchemaSourceException;
+import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactory;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaResolutionException;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
sharedSchemaRepository.registerSchemaSourceListener(listener);
final File test = new File(storageDir, "test.yang");
- Files.write("content-test", test, Charsets.UTF_8);
+ Files.write("content-test", test, StandardCharsets.UTF_8);
final File test2 = new File(storageDir, "test@2012-12-12.yang");
- Files.write("content-test-2012", test2, Charsets.UTF_8);
+ Files.write("content-test-2012", test2, StandardCharsets.UTF_8);
final File test3 = new File(storageDir, "test@2013-12-12.yang");
- Files.write("content-test-2013", test3, Charsets.UTF_8);
+ Files.write("content-test-2013", test3, StandardCharsets.UTF_8);
final File test4 = new File(storageDir, "module@2010-12-12.yang");
- Files.write("content-module-2010", test4, Charsets.UTF_8);
+ Files.write("content-module-2010", test4, StandardCharsets.UTF_8);
final FilesystemSchemaSourceCache<YangTextSchemaSource> cache = new FilesystemSchemaSourceCache<>(sharedSchemaRepository, YangTextSchemaSource.class, storageDir);
@Override
public InputStream openStream() throws IOException {
- return new ByteArrayInputStream("running".getBytes(Charsets.UTF_8));
+ return new ByteArrayInputStream("running".getBytes(StandardCharsets.UTF_8));
}
});
}