Skip to content

Commit

Permalink
Add missing BIG_INTEGER TypeModelValue
Browse files Browse the repository at this point in the history
  • Loading branch information
kabir committed Aug 3, 2011
1 parent 75d3ad1 commit b5a382e
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/main/java/org/jboss/dmr/TypeModelValue.java
Expand Up @@ -53,6 +53,7 @@ void writeExternal(final DataOutput out) throws IOException {
private static final TypeModelValue DECIMAL = new TypeModelValue(ModelType.BIG_DECIMAL);
private static final TypeModelValue DOUBLE = new TypeModelValue(ModelType.DOUBLE);
private static final TypeModelValue INT = new TypeModelValue(ModelType.INT);
private static final TypeModelValue INTEGER = new TypeModelValue(ModelType.BIG_INTEGER);
private static final TypeModelValue LONG = new TypeModelValue(ModelType.LONG);
private static final TypeModelValue LIST = new TypeModelValue(ModelType.LIST);
private static final TypeModelValue OBJECT = new TypeModelValue(ModelType.OBJECT);
Expand All @@ -74,6 +75,8 @@ static TypeModelValue of(final ModelType type) {
return DOUBLE;
case BIG_DECIMAL:
return DECIMAL;
case BIG_INTEGER:
return INTEGER;
case BYTES:
return BYTES;
case LIST:
Expand Down Expand Up @@ -128,7 +131,7 @@ void formatAsJSON(final PrintWriter writer, final int indent, final boolean mult

/**
* Determine whether this object is equal to another.
*
*
* @param other the other object
* @return {@code true} if they are equal, {@code false} otherwise
*/
Expand All @@ -139,7 +142,7 @@ public boolean equals(final Object other) {

/**
* Determine whether this object is equal to another.
*
*
* @param other the other object
* @return {@code true} if they are equal, {@code false} otherwise
*/
Expand Down
59 changes: 59 additions & 0 deletions src/test/java/org/jboss/dmr/SerializeTest.java
@@ -0,0 +1,59 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2006, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.dmr;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.util.Arrays;

import org.junit.Test;

/**
*
* @author <a href="kabir.khan@jboss.com">Kabir Khan</a>
* @version $Revision: 1.1 $
*/
public class SerializeTest
{
@Test
public void testSerializeNodeWithBytes() throws Exception {
ModelNode node = new ModelNode();
node.get("name").set("theName");
node.get("bytes").set(new byte[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9});

ByteArrayOutputStream bout = new ByteArrayOutputStream();
DataOutputStream dout = new DataOutputStream(bout);

node.writeExternal(dout);
dout.close();

byte[] nodebytes = bout.toByteArray();

System.out.println(Arrays.toString(nodebytes));

ModelNode result = new ModelNode();
result.readExternal(new DataInputStream(new ByteArrayInputStream(nodebytes)));

}
}

0 comments on commit b5a382e

Please sign in to comment.