Move snappy codec to netty-codec

This commit is contained in:
Trustin Lee 2012-12-19 18:12:18 +09:00
parent 67da6e4bf9
commit e353540d47
11 changed files with 29 additions and 103 deletions

View File

@ -1,43 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2012 The Netty Project
~
~ The Netty Project 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.netty</groupId>
<artifactId>netty-parent</artifactId>
<version>4.0.0.Beta1-SNAPSHOT</version>
</parent>
<artifactId>netty-codec-snappy</artifactId>
<packaging>jar</packaging>
<name>Netty/Codec/Snappy</name>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-codec</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-handler</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -1,20 +0,0 @@
/*
* Copyright 2012 The Netty Project
*
* The Netty Project 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.
*/
/**
* Encoder and decoder for the Snappy compression protocol.
*/
package io.netty.handler.codec.compression.snappy;

View File

@ -13,10 +13,9 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.handler.codec.compression.snappy;
package io.netty.handler.codec.compression;
import io.netty.buffer.ByteBuf;
import io.netty.handler.codec.compression.CompressionException;
/**
* Uncompresses an input {@link ByteBuf} encoded with Snappy compression into an

View File

@ -13,10 +13,9 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.handler.codec.compression.snappy;
package io.netty.handler.codec.compression;
import io.netty.buffer.ByteBuf;
import io.netty.handler.codec.compression.CompressionException;
import java.util.zip.CRC32;

View File

@ -13,17 +13,16 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.handler.codec.compression.snappy;
import java.nio.charset.Charset;
import java.util.Arrays;
import static io.netty.handler.codec.compression.snappy.SnappyChecksumUtil.validateChecksum;
package io.netty.handler.codec.compression;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToByteDecoder;
import io.netty.handler.codec.compression.CompressionException;
import java.nio.charset.Charset;
import java.util.Arrays;
import static io.netty.handler.codec.compression.SnappyChecksumUtil.*;
/**
* Uncompresses a {@link ByteBuf} encoded with the Snappy framing format.

View File

@ -13,13 +13,13 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.handler.codec.compression.snappy;
package io.netty.handler.codec.compression;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToByteEncoder;
import static io.netty.handler.codec.compression.snappy.SnappyChecksumUtil.*;
import static io.netty.handler.codec.compression.SnappyChecksumUtil.*;
/**
* Compresses a {@link ByteBuf} using the Snappy framing format.

View File

@ -16,8 +16,9 @@
/**
* Encoder and decoder which compresses and decompresses {@link io.netty.buffer.ByteBuf}s
* in a compression format such as <a href="http://en.wikipedia.org/wiki/Zlib">zlib</a>
* and <a href="http://en.wikipedia.org/wiki/Gzip">gzip</a>.
* in a compression format such as <a href="http://en.wikipedia.org/wiki/Zlib">zlib</a>,
* <a href="http://en.wikipedia.org/wiki/Gzip">gzip</a>, and
* <a href="http://code.google.com/p/snappy/">Snappy</a>.
*
* @apiviz.exclude \.codec\.(?!compression)[a-z0-9]+\.
* @apiviz.exclude ^java\.lang\.

View File

@ -13,18 +13,15 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.handler.codec.compression.snappy;
import static org.junit.Assert.assertEquals;
import static io.netty.handler.codec.compression.snappy.SnappyChecksumUtil.*;
package io.netty.handler.codec.compression;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.handler.codec.compression.CompressionException;
import org.junit.Test;
import static io.netty.handler.codec.compression.SnappyChecksumUtil.*;
import static org.junit.Assert.*;
public class SnappyChecksumUtilTest {
@Test
public void testCalculateChecksum() {

View File

@ -13,16 +13,14 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.handler.codec.compression.snappy;
import static org.junit.Assert.*;
package io.netty.handler.codec.compression;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.handler.codec.compression.CompressionException;
import org.junit.Test;
import static org.junit.Assert.*;
public class SnappyFramedDecoderTest {
private final SnappyFramedDecoder decoder = new SnappyFramedDecoder();

View File

@ -13,15 +13,14 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.handler.codec.compression.snappy;
import static org.junit.Assert.assertArrayEquals;
package io.netty.handler.codec.compression;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.junit.Test;
import static org.junit.Assert.*;
public class SnappyFramedEncoderTest {
private final SnappyFramedEncoder encoder = new SnappyFramedEncoder();

View File

@ -13,15 +13,12 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.handler.codec.compression.snappy;
import static org.junit.Assert.assertArrayEquals;
package io.netty.handler.codec.compression;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.handler.codec.compression.CompressionException;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
public class SnappyTest {
@ -46,7 +43,7 @@ public class SnappyTest {
byte[] expected = {
0x6e, 0x65, 0x74, 0x74, 0x79
};
assertArrayEquals("Literal was not decoded correctly", expected, out.array());
Assert.assertArrayEquals("Literal was not decoded correctly", expected, out.array());
}
@Test
@ -65,7 +62,7 @@ public class SnappyTest {
byte[] expected = {
0x6e, 0x65, 0x74, 0x74, 0x79, 0x6e, 0x65, 0x74, 0x74, 0x79
};
assertArrayEquals("Copy was not decoded correctly", expected, out.array());
Assert.assertArrayEquals("Copy was not decoded correctly", expected, out.array());
}
@Test(expected = CompressionException.class)
@ -118,7 +115,7 @@ public class SnappyTest {
0x04 << 2, // literal tag + length
0x6e, 0x65, 0x74, 0x74, 0x79 // "netty"
};
assertArrayEquals("Encoded literal was invalid", expected, out.array());
Assert.assertArrayEquals("Encoded literal was invalid", expected, out.array());
}
@Test
@ -168,6 +165,6 @@ public class SnappyTest {
0x15, 0x4c
};
assertArrayEquals("Encoded result was incorrect", expected, out.array());
Assert.assertArrayEquals("Encoded result was incorrect", expected, out.array());
}
}