/**
 *
 * Copyright © 2014 Florian Schmaus
 *
 * Licensed 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.jxmpp.util;

import static org.junit.Assert.assertEquals;

import org.jxmpp.util.XmppStringUtils;

import org.junit.Test;

public class XmppStringUtilsTest {

	@Test
	public void parseLocalpart() {
		String error = "Error parsing node name";
		assertEquals(error, "", XmppStringUtils.parseLocalpart("yahoo.myjabber.net"));
		assertEquals(error, "", XmppStringUtils.parseLocalpart("yahoo.myjabber.net/registred"));
		assertEquals(error, "user", XmppStringUtils.parseLocalpart("user@yahoo.myjabber.net/registred"));
		assertEquals(error, "user", XmppStringUtils.parseLocalpart("user@yahoo.myjabber.net"));
	}

	@Test
	public void parseDomain() {
		String error = "Error parsing server name";
		String result = "yahoo.myjabber.net";
		assertEquals(error, result, XmppStringUtils.parseDomain("yahoo.myjabber.net"));
		assertEquals(error, result, XmppStringUtils.parseDomain("yahoo.myjabber.net/registred"));
		assertEquals(error, result, XmppStringUtils.parseDomain("user@yahoo.myjabber.net/registred"));
		assertEquals(error, result, XmppStringUtils.parseDomain("user@yahoo.myjabber.net"));
	}

	public void atCommercialAtInResourcepart() {
		final String expectedLocalpart = "TestAccount";
		final String expectedDomainpart = "server.org";
		final String expectedResource = "foo@bar1";
		final String jid = expectedLocalpart + '@' + expectedDomainpart + '/' + expectedResource;
		String localpart = XmppStringUtils.parseLocalpart(jid);
		String domain = XmppStringUtils.parseDomain(jid);
		String resource = XmppStringUtils.parseResource(jid);

		assertEquals(expectedLocalpart, localpart);
		assertEquals(expectedDomainpart, domain);
		assertEquals(expectedResource, resource);
	}
}

@@ -806,24 +806,30 @@
 lpart() %7B%0A%09%09
+final 
 String error
@@ -850,17 +850,17 @@
 ing 
-node name
+localpart
 %22;%0A%09
@@ -1262,16 +1262,22 @@
 n() %7B%0A%09%09
+final 
 String e
@@ -1302,24 +1302,25 @@
 ing 
-server name%22;%0A%09%09
+domain%22;%0A%09%09final 
 Stri
@@ -1616,32 +1616,32 @@
 t/registred%22));%0A
-
 %09%09assertEquals(e
@@ -1715,16 +1715,459 @@
 ));%0A%09%7D%0A%0A
+%09@Test%0A%09public void parseResource() %7B%0A%09%09final String error = %22Error parsing resource%22;%0A%09%09assertEquals(error, %22%22, XmppStringUtils.parseResource(%22foo.jxmpp.org%22));%0A%09%09assertEquals(error, %22registered%22, XmppStringUtils.parseResource(%22foo.jxmpp.org/registered%22));%0A%09%09assertEquals(error, %22registered%22, XmppStringUtils.parseResource(%22user@foo.jxmpp.org/registered%22));%0A%09%09assertEquals(error, %22%22, XmppStringUtils.parseResource(%22user@foo.jxmpp.org%22));%0A%09%7D%0A%0A
 %09public 

Add unit test for parseResource