Example usage for junit.framework Assert assertEquals

List of usage examples for junit.framework Assert assertEquals

Introduction

In this page you can find the example usage for junit.framework Assert assertEquals.

Prototype

static public void assertEquals(int expected, int actual) 

Source Link

Document

Asserts that two ints are equal.

Usage

From source file:com.acc.core.suggestion.DefaultSimpleSuggestionServiceIntegrationTest.java

@Test
public void testReferencesForPurchasedInCategory() {
    final UserModel user = userService.getUserForUID("deJol");
    final CategoryModel category = categoryService.getCategoryForCode("cameras");

    List<ProductModel> result = simpleSuggestionService.getReferencesForPurchasedInCategory(category, user,
            null, false, null);//from   w ww .  java2 s.  c  om
    Assert.assertEquals(4, result.size());
    result = simpleSuggestionService.getReferencesForPurchasedInCategory(category, user, null, false,
            NumberUtils.INTEGER_ONE);
    Assert.assertEquals(1, result.size());
    result = simpleSuggestionService.getReferencesForPurchasedInCategory(category, user,
            ProductReferenceTypeEnum.SIMILAR, false, null);
    Assert.assertEquals(1, result.size());
    result = simpleSuggestionService.getReferencesForPurchasedInCategory(category, user,
            ProductReferenceTypeEnum.ACCESSORIES, false, null);
    Assert.assertEquals(2, result.size());
    result = simpleSuggestionService.getReferencesForPurchasedInCategory(category, user,
            ProductReferenceTypeEnum.ACCESSORIES, true, null);
    Assert.assertEquals(1, result.size());
    final ProductModel product = result.get(0);
    Assert.assertEquals("adapterDC", product.getCode());
    Assert.assertEquals("adapter", product.getName());
}

From source file:com.dianping.phoenix.dev.core.tools.generator.stable.ServiceMetaGeneratorTest.java

@Test
public void test() throws Exception {
    String expected = "<services>\n"
            + "    <service name=\"http://service.dianping.com/shoppicService/shoppicService_1.0.0\">\n"
            + "        <port>2000</port>\n" + "    </service>\n"
            + "    <service name=\"http://service.dianping.com/groupService/groupService_1.0.0\">\n"
            + "        <port>2001</port>\n" + "    </service>\n"
            + "    <service name=\"http://service.dianping.com/accountService/accountService_1.0.0\">\n"
            + "        <port>2002</port>\n" + "    </service>\n"
            + "    <service name=\"http://service.dianping.com/userService/userService_1.0.0\">\n"
            + "        <port>2003</port>\n" + "    </service>\n" + "</services>";
    ServiceMetaContext context = new ServiceMetaContext("org.h2.Driver", "jdbc:h2:mem:hawk;DB_CLOSE_DELAY=-1",
            "", "");
    ServiceMetaGenerator smg = new ServiceMetaGenerator();
    smg.generate(file, context);/*from ww w.j a  v  a  2 s.c om*/
    Assert.assertEquals(expected, FileUtils.readFileToString(file));
}

From source file:com.fufang.testcase.orgmanager.warnset.SaveOrUpdate.java

@Test
public void saveWarn() throws IOException, URISyntaxException, SQLException {

    List<NameValuePair> nvps = new ArrayList<NameValuePair>();
    nvps.add(new BasicNameValuePair("jsonStr",
            "{\"warnBeanList\": [{\"warnType\": \"32\",\"warnGspType\": 3,\"licenseId\":\"77\",\"isOn\":1,\"dayNum\":30,\"maintainDay\": 90,\"roles\":\"B6E58291-0A5B-49A3-B379-19DAC845789F\"}]}"));

    String result = HttpPostLogin.httpPost(testUrl, nvps, loginUrl, userName, pwd);

    JSONObject jsonObject = JSONObject.fromObject(result);
    int state = jsonObject.getInt("state");
    String msg = jsonObject.getString("msg");
    System.out.println(state + " - " + msg);

    Assert.assertEquals(200, state);
    Assert.assertEquals("success", msg);

    SqlUtils c = new SqlUtils();
    con = c.sqlSConnection(dbUrl, dbName, dbUserName, dbPassword);

    try {//from  w w w . j  a  v  a2s  .  co m
        Statement statement = con.createStatement();

        String querySqlU = "SELECT * FROM [dbo].[t_warn] WHERE roles ='B6E58291-0A5B-49A3-B379-19DAC845789F'";
        ResultSet resultSetU = statement.executeQuery(querySqlU);

        while (resultSetU.next()) {
            setId(resultSetU.getInt("id"));
            String warnType = resultSetU.getString("warnType");
            Assert.assertEquals("32", warnType);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:cec.easyshop.core.suggestion.DefaultSimpleSuggestionServiceIntegrationTest.java

@Test
public void testReferencesForPurchasedInCategory() {
    final UserModel user = userService.getUserForUID("dejol");
    final CategoryModel category = categoryService.getCategoryForCode("cameras");

    List<ProductModel> result = simpleSuggestionService.getReferencesForPurchasedInCategory(category, user,
            null, false, null);//from   www .  j a  v a  2 s. c  o m
    Assert.assertEquals(4, result.size());
    result = simpleSuggestionService.getReferencesForPurchasedInCategory(category, user, null, false,
            NumberUtils.INTEGER_ONE);
    Assert.assertEquals(1, result.size());
    result = simpleSuggestionService.getReferencesForPurchasedInCategory(category, user,
            ProductReferenceTypeEnum.SIMILAR, false, null);
    Assert.assertEquals(1, result.size());
    result = simpleSuggestionService.getReferencesForPurchasedInCategory(category, user,
            ProductReferenceTypeEnum.ACCESSORIES, false, null);
    Assert.assertEquals(2, result.size());
    result = simpleSuggestionService.getReferencesForPurchasedInCategory(category, user,
            ProductReferenceTypeEnum.ACCESSORIES, true, null);
    Assert.assertEquals(1, result.size());
    final ProductModel product = result.get(0);
    Assert.assertEquals("adapterDC", product.getCode());
    Assert.assertEquals("adapter", product.getName());
}

From source file:com.mirth.connect.plugins.datatypes.ncpdp.test.NCPDPSerializerTest.java

@Test
public void test51RequestFromXml() throws Exception {
    String input = FileUtils.readFileToString(new File("tests/test-ncpdp-51-request-output.xml"));
    String output = FileUtils.readFileToString(new File("tests/test-ncpdp-51-request-input.txt"));
    NCPDPSerializer serializer = new NCPDPSerializer(defaultProperties.getSerializerProperties());
    Assert.assertEquals(output, serializer.fromXML(input));
}

From source file:com.couchbase.capi.TestCAPI.java

public void testDatabaseHeadDoesNotExist() throws Exception {
    HttpClient client = getClient();//w  w  w . j a va 2  s . co  m

    HttpUriRequest request = new HttpHead(String.format("http://localhost:%d/doesnotexist", port));
    HttpResponse response = client.execute(request);

    Assert.assertEquals(404, response.getStatusLine().getStatusCode());
}

From source file:org.ocpsoft.rewrite.config.tuckey.TuckeyConfigurationProviderTest.java

@Test
public void testConfigurationIntegratesWithRedirectFlow() throws Exception {
    HttpAction<HttpGet> action = get("/some/olddir/value");
    Assert.assertEquals("/very/newdir/value", action.getCurrentURL());
    Assert.assertEquals(404, action.getStatusCode());
}

From source file:org.apache.wink.test.mock.MockHttpServletRequestWrapperTestCase.java

@Test
public void testParameter() throws Exception {
    HttpServletRequest req = MockRequestConstructor.constructMockRequest("POST", "/test", "application/json",
            "application/x-www-form-urlencoded", "x=1&y=2&z=%20".getBytes("UTF-8"));
    String x = req.getParameter("x");
    String y = req.getParameter("y");
    String z = req.getParameter("z");
    String a = req.getParameter("a");

    Assert.assertEquals("1", x);
    Assert.assertEquals("2", y);
    Assert.assertEquals(" ", z);
    Assert.assertNull(a);//from  ww w.j  ava  2s  . com

    Assert.assertEquals(3, req.getParameterMap().size());
}

From source file:com.github.neoio.net.message.staging.memory.TestMemoryMessageStaging.java

@Test
public void test_tempWrite() {
    ByteBuffer buffer = ByteBuffer.allocate(1024);

    buffer.put("Hello World".getBytes());
    buffer.rewind();/*w w  w  . j ava  2  s.  com*/
    staging.writeTempWriteBytes(buffer);
    Assert.assertTrue(staging.hasTempWriteBytes());

    buffer.clear();
    staging.readTempWriteBytes(buffer);
    Assert.assertEquals("Hello World",
            new String(ArrayUtils.subarray(buffer.array(), 0, "Hello World".getBytes().length)));
    staging.resetTempWriteBytes();

    Assert.assertFalse(staging.hasTempWriteBytes());
}

From source file:com.inferiorhumanorgans.WayToGo.Agency.NextBus.RouteList.RouteListXMLTask.java

@Override
protected Void doInBackground(final NextBusAgency... someAgencies) {
    Assert.assertEquals(1, someAgencies.length);
    super.doInBackground(someAgencies);
    String theNBName = theAgency.getNextBusName();

    Log.i(LOG_NAME, "Trying to get the route list for " + theNBName + ".");

    InputStream content = null;// w w w.j  ava  2  s  .  c om
    ClientConnectionManager connman = new ThreadSafeClientConnManager(params, registry);
    DefaultHttpClient hc = new DefaultHttpClient(connman, params);

    String theNBURL = "http://webservices.nextbus.com/service/publicXMLFeed?command=routeList&a=";
    theNBURL += Uri.encode(theNBName);
    Log.i(LOG_NAME, "Fetching from: " + theNBURL);
    HttpGet getRequest = new HttpGet(theNBURL);
    try {
        content = hc.execute(getRequest).getEntity().getContent();
    } catch (ClientProtocolException ex) {
        Logger.getLogger(LOG_NAME).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(LOG_NAME).log(Level.SEVERE, null, ex);
        this.cancel(true);
        return null;
    }

    try {
        SAXParserFactory spf = SAXParserFactory.newInstance();
        SAXParser sp = spf.newSAXParser();

        XMLReader xr = sp.getXMLReader();

        xr.setContentHandler(theDataHandler);

        xr.parse(new InputSource(content));

    } catch (ParserConfigurationException pce) {
        Log.e(LOG_NAME + " SAX XML", "sax parse error", pce);
    } catch (AbortXMLParsingException abrt) {
        Log.i(LOG_NAME + " AsyncXML", "Cancelled!!!!!");
    } catch (SAXException se) {
        Log.e(LOG_NAME + " SAX XML", "sax error", se);
    } catch (IOException ioe) {
        Log.e(LOG_NAME + " SAX XML", "sax parse io error", ioe);
    }
    //Log.i(LOG_NAME + " SAX XML", "Done parsing XML for " + theNBName);
    return null;
}